Phonegap构建cordova-plugin-facebook4插件不能在iOS上工作 [英] Phonegap Build cordova-plugin-facebook4 plugin not working on iOS

查看:264
本文介绍了Phonegap构建cordova-plugin-facebook4插件不能在iOS上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个包含facebook登录的phonegap构建应用程序。
以下是一些细节。
- 应用程序使用Facebook按钮登录




  • 它使用cordova-plugin-facebook4插件( https://www.npmjs.com/package/cordova-plugin-facebook4


  • 整合代码如下:

      facebookConnectPlugin.login ([public_profile],
    函数(userData){
    alert(login);
    //抓取用户信息使用图形API api
    facebookConnectPlugin.api(me / ?fields = id,name,email,gender,[email,public_profile],
    函数(结果){
    alert(login success);
    // store访问令牌在本地存储
    facebookConnectPlugin.getAccessToken(function(token){
    console.log(Token:+ token);
    });
    },
    函数(错误){
    alert(Failed:+ error);
    });
    },function(error){alert(error);}
    );


  • 上述代码在Android应用程序中运行正常。




- 上述代码在iOS应用程序中不起作用



用于测试的设备:IPad mini iOS版本10.x。






在developer.facebook.com上,该应用程序iOS平台的设置如下:



Bundle ID:与config.xml中的widget id相同的值,用于phonegap



iPhone store id:empty



url scheme suffix:empty



ipad store id:empty



单点登录切换:是






以下是当前行为iOS iPad:
1.用户在iOS应用程序中点击使用Facebook登录
2.用户被带到safari浏览器中的Facebook权限页面
3.用户输入用户ID和密码
4.用户被要求许可,用户单击确认
5. Safari显示一个弹出窗口,询问在应用程序中打开?
6.用户点击Open
7.用户被带到同一个应用程序和同一页面并显示相同的登录链接。



请注意控制不会传回来继续执行脚本,几乎该应用程序从开始重新启动。



Safari Web检查器没有显示任何错误。 >

Mac上的GapDebug(我使用的是虚拟框Yosemite mac版本)没有显示任何错误。



请帮助,因为我不太清楚,我还缺少什么。

解决方案

我知道这个问题迟到了,但这可能有助于其他人解决这个问题。所以这里是解决方案

 < meta http-equiv =Content-Security-Policycontent =default-src * gap:// ready; style-src'self''unsafe-inline'; img-src'self'data :; script-src *'unsafe-inline''unsafe-eval'> 

将其添加到index.html。 gap:// ready 是iOS 10必需的


I am creating a phonegap build app which contains a facebook login. Below are some details. - The app has a Login with facebook button

  • It uses cordova-plugin-facebook4 plugin (https://www.npmjs.com/package/cordova-plugin-facebook4)

  • The integration code is below:

    facebookConnectPlugin.login(["public_profile"], 
    function(userData) {
    alert("login");
    //fetch user info using graph api
    facebookConnectPlugin.api("me/?fields=id,name,email,gender", ["email","public_profile"],
    function (result) {
    alert("login success");
    //store access token in local storage
    facebookConnectPlugin.getAccessToken(function(token) {
    console.log("Token: " + token);
    });
    },
    function (error) {
    alert("Failed: " + error);
    });
    }, function(error){alert("error");}
    );
    

  • The above code works fine for on the android app.

- The above code does not work in iOS app

Device used for testing: IPad mini iOS version 10.x.


On developer.facebook.com, the app settings for iOS platform are as follows:

Bundle ID: same value as widget id in config.xml for phonegap

iPhone store id: empty

url scheme suffix: empty

ipad store id: empty

Single Sign On toggle: YES


Below is the current behavior for iOS iPad: 1. User clicks on Login using Facebook in the iOS app 2. User is taken to facebook permissions page in safari browser 3. User enters user id and password 4. User is asked for permission and User clicks "Confirm" 5. Safari shows a popup asking "Open in App?" 6. User clicks Open 7. User is taken to the same app and the same page and displayed the same login link.

Note that the control is not passed back to continue the script at all, its almost that the app was relaunched from start.

Safari web inspector does not show any errors.

GapDebug on mac (i am using a virtualbox Yosemite mac version) does not show any errors.

Please help as I am not very sure at this point, what else I am missing.

解决方案

I know its late to answer for this question but it might help other to fix this issue. So here is the solution

<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">

add this in index.html. gap://ready is required for iOS 10

这篇关于Phonegap构建cordova-plugin-facebook4插件不能在iOS上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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