开发者

Facebook Connect / phonegap - "nativeInterface" parameter within FB.init call, what it does?

So I have been trying to run the Facebook Connect example for PhoneGap / Android with no luck. https://github.com/davejohnson/phonegap-plugin-facebook-connect *

There are some similar threads with the same problem.. conclusion is that "Facebook SDK is a moving point"

I have succesfully compiled previously apps using phoneGap & Eclipse. Now following the example* for Android. If I do exactly what they suggest. App shows the buttons but nothing happens when I click on them.

After analyzing the code I have noticed that

function initFB(){
try {
    FB.init({ appId: "45253452345234523", nativeInterface: PG.FB });
    document.getElementById('data'开发者_Python百科).innerHTML = "";
  } catch (e) {
    alert(e);
  }
}

there is a parameter nativeInterface : PG.FB which is nowhere described within Facebook API for this call.. http://developers.facebook.com/docs/reference/javascript/FB.init/

what is more interesting is that when i remove this parameter.. suddenly Login button goes to Facebook page with Error Code API 191.

So my question is what this parameter is supposed to do? and why it is not in Facebook API?

I have found no info about this parameter in internet. I guess if it would be a case of an out-dated FB API there would be some info available.

Any ideas?

Thanks,

Marcin


The "nativeInterface: PG.FB" option is to tell PhoneGap to use the native authentication interface instead of the mobile web interface. If you don't add in the "PG.FB" option, you'll get redirected to Facebook's mobile authentication instead. It took me a while to figure this out too, and it's not well documented, but that's what is going on.

Two other things about the PhoneGap Facebook Plugin that are not up to date with the latest Facebook JavaScript SDK:

  1. When using FB.login() you should be using the "scope" parameter, but PhoneGap expects the deprecated "perms" parameter.
  2. When the authentication response from FB.login() you should be getting "response.authResponse", but instead "response.session" is what is given back. This means you'll have to pull out the OAuth Access token with "response.session.auth_token" instead of "response.authResponse.accessToken".

Hopefully they'll get to updating the PhoneGap Facebook Plugin, but for now I use if/else statements to detect if PhoneGap is there. You can check if PhoneGap is initialized by using:

if(window.PhoneGap) {
  //PhoneGap Library is Loaded
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜