2013-05-11 69 views
0

我從我的PhoneGap應用程序啓動一個應用程式內瀏覽器,我得到以下異常:PhoneGap的InAppBrowser不是(IOS)工作 - 拋出異常

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

在我的應用程序中,我只是在底部看到一個空白屏幕,並顯示加載完成按鈕。幫幫我!!

回答

0

問題是傳遞給inAppBrowser()的url中的空格。該URL必須使用encodeURI()進行編碼。這在phonegap docs中提到:

url:要加載的URL(字符串)。如果您的URL中包含Unicode字符,請調用encodeURI()。