Test case:
login into Facebook using your Titanium's app
kill it from Dock
try to open app with Facebook user-to-user request URL from your notifications section in Facebook or newsfeed story. It should be something like fb116843021780929://authorize?...
"FBSession: should only be used from a single thread" red screen appears
XCode console on a device says:
Sep 10 12:40:08 iPhone Printpie[31305] <Warning>: *** Assertion failure in -[FBSession handleOpenURL:], /Volumes/Datums/CodeValhalla/Github/Mine/titanium_modules/facebook/mobile/ios/Classes/FBConnect/FBSession.m:426
Sep 10 12:40:08 iPhone Printpie[31305] <Warning>: [ERROR] Script Error FBSession: should only be used from a single thread
Test application code is simple as a child's tear:
var fb = require('facebook');
fb.appid = '116843021780929';
var win = Ti.UI.createWindow();
var loginButton = Ti.UI.createButton({
title: 'Login'
});
loginButton.addEventListener('click', function(){fb.authorize();});
win.add(loginButton);
win.open();
Don't forget to add into your Info.plist next string for Facebook URL chema support:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.printpie.cleverbug</string>
<key>CFBundleURLSchemes</key>
<array>
<string>printpie</string>
<string>fb116843021780929</string>
</array>
</dict>
</array>
So:
run the app
click "Login" button
login into your Fb account
you will be bring back to the app
close simulator
open simulator stand-alone, without titanium
try next URL (it's similar as from Facebook native app or Safari's web-version of FB):
fb116843021780929://authorize?expires_in=3600&access_token=qkjKR42UQsewYckYagPhU2Avo4eLruAKH41Vd1u192UORNvhzGftEUi7sOK375opZCKzpK1ZCAyxkBH5je3BUG3E8Shp6mI8VmdXWU2dxrOe4oB7BoDPSAZDZD&target_url=http%3A%2F%2Fm.facebook.com%2Fapps%2Fcleverbug-printpie%3Ffb_source%3Dnotification%26request_ids%3D511072445602499%26ref%3Dnotif%26app_request_type%3Duser_to_user
you will see "FBSession: should only be used from a single thread"
I saw many similar questions on Q&A section with no answers :(
P.S. sorry, no time to make a bundle with test application, but I hope I explained it above.
Probably I know why it happens: old Ti.Facebook module still in SDK, and not requires initialization (with "require(..") right? Maybe that is a first thread which is capturing and handle openURL param.
This should not happen with Ti.Facebook 5.0.0 and later (e.g. 5.2.3 currently). Resolving for now, please leave your comments if you still see it.
Closing ticket as fixed with reference to the above comments.