【问题标题】:Access headers/queryparams from a WebView from Nativescript从 Nativescript 的 WebView 访问 headers/queryparams
【发布时间】:2019-07-29 22:02:21
【问题描述】:

我目前正在使用 Nativescript 开发移动应用程序。所以,我在主页上有一个 WebView 可以使用 Spotify 登录。登录后,我必须从 WebView 中的页面检索标题/查询参数。这可能吗?如果可以,我该怎么做?

【问题讨论】:

    标签: javascript angular typescript nativescript nativescript-angular


    【解决方案1】:

    您可以注册 loadFinishedEvent 并检查 URL 以获取返回给您的查询参数。我对第三方登录也是如此。

    webViewLoaded(args) {
            const webview: WebView = <WebView>args.object;
    webview.on(WebView.loadFinishedEvent, (webargs: LoadEventData) => {
                let message;
                if (!webargs.error) {
                    if (webargs.url.toLowerCase().indexOf('spotity') > -1) {
                        //Read the parameters and navigate
    
                    }
    
                    message = 'WebView finished loading of ' + webargs.url;
                } else {
                    message = 'Error loading ' + webargs.url + ': ' + webargs.error;
                }
            });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-10
      • 2020-11-17
      • 2020-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多