Facebook插件安装Facebook应用程序后不工作 [英] Facebook plugin not works after installing facebook application

查看:774
本文介绍了Facebook插件安装Facebook应用程序后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:使用facebook cordova插件登录。



安装 Facebook应用程序之前, / p>

安装 Facebook应用程式后,它会抛出「工作阶段已关闭,而且未正常关闭



代码:

  facebookConnectPlugin.login ,public_profile,user_friends],
function(response){
var accessToken = response.authResponse.accessToken;
var fbName =;
var fbID = ;
var fbProfilePicUrl =;
if(response.authResponse){
facebookConnectPlugin.api('/ me',null,
function(response){
/ *存储成功细节在变量* /
fbID = response.id;
fbName = response.name;
/ *获取facebook图片url * /
facebookConnectPlugin.api 'me / picture?redirect = false& type = large',null,
function(response){
var data = response.data;
fbProfilePicUrl = data.url;
/ *调用fb在这里注册方法* /
},
function(error){});
});
}
else {/ * do for authenticate fb login error * /}
});


回应 {status:未知}



  10-19 18:08:45.601 19479-19479 / package I / chromium:[INFO:CONSOLE(26)]没有找到Content-Security-Policy元标记,请添加一个当使用cordova插件白名单插件。,源:file:///android_asset/www/plugins/cordova-plugin-whitelist/whitelist.js(26)
10-19 18:08:45.651 19479 -19479 / package D / ViewRootImpl:ViewPostImeInputStage ACTION_DOWN
10-19 18:08:45.721 19479-20018 / package D / ConnectPlugin:login FB
10-19 18:08:45.726 19479-19479 / package D / ConnectPlugin:onSessionStateChange:OPENING
10-19 18:08:45.736 19479-20018 / package I /时间表:时间表:Activity_launch_request id:包时间:28785549
10-19 18:08:45.756 19479 -20018 / package W / PluginManager:THREAD警告:exec()调用FacebookConnectPlugin.login阻塞了主线程35ms。插件应该使用CordovaInterface.getThreadPool()。
10-19 18:08:45.776 19479-19479 / package D / PhoneWindow:* FMB * installDecor mIsFloating:false
10-19 18:08:45.776 19479-19479 / package D / PhoneWindow: FMB * installDecor标志:8454400
10-19 18:08:46.0​​16 19479-19479 / package D / ViewRootImpl:Buffer Count from app info with :: - 1&& -1 for :: package from View :: -1 DBQ Enabled :: false false
10-19 18:08:46.0​​31 19479-19479 / package D / PhoneWindow:* FMB * isFloatingMenuEnabled mFloatingMenuBtn:null
10-19 18:08:46.0​​31 19479-19479 / package D / PhoneWindow:* FMB * isFloatingMenuEnabled返回false
10-19 18:08:46.0​​71 19479-19856 / package D / mali_winsys:new_window_surface返回0x3000,[540x960 ] -format:1
10-19 18:08:46.0​​86 19479-19479 / package I /时间轴:时间轴:Activity_idle id:android.os.BinderProxy@aceb5fe时间:28785898
10-19 18: 08:46.106 19479-19479 / package V / ActivityThread:updateVisibility:ActivityRecord {1a4f5fca token=android.os.BinderProxy@26b1fe99 {package / package.MainActivity}} show:true
10-19 18:08:46.881 19479 -19479 / package I /时间轴:时间表:Activity_launch_request id:com.facebook.katana时间:28786693
10-19 18:08:46.921 19479-19479 / package V / ActivityThread:updateVisibility:ActivityRecord {1a4f5fca token = android .os.BinderProxy @ 26b1fe99 {package / package.MainActivity}} show:false
10-19 18:08:47.451 19479-19479 / package V / ActivityThread:updateVisibility:ActivityRecord {25c340a token = android.os.BinderProxy @ aceb5fe {package / com.facebook.LoginActivity}} show:false
10-19 18:08:49.241 19479-19479 / package V / ActivityThread:updateVisibility:ActivityRecord {1a4f5fca token=android.os.BinderProxy@26b1fe99 {package / package.MainActivity}} show:true
10-19 18:08:49.261 19479-19856 / package D / mali_winsys:new_window_surface返回0x3000,[540x960] -format:1
10-19 18:08:49.291 19479-19479 / package D / CordovaInterfaceImpl:发送活动结果到插件
10-19 18:08:49.291 19479-19479 / package D / ConnectPlugin:activity result in plugin:requestCode(64206) resultCode(-1)
10-19 18:08:49.306 19479-19479 / package D / ConnectPlugin:onSessionStateChange:CLOSED_LOGIN_FAILED
10-19 18:08:49.306 19479-19479 / package E / ConnectPlugin: com.facebook.FacebookAuthorizationException:会话已关闭,但未正常关闭



谢谢。

解决方案

通过替换插件 Wizcorp / phonegap-facebook-plugin jeduan / cordova-plugin-facebook4



jeduan / cordova -plugin-facebook4 Facebook的官方插件的一个分支Apache Cordova实现最新的Facebook SDK。除非另有说明,否则这是一个替换。您不必替换客户端代码。


Scenario: Using facebook cordova plugin for login.

Before installing facebook application it works fine.

After installing facebook application it throws "Session was closed and was not closed normally"

code:

 facebookConnectPlugin.login(["email", "public_profile","user_friends" ],
            function(response) {
                var accessToken = response.authResponse.accessToken;
                var fbName = "";
                var fbID = "";
                var fbProfilePicUrl = "";
            if (response.authResponse) {
                facebookConnectPlugin.api('/me',null,
                function(response) {
                /*store succes details in variables*/
                fbID = response.id;
                fbName = response.name;
                /*Get facebook picture url*/
                facebookConnectPlugin.api('me/picture?redirect=false&type=large',null,
                function(response) {
                    var data = response.data;
                    fbProfilePicUrl = data.url;
                    /*call fb sign up method here*/
                },
                function(error) {});
                });
            }
            else{/*do for authenticate fb login error*/}
            });

Response {"status":"unknown"}

As per documentation

FB.getLoginStatus() allows you to determine if a user is logged in to Facebook and has authenticated your app. There are three possible states for a user:

the user is logged into Facebook and has authenticated your application (connected)
the user is logged into Facebook but has not authenticated your application (not_authorized)
the user is either not logged into Facebook or explicitly logged out of your application so it doesn't attempt to connect to Facebook and thus, we don't know if they've authenticated your application or not (unknown)

10-19 18:08:45.601 19479-19479/package I/chromium: [INFO:CONSOLE(26)] "No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.", source: file:///android_asset/www/plugins/cordova-plugin-whitelist/whitelist.js (26)
10-19 18:08:45.651 19479-19479/package D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
10-19 18:08:45.721 19479-20018/package D/ConnectPlugin: login FB
10-19 18:08:45.726 19479-19479/package D/ConnectPlugin: onSessionStateChange:OPENING
10-19 18:08:45.736 19479-20018/package I/Timeline: Timeline: Activity_launch_request id:package time:28785549
10-19 18:08:45.756 19479-20018/package W/PluginManager: THREAD WARNING: exec() call to FacebookConnectPlugin.login blocked the main thread for 35ms. Plugin should use CordovaInterface.getThreadPool().
10-19 18:08:45.776 19479-19479/package D/PhoneWindow: *FMB* installDecor mIsFloating : false
10-19 18:08:45.776 19479-19479/package D/PhoneWindow: *FMB* installDecor flags : 8454400
10-19 18:08:46.016 19479-19479/package D/ViewRootImpl: Buffer Count from app info with  ::-1 && -1 for :: package from View :: -1 DBQ Enabled ::false false
10-19 18:08:46.031 19479-19479/package D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
10-19 18:08:46.031 19479-19479/package D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
10-19 18:08:46.071 19479-19856/package D/mali_winsys: new_window_surface returns 0x3000,  [540x960]-format:1
10-19 18:08:46.086 19479-19479/package I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@aceb5fe time:28785898
10-19 18:08:46.106 19479-19479/package V/ActivityThread: updateVisibility : ActivityRecord{1a4f5fca token=android.os.BinderProxy@26b1fe99 {package/package.MainActivity}} show : true
10-19 18:08:46.881 19479-19479/package I/Timeline: Timeline: Activity_launch_request id:com.facebook.katana time:28786693
10-19 18:08:46.921 19479-19479/package V/ActivityThread: updateVisibility : ActivityRecord{1a4f5fca token=android.os.BinderProxy@26b1fe99 {package/package.MainActivity}} show : false
10-19 18:08:47.451 19479-19479/package V/ActivityThread: updateVisibility : ActivityRecord{25c340a token=android.os.BinderProxy@aceb5fe {package/com.facebook.LoginActivity}} show : false
10-19 18:08:49.241 19479-19479/package V/ActivityThread: updateVisibility : ActivityRecord{1a4f5fca token=android.os.BinderProxy@26b1fe99 {package/package.MainActivity}} show : true
10-19 18:08:49.261 19479-19856/package D/mali_winsys: new_window_surface returns 0x3000,  [540x960]-format:1
10-19 18:08:49.291 19479-19479/package D/CordovaInterfaceImpl: Sending activity result to plugin
10-19 18:08:49.291 19479-19479/package D/ConnectPlugin: activity result in plugin: requestCode(64206), resultCode(-1)
10-19 18:08:49.306 19479-19479/package D/ConnectPlugin: onSessionStateChange:CLOSED_LOGIN_FAILED
10-19 18:08:49.306 19479-19479/package E/ConnectPlugin: com.facebook.FacebookAuthorizationException: Session was closed and was not closed normally

I checked with debug and signed apk it shows same issue.

suggest some checklist.

thank you.

解决方案

Got worked by replacing plugin Wizcorp/phonegap-facebook-plugin to jeduan/cordova-plugin-facebook4

jeduan/cordova-plugin-facebook4 is a fork of the official plugin for Facebook in Apache Cordova that implements the latest Facebook SDK. Unless noted, this is a drop-in replacement. You don't have to replace your client code.

这篇关于Facebook插件安装Facebook应用程序后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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