Comments (3)
I devised a temporary fix for this. I'll explain it here, in case anyone else has that problem.
I didn't find anything in the Facebook settings I could tweak, so I tweaked the code to replace string-formatted dates by their expected integer value.
Sorry about the JavaScript, the original is written in CoffeeScript :-)
window.normalize_session_date = function(session) {
if (typeof session.expires === 'string') {
var M, d, h, i, m, s, y, _ref;
_ref = (function() {
var _i, _len, _ref, _results;
_ref = session.expires.split(/-|:|\s/);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
i = _ref[_i];
_results.push(parseInt(i));
}
return _results;
})();
y = _ref[0], M = _ref[1], d = _ref[2], h = _ref[3], m = _ref[4], s = _ref[5];
var integer_date = new Date(y, M, d, h, m, s).valueOf();
console.log("Normalizing session.expires from '" + session.expires + "' to " + integer_date);
session.expires = integer_date;
}
};
Then in the main PG.FB code, I add the call to the normalization function:
init: function(apiKey) {
// create the fb-root element if it doesn't exist
...
PhoneGap.exec(function() {
var session = JSON.parse(localStorage.getItem('pg_fb_session') || '{"expires":0}');
normalize_session_date(session);
if (session.expires > new Date().valueOf()) {
FB.Auth.setSession(session, 'connected');
console.log("session successfully recovered");
}
}, null, 'com.phonegap.facebook.Connect', 'init', [apiKey]);
},
login: function(a, b) {
b = b || { perms: '' };
PhoneGap.exec(function(e) { // login
normalize_session_date(e.session);
localStorage.setItem('pg_fb_session', JSON.stringify(e.session));
FB.Auth.setSession(e.session, 'connected');
if (a) a(e);
}, null, 'com.phonegap.facebook.Connect', 'login', b.perms.split(',') );
},
...
It's a pretty nasty fix, but it works for me. I'm hoping this will help someone else until the underlying issue is fixed.
For anyone interested in the CoffeeScript version instead, here it is:
window.normalize_session_date = (session)->
if typeof session.expires == 'string'
[y, M, d, h, m, s] = ( parseInt(i) for i in session.expires.split(/-|:|\s/) )
integer_date = new Date(y, M, d, h, m, s).valueOf()
console.log("Normalizing session.expires from '" + session.expires + "' to " + integer_date)
session.expires = integer_date
from phonegap-facebook-plugin.
I just filed a pull request that fixes the bug, feel free to try it :)
https://github.com/davejohnson/phonegap-plugin-facebook-connect/pull/93/files
from phonegap-facebook-plugin.
Pull request #93 works for me. Thanks @kizzx2 !
from phonegap-facebook-plugin.
Related Issues (20)
- Compile Error
- ErrorCode for ios
- Cordova iOS - Facebook Native App callback return issue?
- Turn Texas HoldEm Poker
- Facebook share link not working
- app crash on facebook re-login
- THIS REPOSITORY HAS BEEN ABANDONED. Use the jeduan fork instead!
- miss IOS instruction on documentation HOT 1
- Not Able to Validate Server Side Login Using AccessToken and Fetch Profile Information
- unable to list saved accounts on device
- You can't use Facebook to log into this app or website because there's an issue with its implementation of Facebook Login HOT 1
- Plugin doesn't work on my site
- TypeScript definition support
- UIWebView needs to be removed HOT 1
- Plugin for mobile version of site
- How i can get Deep Link?
- h
- Busco
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phonegap-facebook-plugin.