Question

I am launching an inapp browser from my phonegap app and I get the following exception:

*** 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]

The code to launch the 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');});
}

In my app I just get a blank screen with the 'done' button on the bottom and says loading. Help!!

Was it helpful?

Solution

The issue was the spaces in the url passed to inAppBrowser(). The URL must be encoded with encodeURI(). This is mentioned in the phonegap docs:

url: the URL to load (String). Call encodeURI() on this if you have Unicode characters in your URL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top