【问题标题】:Phonegap InAppBrowser not working in (iOS) - Exception thrownPhonegap InAppBrowser 在 (iOS) 中不起作用 - 抛出异常
【发布时间】:2013-05-11 23:34:45
【问题描述】:

我正在从我的 phonegap 应用启动应用内浏览器,但出现以下异常:

*** WebKit discarded an uncaught exception in the
webView:decidePolicyForNavigationAction:request:frame:decisionListener:
delegate: <NSInvalidArgumentException>
 *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
 attempt to insert nil object from objects[1]

启动inAppBrowser的代码:

function loginFromInAppBrowser() {
    var client_id="clientid.apps.googleusercontent.com";
    var state="whatever_you_want";
    var scope="https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/devstorage.read_only";
    var url="https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=" + client_id + "&state=" + state + "&redirect_uri=mypackage:/oauth2callback&scope=" + scope;

    var ref = window.open(url, '_blank', 'location=yes');
    ref.addEventListener('loadstop', function(event) {console.log(event.url+event.token);});
    ref.addEventListener('onerror', function() { console.log('error');});
    ref.addEventListener('loadstart', function() { console.log('start');});
}

在我的应用程序中,我只是得到一个空白屏幕,底部有“完成”按钮并显示正在加载。救命!!

【问题讨论】:

    标签: ios cordova inappbrowser


    【解决方案1】:

    问题是传递给 inAppBrowser() 的 url 中的空格。 URL 必须使用 encodeURI() 进行编码。 phonegap docs中提到了这一点:

    url:要加载的 URL(字符串)。如果您的 URL 中有 Unicode 字符,请在此调用 encodeURI()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-29
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      • 1970-01-01
      • 2018-04-01
      • 1970-01-01
      相关资源
      最近更新 更多