3

我正在使用 phonegap 在 Android 和 iOS 上开发我的应用程序。到目前为止,我已经成功实现了适用于 Android 的 facebook connect 插件,并且效果很好。

我无法做一件事,那就是如何处理插件错误。例如,当没有网络连接时, FB.login(...) 不起作用,我从 facebook-js-sdk.js 收到警报:第 5105 行:

// CORDOVA PATCH
// If the nativeInterface arg is specified then call out to the nativeInterface 
// which uses the native app rather than using the iframe / popup web
if (FB._nativeInterface) {
    switch (params.method) {
        case 'auth.login':
            FB._nativeInterface.login(params, cb, function(e) {alert('Cordova Facebook Connect plugin fail on login!' + e);});
        break;

如何拦截该警报并显示我自己的错误?这是我用于登录的代码:

login: function(success, error) {
   FB.login(function(response) {
     if (response.authResponse) {
        //some code ..
        if (success && typeof(success) === "function") {  
            success();  
        } 
     } else {
        alert('User cancelled login or did not fully authorize.');             
        if (error && typeof(error) === "function") {  
            error(false);  
        } 
     }
   }, {scope: 'email'}); 
}

elsePS:即使我取消登录授权,我也从来没有进入过区块,我也有同样的警报。

我错过了什么吗?

非常感谢您的帮助。

4

0 回答 0