0

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

私のアプリでは、下部に「完了」ボタンが付いた空白の画面が表示され、読み込み中と表示されます。ヘルプ!!

4

1 に答える 1

0

問題は、inAppBrowser() に渡される URL のスペースでした。URL は、encodeURI() でエンコードする必要があります。これはphonegap docsで言及されています:

url: 読み込む URL (文字列)。URL に Unicode 文字が含まれている場合は、encodeURI() を呼び出します。

于 2013-05-11T23:46:45.190 に答える