facebookConnectPlugin未定义 - PhoneGap Build& Android的 [英] facebookConnectPlugin is not defined - PhoneGap Build & Android

查看:151
本文介绍了facebookConnectPlugin未定义 - PhoneGap Build& Android的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在iOS上使用PhoneGap和Ionic获取facebookConnectPlugin。问题是,当我尝试在Android上运行完全相同的应用程序时,我收到错误没有定义FacebookConnectPlugin。我正在使用PhoneGap Build,而不是为Android设置。



以下是我采取的尝试使其正常工作的步骤在Android上:



1)生成新的密钥库。

  C:\程序文件(x86)\Java\jre1.8.0_60\bin\keytool.exe-genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 

2)使用此密钥库创建一个新的哈希。

 C:\程序文件(x86)\Java\jre1.8.0_60\bin\keytool.exe-exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64 

使用密码android无处不在,要求我输入密码(对于密钥库和哈希)。



3)将以下内容添加到我的config.xml文档中:

 < gap:plugin name =com.phonegap.plugins.facebookconnectversion =0.9.0> 
< param name =APP_IDvalue =XXXXXXXXXX/>
< param name =APP_NAMEvalue =MyApp/>
< / gap:plugin>

我从Facebook和APP_NAME获得的APP_ID是Facebook的显示名称。



4)在PhoneGap中创建一个Android键,构建上传我指定的密钥库和别名androiddebugkey。对于所有密码,包括证书密码我输入我的密码android。 5)将我的应用程序上传到PhoneGap构建,将其安装在Android模拟器(Lollipop使用Visual Studio Emulator for Android)上,并尝试使用以下代码登录Facebook。此代码在$ ionPlatform.ready之后触发。

  var _this = this; 
var fbLoginSuccess = function(userData){
facebookConnectPlugin.api(me /?fields = id,email,[public_profile],
function(result){
},
function(error){
alert(Failed:+ error);
}
);
}

facebookConnectPlugin.login([public_profile],
fbLoginSuccess,
函数(错误){
alert(JSON.stringify(error) );
}
);

6)对于我的网站在developers.facebook.com,我添加了一个Android应用程序。 Google Play软件包名称与config.xml中的widget元素中的id相同。对于类名称,我指定与id完全相同的东西,但附加了.MainActivity。我将从上述步骤2生成的密钥哈希插入密钥哈希字段。我打开了单一登录。不确定是否正确。



我已经花了几天时间来计算出来,没有运气。我不知道问题是与哈希,科尔多瓦或其他一些Facebook的权限。就像我之前说过的,它在iOS上工作正常。这只是Android的问题。



任何帮助都将非常感激。

解决方案

@oalbrecht,



我发布此链接希望你会阅读整个文件。



开发人员对Cordova / Phonegap的新错误



其实您的错误是



3。不遵循博客。



你看,现在我们已经转到npm.org上的新的存储库了。这实际上让你有另一个错误



11。您需要从NPM获取您的插件。



我是如何计算出来的?我对您的插件进行了google搜索: com.phonegap.plugins.facebookconnect



关于三(3)个链接是你的插件: FacebookConnect



文档说



现在已经结束!!! / h2>

here



请仔细阅读方向。这是一个丑陋的插件。正确的链接是:





您的新插件设置为:



code< gap:plugin name =cordova-plugin-facebookconnect-orlandosource =npmversion =0.11.0>


I was able to get the facebookConnectPlugin working on iOS using PhoneGap and Ionic. The issue is that when I try to run the exact same app on Android I get the error "facebookConnectPlugin is not defined". I'm using PhoneGap Build and am not building natively for Android.

Here are the steps I've taken to try to get it working on Android:

1) Generated a new keystore.

"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 

2) Created a new hash using this keystore.

"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64

Used the password "android" everywhere it asked me for a password (for the keystore and the hash).

3) Added the following to my config.xml document:

<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0">
    <param name="APP_ID" value="XXXXXXXXXX" />
    <param name="APP_NAME" value="MyApp" />
</gap:plugin>

The APP_ID I got from Facebook and the APP_NAME was the display name from Facebook.

4) Created an Android key in PhoneGap build uploading the keystore I specified and the alias "androiddebugkey". For all the passwords, including the certificate password I input my password "android".

5) Uploaded my application to PhoneGap build, installed it on an Android emulator (Lollipop using Visual Studio Emulator for Android) and tried to log into Facebook using the following code. This code fires after $ionicPlatform.ready.

var _this = this;    
var fbLoginSuccess = function (userData) {
    facebookConnectPlugin.api("me/?fields=id,email", ["public_profile"],
        function (result) {
        },
        function (error) {
            alert("Failed: " + error);
        }
    );
}

facebookConnectPlugin.login(["public_profile"],
    fbLoginSuccess,
    function (error) {
        alert(JSON.stringify(error));
    }
);

6) For my site at developers.facebook.com I added an Android app. The Google Play Package Name is the same as my "id" in the widget element in config.xml. For the Class Name, I specified the exact same thing as the id, but with ".MainActivity" appended to it. I inserted the Key Hash generated from Step 2 above into the Key Hashes field. I turned Single Sign On on. Not sure if that is correct or not.

I've spent days trying to figure this out with no luck. I'm not sure if the issue is with the hash, cordova, or some other Facebook permissions. Like I said earlier, it works fine on iOS. It's just Android that has the problem.

Any help would be very much appreciated.

解决方案

@oalbrecht,

I am posting this link with the hope you will read the entire document.

Top Mistakes by Developers new to Cordova/Phonegap

In fact your error was

3. Does not follow the blogs.

For you see, we have now move to a new repository on npm.org. This actually gets you another error

11. You need to get your plugins from NPM now.

How did I figure this out? I did a google search of your plugin: com.phonegap.plugins.facebookconnect

About three (3) links down is your plugin: FacebookConnect

The documentation says

REPOSITORY IS NOW DEPRECATED!!!

Please go here

READ THE DIRECTIONS CAREFULLY. This is an ugly plugin. The correct links are:

Your new plugin setting is:

<gap:plugin name="cordova-plugin-facebookconnect-orlando" source="npm" version="0.11.0">

这篇关于facebookConnectPlugin未定义 - PhoneGap Build&amp; Android的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆