android - Phonegap facebook plugin: Not working when native FB app is installed -
i have used cordova- 2.5.0 & facebook-sdk 3.0.2 in fb plugin.it works fine when device not have native app installed. when native app installed nothing happened.means cant current access token of user.any idea? according me there 2 ways:
1) disable access native app in ios. not right way if user allready login in native has login again in plugin setup.
2)dont know how solve issue.there no issue hash key right , works in ios using first way.
so question how prevent accessing native app? or there other way solve issue?
as dont anything. when going user's friend list shows active access token must used query information current user.,"type":"oauthexception","code":2500.
cdv-pluggin-fb-connect.js
cdv = ( typeof cdv == 'undefined' ? {} : cdv ); var cordova = window.cordova || window.cordova; cdv.fb = { init: function(apikey, fail) { // create fb-root element if doesn't exist if (!document.getelementbyid('fb-root')) { var elem = document.createelement('div'); elem.id = 'fb-root'; document.body.appendchild(elem); } cordova.exec(function() { var authresponse = json.parse(localstorage.getitem('cdv_fb_session') || '{"expiresin":0}'); if (authresponse && authresponse.expirationtime) { var nowtime = (new date()).gettime(); if (authresponse.expirationtime > nowtime) { // update expires in information updatedexpiresin = math.floor((authresponse.expirationtime - nowtime) / 1000); authresponse.expiresin = updatedexpiresin; localstorage.setitem('cdv_fb_session', json.stringify(authresponse)); fb.auth.setauthresponse(authresponse, 'connected'); } } console.log('cordova facebook connect plugin initialized successfully.'); }, (fail?fail:null), 'org.apache.cordova.facebook.connect', 'init', [apikey]); }, login: function(params, cb, fail) { params = params || { scope: '' }; cordova.exec(function(e) { // login if (e.authresponse && e.authresponse.expiresin) { var expirationtime = e.authresponse.expiresin === 0 ? 0 : (new date()).gettime() + e.authresponse.expiresin * 1000; e.authresponse.expirationtime = expirationtime; } localstorage.setitem('cdv_fb_session', json.stringify(e.authresponse)); fb.auth.setauthresponse(e.authresponse, 'connected'); if (cb) cb(e); }, (fail?fail:null), 'org.apache.cordova.facebook.connect', 'login', params.scope.split(',') ); }, logout: function(cb, fail) { cordova.exec(function(e) { localstorage.removeitem('cdv_fb_session'); fb.auth.setauthresponse(null, 'notconnected'); if (cb) cb(e); }, (fail?fail:null), 'org.apache.cordova.facebook.connect', 'logout', []); }, getloginstatus: function(cb, fail) { cordova.exec(function(e) { if (cb) cb(e); }, (fail?fail:null), 'org.apache.cordova.facebook.connect', 'getloginstatus', []); }, dialog: function(params, cb, fail) { cordova.exec(function(e) { // login if (cb) cb(e); }, (fail?fail:null), 'org.apache.cordova.facebook.connect', 'showdialog', [params] ); } }; thanks in advance!!
i able working plugin: https://github.com/jimzim/phonegap-facebook-android-sample
Comments
Post a Comment