简体   繁体   English

Facebook Connect / phonegap - FB.init调用中的“nativeInterface”参数,它有什么作用?

[英]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. 所以我一直试图为PhoneGap / Android运行Facebook Connect示例而没有运气。 https://github.com/davejohnson/phonegap-plugin-facebook-connect * 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" 有一些类似的线程有同样的问题。结论是“Facebook SDK是一个移动点”

I have succesfully compiled previously apps using phoneGap & Eclipse. 我使用phoneGap和Eclipse成功编译了以前的应用程序。 Now following the example* for Android. 现在关注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').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/ 有一个参数nativeInterface:PG.FB在Facebook API中没有为此调用描述.. 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. 更有趣的是,当我删除此参数时..突然登录按钮进入带有错误代码API 191的Facebook页面。

So my question is what this parameter is supposed to do? 所以我的问题是这个参数应该做什么? and why it is not in Facebook API? 为什么它不在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. 我想如果它是一个过时的FB API的情况下会有一些信息可用。

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. “nativeInterface:PG.FB”选项用于告诉PhoneGap使用本机身份验证接口而不是移动Web界面。 If you don't add in the "PG.FB" option, you'll get redirected to Facebook's mobile authentication instead. 如果您没有添加“PG.FB”选项,您将被重定向到Facebook的移动身份验证。 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: 关于PhoneGap Facebook插件的另外两件事与最新的Facebook JavaScript SDK不同:

  1. When using FB.login() you should be using the "scope" parameter, but PhoneGap expects the deprecated "perms" parameter. 使用FB.login()时,您应该使用“scope”参数,但PhoneGap需要不推荐使用的“perms”参数。
  2. When the authentication response from FB.login() you should be getting "response.authResponse", but instead "response.session" is what is given back. 当来自FB.login()的验证响应时,你应该得到“response.authResponse”,而是“response.session”是给出的。 This means you'll have to pull out the OAuth Access token with "response.session.auth_token" instead of "response.authResponse.accessToken". 这意味着您必须使用“response.session.auth_token”而不是“response.authResponse.accessToken”来提取OAuth访问令牌。

Hopefully they'll get to updating the PhoneGap Facebook Plugin, but for now I use if/else statements to detect if PhoneGap is there. 希望他们能够更新PhoneGap Facebook插件,但是现在我使用if / else语句来检测PhoneGap是否存在。 You can check if PhoneGap is initialized by using: 您可以使用以下命令检查PhoneGap是否已初始化:

if(window.PhoneGap) { if(window.PhoneGap){
//PhoneGap Library is Loaded //已加载PhoneGap库
} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook FB.Init()无法用于Android Unity - Facebook FB.Init() Fail for Android Unity 调用fb.init时,Android上的Facebook Unity SDK崩溃 - Facebook Unity SDK on Android crashes when fb.init is called Facebook sdk for unity 显示 NullReferenceException: Facebook object is not yet loaded。 你调用了 FB.Init() 了吗? 在谷歌内部测试中 - Facebook sdk for unity shows NullReferenceException: Facebook object is not yet loaded. Did you call FB.Init()? on google internal test Facebook如何在“Facebook Connect”设置中使用FB Init调用设置Cookies? - How does Facebook set Cookies with FB Init call in “Facebook Connect” setup? 适用于Android的Unity的Facebook SDK尝试在不调用FB.login的情况下登录FB.init - Facebook SDK for Unity on Android tries to login on FB.init without calling FB.login 适用于Unity的Facebook SDK v7.0.3 FB.Init委托从未调用 - Facebook SDK for Unity v7.0.3 FB.Init delegate never called phonegap-plugin-facebook-connect:FB.Login之后没有回调函数 - phonegap-plugin-facebook-connect: no callback function after FB.Login PhoneGap Facebook插件Init()函数 - PhoneGap Facebook plugin Init() function Facebook连接和电话差距 - Facebook connect and phonegap 带有Facebook Connect集成的PhoneGap的问题 - Problems with PhoneGap with Facebook Connect integration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM