简体   繁体   English

Phonegap Cordova使用Facebook登录

[英]Phonegap Cordova Login with Facebook

I'm new in Phonegap and i'm trying to add Facebook login in my Cordova application, i tried Plugin and Facebook SDK for Javascript. 我是Phonegap的新手,我想在我的Cordova应用程序中添加Facebook登录名,我尝试了Java插件和Facebook SDK。

Plugin: https://github.com/jeduan/cordova-plugin-facebook4 插件: https//github.com/jeduan/cordova-plugin-facebook4

Facebook JavaScript SDK: https://developers.facebook.com/docs/facebook-login/web Facebook JavaScript SDK: https//developers.facebook.com/docs/facebook-login/web

In both the sdk and javascript plugin, I encountered difficulties. 在sdk和javascript插件中,我都遇到了困难。

Plugin: 插入:

The key hash does not match any stored key hashes

Facebook SDK JS: Facebook SDK JS:

Unable to load URL: The domain for this URL is not included in the application domains. In order to load this URL, add all domains and subdomains to the Application Domains field in the application settings.

I tried to add localhost as my domain but does not work, and tried to create a hash in Windows, I generated the hash and added it to my facebook app but still appear the same error. 我试图将localhost添加为我的域,但不起作用,并尝试在Windows中创建哈希,我生成了哈希并将其添加到我的facebook应用中,但仍然出现相同的错误。

Anyone has idea? 有人知道吗?

<!--Version Phonegap-->
<preference name="cordova-ios" version="4.5.4" />
<preference name="phonegap-version" value="cli-8.0.0" />

Facebook Plugin config.xml: Facebook插件config.xml:

<plugin name="cordova-plugin-facebook4" spec="~4.2.1">
    <variable name="APP_ID" value="XXXXXXXXX" />
    <variable name="APP_NAME" value="YYYYYY" />
</plugin>

Facebook Plugin Login: Facebook插件登录:

const permissions = new Array("email","public_profile");

        facebookConnectPlugin.login(permissions, function (userData) {
            console.log("UserInfo: ", userData);
        },
          function loginError(error) {
            console.error(error)
          }
        );

Facebook SDK JS: Facebook SDK JS:

FB.login(function (response) {
            if (response.status === 'connected') {
                // Logged into your app and Facebook.
            } else {
                // The person is not logged into this app or we are unable to tell. 
            }
        });

I found a way to resolve: 我找到了一种解决方法:

The key hash does not match any stored key hashes

I setup my Facebook App as Android Platform and set my package name with (config.xml): 我将我的Facebook应用设置为Android平台,并使用(config.xml)设置程序包名称:

widget id="com.XXXX.YYY.ZZZ"

And my Class Name, i follow this and used http://www.javadecompilers.com/result . 还有我的班级名称,我遵循名称并使用了http://www.javadecompilers.com/result

To generate my hash, i follow Muhammad Omar ElShourbagy solution . 为了生成我的哈希,我遵循Muhammad Omar ElShourbagy解决方案

Everything works fine. 一切正常。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM