[TIMOB-12828] iOS: Facebook v3 Module: Login process differs from Ti.Facebook and logout fails
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-03-22T23:54:21.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.1.0, 2013 Sprint 06 API, 2013 Sprint 06 |
Components | iOS |
Labels | kicthensink, parity, qe-devCheck |
Reporter | Benjamin Hatfield |
Assignee | Blain Hamon |
Created | 2013-02-22T21:53:59.000+0000 |
Updated | 2014-10-03T23:17:59.000+0000 |
Description
REPRODUCTION:
First, run the code below using 3.0.2 GA to see the previous behavior in the iOS simulator. Click login. Notice the dialog box appears. Enter your credentials. Then, click the logout button.
Next,
Add the facebook module and add this item in the tiapp.xml:
Comment out line 1 and uncomment line 2, so you are using the add-on module.
Change the SDK version to 3.1.0
Add the facebook module and add this item in the tiapp.xml: 495338853813822
Run the code again on the iOS simulator. See results below for findings.
RESULTS: 1. When clicking the login button, the application opens Safari to enter your credentials instead of the dialog as in the previous version. 2. When clicking the logout button, the application throws this error: {noformat} [INFO] : 2013-02-22 13:47:19.369 FacebookTest[87247:22503] *** Assertion failure in -[FBSession close], /Volumes/Datums/CodeValhalla/Github/Mine/titanium_modules/facebook/mobile/ios/Classes/FBConnect/FBSession.m:404 [ERROR] : Script Error { [TRACE] : = "#0 () at :0"; [TRACE] : line = 25; [TRACE] : message = "FBSession: should only be used from a single thread"; [TRACE] : sourceId = 275184000; [TRACE] : sourceURL = "file://localhost/Users/bhatfield/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/DF408B6A-B022-4CB8-B834-A527FD542DD0/FacebookTest.app/app.js"; [TRACE] : } {noformat} NOTES: With the Facebook.LoginButton, when logging in, the application still opens a Safari window to enter your credentials, but you can logout OK. No error is thrown. On Android, the default login process behaves the same (dialog appears in both cases) and the application can logout OK. FURTHER QUESTION: I don't know if this is a parity issue or not, but when logging out in iOS, you can login again without supplying your credentials. On Android, if you logout, you have to supply your credentials again when you login. TEST CODE:
var fb = Ti.Facebook;
//var fb = require('facebook');
fb.appid = 495338853813822;
fb.permissions = ['publish_stream','create_event'];
fb.addEventListener('login', function(e) {
if (e.success) {
alert('Logged In');
} else if (e.error) {
alert(e.error);
} else if (e.cancelled) {
alert("Canceled");
}
});
fb.addEventListener('logout', function(e) {
alert('Logged Out');
});
var login = Ti.UI.createButton({title: 'Login'});
login.addEventListener('click', function(e){
fb.authorize();
});
var logout = Ti.UI.createButton({title: 'Log Out'});
logout.addEventListener('click', function(e){
fb.logout();
});
var win = Ti.UI.createWindow({layout: 'vertical', backgroundColor: 'white'});
win.add(login);
win.add(logout);
win.open();
Found some new information. Investigating.
Tried changing the initial permissions and forceDialogAuth settings. logout method still fails.
To fix the logout bug, change some code in FacebookModule.m: The logout function looks like this:
While it should look like this: (run only on main thread)
Happens on iOS 6.1 / 6.1.2 with SDK 3.0.0GA, modified to use the new 3.1 Facebook SDK instead of the internal Facebook module of 3.0.0.GA. Also, the issue's severity should be changed, since this bug WILL be a major one in the 3.1 release.
Good catch in needing to wrap logout on the main thread. The only bit remains is: the behavior change was not caused by a codechange in Titanium, but appears to be a change within Facebook's own SDK code. Perhaps this is intentional on their part; after all, for iOS 6's single sign-on, you're never prompted to enter the user name and password. Will be making pull request to fix logout. What else remains?
https://github.com/appcelerator/titanium_modules/pull/91
Oh ick. Just realized I have a flaw in the login reporting code. Updating pull.
Closing as fixed. Tested Mac osx 10.9.5 Mavericks Appcelerator Studio, build: 3.4.0.201409261245 Titanium SDK, build: 3.4.1.v20141003114920 acs@1.0.18 alloy 1.5.1 install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0 titanium-code-processor@1.1.1 Xcode6.1GM Device: iPhone 6 iOS 8.1 ks