Phonegap InAppBrowser无法使用(iOS) - 抛出异常

时间:2013-05-11 23:34:45

标签: ios cordova inappbrowser

我正在从我的phonegap应用程序启动一个inapp浏览器,我得到以下例外:

*** 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');});
}

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

1 个答案:

答案 0 :(得分:0)

问题是传递给inAppBrowser()的url中的空格。必须使用encodeURI()编码URL。这在phonegap docs

中提到

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