Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23890] iOS10: Facebook Login is not working

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-09-13T00:14:55.000+0000
Affected Version/sRelease 5.4.0, Release 5.5.0
Fix Version/sRelease 5.5.0
ComponentsiOS
Labelsfacebook, facebookSDK, ios, ios10, ti.facebook, xcode8
ReporterYgor Lemos
AssigneeHans Knöchel
Created2016-09-09T23:42:06.000+0000
Updated2016-11-17T08:16:44.000+0000

Description

Facebook login using the latest FB Modules is not working anymore on devices running iOS 10. We have catch this behavior on our production published app running the Facebook Module (5.2.0) and Ti SDK 5.3.0. We have tested this behavior on Ti SDK 5.2.0.GA up to 5.5.0 RC and all present the same behavior. *Steps to Reproduce* * Use a button for Facebook login (using the fb.authorize method). * The button opens the SafariView with the Facebook App Authorization site. * Tap OK button. * The SafariView gets a blank page and doesn't get dismissed. * If you tap the DONE button, the view is dismissed but the is not logged in. *Expected* Normal FB login flow where you tap the OK button on the SafariViewController opened by the Facebook module, the SafariViewController gets dismissed, the login event is fired with the user logged in. *Follows a very simple app using the Facebook Module displaying this issue.*
var fb = require("facebook");

// Facebook Stuff
fb.initialize();


var win = Ti.UI.createWindow();

var fbloginbutton = Ti.UI.createButton({
    title: "Login with Facebook"
});

fbloginbutton.addEventListener("click", function() {
    fb.authorize();
});

win.add(fbloginbutton);

var lbl = Ti.UI.createLabel({
    color: "red",
    text: fb.loggedIn
});





win.add(lbl);

fb.addEventListener("login", function() {
    console.log("fb-event-login: " + fb.loggedIn);
    console.log("accessToken: " + fb.accessToken);
    console.log("fbuid: " + fb.uid);
    
    lbl.setText(fb.loggedIn);
});

fb.addEventListener("logout", function() {
    console.log("fb-event-logout: " + fb.loggedIn);
    console.log("accessToken: " + fb.accessToken);
    
    lbl.setText(fb.loggedIn);
    
});


console.log("fb-boot-status: " + fb.loggedIn);
console.log("fb-boot-accessToken: " + fb.accessToken);


win.open();

Please remember to setup the proper Facebook App ID parameters on tiapp.xml on the iOS section together with LSApplicationQueriesSchemes and NSAppTransportSecurity as per Facebook Ti module instructions. This is critical since iOS 10 final is to be released next week and this completely breaks Facebook login.

Comments

  1. Ygor Lemos 2016-09-09

    More Info: * Using the Module Login Button (using createLoginButton) presents the same behavior. * If you tap to open the Link In Safari, it opens in safari and when you tap OK it goes back to the app and crashes ([ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'. [ERROR] Reason: [ERROR] *** setObjectForKey: object cannot be nil (key: error)) * We have tried to use the latest version of the ti.facebook module on github (iOS-5.2.4 release) and it does not solve this problem. * Facebook has released the 4.15.1 version of their SDK which makes some updates related to XCode 8 and iOS 10 (Ti.Facebook module seems to use 4.14.0 on the latest Github Version)
  2. Ygor Lemos 2016-09-09

    Other apps that use the same native login flow on iOS (opens SFSafariViewController with Facebook login inside the app itself) are working fine after updating to iOS 10. Our app which the current iOS Published version is compiled with Facebook Module (5.2.0) and Ti SDK 5.3.0 is not. On all our tests running against iOS 9 both on devices as in the simulator, the login behaves normally.
  3. Ygor Lemos 2016-09-10

    other devs are experiencing this problem as well: http://stackoverflow.com/questions/39297781/facebook-login-doesnt-works-on-ios-10-titanium-sdk-5-3-1-ga-and-5-5-0-beta/39422401#39422401
  4. Ygor Lemos 2016-09-10

    I have tried to compile the current ti.facebook module source replacing the Facebook SDK frameworks with the ones available on their latest SDK (4.15.1). The module works fine but shows the same behavior presenting a blank screen after tapping OK and not returning to the app. Closing the safari view controller manually returns to the app and fires the login event as "cancelled" and it doesn't login at all.
  5. Hans Knöchel 2016-09-11

    Hey [~ygbr], I'm here! Before I dig into the issue, I would like to clear the following quote: {quote} We have catch this behavior on our production published app running the Facebook Module (5.2.0) and Ti SDK 5.3.0. {quote} How can you catch the error-behavior in a production app when a) iOS 10 need to be built with Xcode 8 which is not able to have apps in the store, yet and b) you are using Ti SDK 5.3.0 for that which does not support iOS 10 builds, yet. Thanks!
  6. Hans Knöchel 2016-09-11

    Let's go: - This seems to happen on the native side as well (https://forums.developer.apple.com/thread/50332 + http://stackoverflow.com/questions/38689631/how-to-use-facebook-ios-sdk-on-ios-10) - Make sure you have included all iOS required query schemes (if that works, let me know and I'll update the docs anyway):
       <key>LSApplicationQueriesSchemes</key>  
       <array>  
               <string>fbapi</string>  
               <string>fbapi20130214</string>  
               <string>fbapi20130410</string>  
               <string>fbapi20130702</string>  
               <string>fbapi20131010</string>  
               <string>fbapi20131219</string>  
               <string>fbapi20140410</string>  
               <string>fbapi20140116</string>  
               <string>fbapi20150313</string>  
               <string>fbapi20150629</string>  
               <string>fbapi20160328</string>  
               <string>fbauth</string>  
               <string>fbauth2</string>  
               <string>fb-messenger-api20140430</string>  
               <string>fb-messenger-platform-20150128</string>  
               <string>fb-messenger-platform-20150218</string>  
               <string>fb-messenger-platform-20150305</string>  
               <string>fbapi</string>  
               <string>fb-messenger-api</string>  
               <string>fbauth2</string>  
               <string>fbshareextension</string>  
       </array> 
       
    - Enable keychain-sharing in your entitlements with your app-id from the tiapp.xml (if that works, we need to update the docs as well):
       <key>keychain-access-groups</key>
       <array>
       	<string>com.yourcompany.identifier</string>
       </array>
       
    So summary: I don't think it's the Facebook module itself, but the way we need to implement it for iOS 10. I will see if Facebook has a specific SDK release for iOS 10 so we can include that as well. Thanks!
  7. Hans Knöchel 2016-09-11

    PR (ti.facebook): https://github.com/appcelerator-modules/ti.facebook/pull/63 [~ygbr] Please try the ti.facebook version 5.2.5 that is attached to the PR, as well as the above hints. Pretty sure that will work. Thanks!
  8. Ygor Lemos 2016-09-11

    @Hans clearing out your questions: bq. How can you catch the error-behavior in a production app when a) iOS 10 need to be built with Xcode 8 which is not able to have apps in the store, yet and b) you are using Ti SDK 5.3.0 for that which does not support iOS 10 builds, yet. Thanks! We have installed the current version of our production app available in the iOS App Store ( compiled with Facebook Module (5.2.0), Xcode 7 and Ti SDK 5.3.0) and the facebook login simply stopped working after updating to iOS 10 GM. (Tested on iPhone 5S, 6, and 6S Plus). It worked flawlessly on iOS 9. Just to be clear, just updating to iOS 10 completely breaks Facebook Login on previously published Ti apps, which doesn't happens with other (non-ti) apps that were also compiled with previous versions of Xcode and FB SDKs. We have tested a plethora of other iOS apps that uses Facebook login and they are working just fine after updating to to iOS 10. All titanium apps that we control are having this login failure on iOS 10. I will try the keychain and adding the extra LSApplicationQueriesSchemes (even though Facebook SDK explicitly says to remove the extra ones in the latest SDK version) and report back here soon. Thanks.
  9. Hans Knöchel 2016-09-11

    Thanks for the feedback! The entitlements are not necessary anymore, since the newer version of the Facebook SDK sets them for you. I am still able to reproduce it and need some more testing right now. Will keep you updated.
  10. Ygor Lemos 2016-09-11

    @Hans Thanks for the feedback. As a side note I have tried all the steps you mentioned and the FB Module attached to your PR (5.2.5) but still get the same effects (yesterday I have tried to update the FB SDK frameworks on the module myself too, but I got the same results). I also have tried to test it with run-on-main-thread on and off and the with the new jscore framework enabled but the problem persists in all cases.
  11. Hans Knöchel 2016-09-11

    Ok, found the problem. In the Titanium SDK core, we have the following application delegate to handle url-opens:
        - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
        
    When using the Facebook-SDK, the following thing is recommended:
        - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
        {
            return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
        }
        
    and for some reason, it never made problems before, but now it does. So we need to find a way to hook into that delegate from the module.
  12. Hans Knöchel 2016-09-11

    Ok, I have something working (although I'm not sure it's the best way to do it, yet): We need an SDK-core PR to send out a notification when the above delegate is called by the system. In the module, we hook into that notification like we do with other (system- and SDK-side notifications). Inside there, we call the Facebook-delegate and the callback in authorize that has not been triggered gets triggered. Works with both active and inactive sessions. Anyway, it requires a lot of testing to ensure everything in the session- and accesstoken-handling still works. PR's: - ti.facebook: https://github.com/appcelerator-modules/ti.facebook/pull/63 - titanium_mobile (master): https://github.com/appcelerator/titanium_mobile/pull/8346 - titanium_mobile (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8352 - titanium_mobile (5_5_X): https://github.com/appcelerator/titanium_mobile/pull/8351 I will do the 6_0_X and 5_5_X backports as soon as [~ygbr] and [~cng] can confirm the fix. I updated the prepackaged version in the ti.facebook PR as well. Fingers crossed!
  13. Ygor Lemos 2016-09-11

    Hi Hans, I have tested using your updated module PR and your pull on Ti master (6.1.0) and now when I tap on the OK button inside the FB Login SafariViewController I get the following crash:
        [ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
        [ERROR] Reason:
        [ERROR] *** setObjectForKey: object cannot be nil (key: error)
        [ERROR] Stack trace:
        [ERROR]
        [ERROR] 0   CoreFoundation                      0x000000010b716333 __exceptionPreprocess + 147
        [ERROR] 1   libobjc.A.dylib                     0x000000010ace521e objc_exception_throw + 48
        [ERROR] 2   CoreFoundation                      0x000000010b62c9b7 -[__NSDictionaryM setObject:forKey:] + 1047
        [ERROR] 3   fblogintest                         0x0000000104656020 -[FacebookModule fireLogin:cancelled:withError:] + 336
        [ERROR] 4   fblogintest                         0x00000001045b9b31 -[FBSDKLoginManager invokeHandler:error:] + 148
        [ERROR] 5   fblogintest                         0x00000001045b98a7 -[FBSDKLoginManager completeAuthentication:expectChallenge:] + 1499
        [ERROR] 6   fblogintest                         0x00000001045b65c0 -[FBSDKLoginURLCompleter completeLogIn:withHandler:] + 374
        [ERROR] 7   fblogintest                         0x00000001045bb6e2 -[FBSDKLoginManager(Native) application:openURL:sourceApplication:annotation:] + 644
        [ERROR] 8   fblogintest                         0x00000001045883ba -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] + 305
        [ERROR] 9   CoreFoundation                      0x000000010b6b419c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
        [ERROR] 10  CoreFoundation                      0x000000010b6b409b _CFXRegistrationPost + 427
        [ERROR] 11  CoreFoundation                      0x000000010b6b3e02 ___CFXNotificationPost_block_invoke + 50
        [ERROR] 12  CoreFoundation                      0x000000010b676ea2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
        [ERROR] 13  CoreFoundation                      0x000000010b675f3b _CFXNotificationPost + 667
        [ERROR] 14  Foundation                          0x000000010636613b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
        [ERROR] 15  fblogintest                         0x00000001044b4e08 -[TiApp application:openURL:sourceApplication:annotation:] + 408
        [ERROR] 16  UIKit                               0x00000001068cbae3 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 940
        [ERROR] 17  UIKit                               0x00000001068cb472 -[UIApplication _applicationOpenURL:payload:] + 757
        [ERROR] 18  SafariServices                      0x00000001170bc060 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:] + 155
        [ERROR] 19  SafariServices                      0x00000001170b3db7 -[SFBrowserRemoteViewController willOpenURLInHostApplication:] + 68
        [ERROR] 20  CoreFoundation                      0x000000010b69d05c __invoking___ + 140
        [ERROR] 21  CoreFoundation                      0x000000010b69cee1 -[NSInvocation invoke] + 289
        [ERROR] 22  FrontBoardServices                  0x000000011260576b __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
        [ERROR] 23  FrontBoardServices                  0x00000001126055e4 -[FBSSerialQueue _performNext] + 189
        [ERROR] 24  FrontBoardServices                  0x000000011260596d -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        [ERROR] 25  CoreFoundation                      0x000000010b6bb311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        [ERROR] 26  CoreFoundation                      0x000000010b6a059c __CFRunLoopDoSources0 + 556
        [ERROR] 27  CoreFoundation                      0x000000010b69fa86 __CFRunLoopRun + 918
        [ERROR] 28  CoreFoundation                      0x000000010b69f494 CFRunLoopRunSpecific + 420
        [ERROR] 29  GraphicsServices                    0x000000010cdbda6f GSEventRunModal + 161
        [ERROR] 30  UIKit                               0x00000001068c0f34 UIApplicationMain + 159
        [ERROR] 31  fblogintest                         0x00000001042dfff6 main + 310
        [ERROR] 32  libdyld.dylib                       0x000000010f94768d start + 1
        [ERROR] 33  ???                                 0x0000000000000001 0x0 + 1
        [ERROR]
        [ERROR] 2016-09-11 18:27:20.175 fblogintest[3129:344150] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: error)'
        [ERROR] *** First throw call stack:
        [ERROR] (
        [ERROR]         0   CoreFoundation                      0x000000010b71634b __exceptionPreprocess + 171
        [ERROR]         1   libobjc.A.dylib                     0x000000010ace521e objc_exception_throw + 48
        [ERROR]         2   CoreFoundation                      0x000000010b62c9b7 -[__NSDictionaryM setObject:forKey:] + 1047
        [ERROR]         3   fblogintest                         0x0000000104656020 -[FacebookModule fireLogin:cancelled:withError:] + 336
        [ERROR]         4   fblogintest                         0x00000001045b9b31 -[FBSDKLoginManager invokeHandler:error:] + 148
        [ERROR]         5   fblogintest                         0x00000001045b98a7 -[FBSDKLoginManager completeAuthentication:expectChallenge:] + 1499
        [ERROR]         6   fblogintest                         0x00000001045b65c0 -[FBSDKLoginURLCompleter completeLogIn:withHandler:] + 374
        [ERROR]         7   fblogintest                         0x00000001045bb6e2 -[FBSDKLoginManager(Native) application:openURL:sourceApplication:annotation:] + 644
        [ERROR]         8   fblogintest                         0x00000001045883ba -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] + 305
        [ERROR]         9   CoreFoundation                      0x000000010b6b419c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
        [ERROR]         10  CoreFoundation                      0x000000010b6b409b _CFXRegistrationPost + 427
        [ERROR]         11  CoreFoundation                      0x000000010b6b3e02 ___CFXNotificationPost_block_invoke + 50
        [ERROR]         12  CoreFoundation                      0x000000010b676ea2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
        [ERROR]         13  CoreFoundation                      0x000000010b675f3b _CFXNotificationPost + 667
        [ERROR]         14  Foundation                          0x000000010636613b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
        [ERROR]         15  fblogintest                         0x00000001044b4e08 -[TiApp application:openURL:sourceApplication:annotation:] + 408
        [ERROR]         16  UIKit                               0x00000001068cbae3 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 940
        [ERROR]         17  UIKit                               0x00000001068cb472 -[UIApplication _applicationOpenURL:payload:] + 757
        [ERROR]         18  SafariServices                      0x00000001170bc060 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:] + 155
        [ERROR]         19  SafariServices                      0x00000001170b3db7 -[SFBrowserRemoteViewController willOpenURLInHostApplication:] + 68
        [ERROR]         20  CoreFoundation                      0x000000010b69d05c __invoking___ + 140
        [ERROR]         21  CoreFoundation                      0x000000010b69cee1 -[NSInvocation invoke] + 289
        [ERROR]         22  FrontBoardServices                  0x000000011260576b __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
        [ERROR]         23  FrontBoardServices                  0x00000001126055e4 -[FBSSerialQueue _performNext] + 189
        [ERROR]         24  FrontBoardServices                  0x000000011260596d -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        [ERROR]         25  CoreFoundation                      0x000000010b6bb311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        [ERROR]         26  CoreFoundation                      0x000000010b6a059c __CFRunLoopDoSources0 + 556
        [ERROR]         27  CoreFoundation                      0x000000010b69fa86 __CFRunLoopRun + 918
        [ERROR]         28  CoreFoundation                      0x000000010b69f494 CFRunLoopRunSpecific + 420
        [ERROR]         29  GraphicsServices                    0x000000010cdbda6f GSEventRunModal + 161
        [ERROR]         30  UIKit                               0x00000001068c0f34 UIApplicationMain + 159
        [ERROR]         31  fblogintest                         0x00000001042dfff6 main + 310
        [ERROR]         32  libdyld.dylib                       0x000000010f94768d start + 1
        [ERROR]         33  ???                                 0x0000000000000001 0x0 + 1
        [ERROR] )
        [ERROR] libc++abi.dylib: terminating with uncaught exception of type NSException
        -- End simulator log ---------------------------------------------------------
        
  14. Hans Knöchel 2016-09-11

    Mhh, it looks like in [this line](https://github.com/hansemannn/ti.facebook/blob/85ec3e4307bf8375f0450d104ed0e8c6a804d7cd/ios/Classes/FacebookModule.m#L870) the errorString is nil. Very weird. I just pushed another commit to optimize the delegate handling, please build the module yourself this time to speed-up the debugging, thanks!.
  15. Ygor Lemos 2016-09-12

    Hi Hans, I have downloaded the latest version from your PR and build it myself. Still getting the following error after I tap OK on the SafariViewController
        [TRACE] [fblogintest] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: error)'
        [ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
        [ERROR] Reason:
        [ERROR] *** setObjectForKey: object cannot be nil (key: error)
        [ERROR] Stack trace:
        [ERROR]
        [ERROR] 0   CoreFoundation                      0x0000000109cf0333 __exceptionPreprocess + 147
        [ERROR] 1   libobjc.A.dylib                     0x00000001092bf21e objc_exception_throw + 48
        [ERROR] 2   CoreFoundation                      0x0000000109c069b7 -[__NSDictionaryM setObject:forKey:] + 1047
        [ERROR] 3   fblogintest                         0x0000000102c38040 -[FacebookModule fireLogin:cancelled:withError:] + 336
        [ERROR] 4   fblogintest                         0x0000000102b9bca1 -[FBSDKLoginManager invokeHandler:error:] + 148
        [ERROR] 5   fblogintest                         0x0000000102b9ba17 -[FBSDKLoginManager completeAuthentication:expectChallenge:] + 1499
        [ERROR] 6   fblogintest                         0x0000000102b98730 -[FBSDKLoginURLCompleter completeLogIn:withHandler:] + 374
        [ERROR] 7   fblogintest                         0x0000000102b9d852 -[FBSDKLoginManager(Native) application:openURL:sourceApplication:annotation:] + 644
        [ERROR] 8   fblogintest                         0x0000000102b6a52a -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] + 305
        [ERROR] 9   CoreFoundation                      0x0000000109c8e19c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
        [ERROR] 10  CoreFoundation                      0x0000000109c8e09b _CFXRegistrationPost + 427
        [ERROR] 11  CoreFoundation                      0x0000000109c8de02 ___CFXNotificationPost_block_invoke + 50
        [ERROR] 12  CoreFoundation                      0x0000000109c50ea2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
        [ERROR] 13  CoreFoundation                      0x0000000109c4ff3b _CFXNotificationPost + 667
        [ERROR] 14  Foundation                          0x000000010494013b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
        [ERROR] 15  fblogintest                         0x0000000102a96f78 -[TiApp application:openURL:sourceApplication:annotation:] + 408
        [ERROR] 16  UIKit                               0x0000000104ea5ae3 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 940
        [ERROR] 17  UIKit                               0x0000000104ea5472 -[UIApplication _applicationOpenURL:payload:] + 757
        [ERROR] 18  SafariServices                      0x0000000115696060 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:] + 155
        [ERROR] 19  SafariServices                      0x000000011568ddb7 -[SFBrowserRemoteViewController willOpenURLInHostApplication:] + 68
        [ERROR] 20  CoreFoundation                      0x0000000109c7705c __invoking___ + 140
        [ERROR] 21  CoreFoundation                      0x0000000109c76ee1 -[NSInvocation invoke] + 289
        [ERROR] 22  FrontBoardServices                  0x0000000110bdf76b __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
        [ERROR] 23  FrontBoardServices                  0x0000000110bdf5e4 -[FBSSerialQueue _performNext] + 189
        [ERROR] 24  FrontBoardServices                  0x0000000110bdf96d -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        [ERROR] 25  CoreFoundation                      0x0000000109c95311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        [ERROR] 26  CoreFoundation                      0x0000000109c7a59c __CFRunLoopDoSources0 + 556
        [ERROR] 27  CoreFoundation                      0x0000000109c79a86 __CFRunLoopRun + 918
        [ERROR] 28  CoreFoundation                      0x0000000109c79494 CFRunLoopRunSpecific + 420
        [ERROR] 29  GraphicsServices                    0x000000010b397a6f GSEventRunModal + 161
        [ERROR] 30  UIKit                               0x0000000104e9af34 UIApplicationMain + 159
        [ERROR] 31  fblogintest                         0x00000001028c2326 main + 310
        [ERROR] 32  libdyld.dylib                       0x000000010df2168d start + 1
        [ERROR] 33  ???                                 0x0000000000000001 0x0 + 1
        [ERROR]
        [ERROR] 2016-09-11 22:59:51.484 fblogintest[11606:999429] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: error)'
        [ERROR] *** First throw call stack:
        [ERROR] (
        [ERROR]         0   CoreFoundation                      0x0000000109cf034b __exceptionPreprocess + 171
        [ERROR]         1   libobjc.A.dylib                     0x00000001092bf21e objc_exception_throw + 48
        [ERROR]         2   CoreFoundation                      0x0000000109c069b7 -[__NSDictionaryM setObject:forKey:] + 1047
        [ERROR]         3   fblogintest                         0x0000000102c38040 -[FacebookModule fireLogin:cancelled:withError:] + 336
        [ERROR]         4   fblogintest                         0x0000000102b9bca1 -[FBSDKLoginManager invokeHandler:error:] + 148
        [ERROR]         5   fblogintest                         0x0000000102b9ba17 -[FBSDKLoginManager completeAuthentication:expectChallenge:] + 1499
        [ERROR]         6   fblogintest                         0x0000000102b98730 -[FBSDKLoginURLCompleter completeLogIn:withHandler:] + 374
        [ERROR]         7   fblogintest                         0x0000000102b9d852 -[FBSDKLoginManager(Native) application:openURL:sourceApplication:annotation:] + 644
        [ERROR]         8   fblogintest                         0x0000000102b6a52a -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] + 305
        [ERROR]         9   CoreFoundation                      0x0000000109c8e19c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
        [ERROR]         10  CoreFoundation                      0x0000000109c8e09b _CFXRegistrationPost + 427
        [ERROR]         11  CoreFoundation                      0x0000000109c8de02 ___CFXNotificationPost_block_invoke + 50
        [ERROR]         12  CoreFoundation                      0x0000000109c50ea2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
        [ERROR]         13  CoreFoundation                      0x0000000109c4ff3b _CFXNotificationPost + 667
        [ERROR]         14  Foundation                          0x000000010494013b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
        [ERROR]         15  fblogintest                         0x0000000102a96f78 -[TiApp application:openURL:sourceApplication:annotation:] + 408
        [ERROR]         16  UIKit                               0x0000000104ea5ae3 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 940
        [ERROR]         17  UIKit                               0x0000000104ea5472 -[UIApplication _applicationOpenURL:payload:] + 757
        [ERROR]         18  SafariServices                      0x0000000115696060 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:] + 155
        [ERROR]         19  SafariServices                      0x000000011568ddb7 -[SFBrowserRemoteViewController willOpenURLInHostApplication:] + 68
        [ERROR]         20  CoreFoundation                      0x0000000109c7705c __invoking___ + 140
        [ERROR]         21  CoreFoundation                      0x0000000109c76ee1 -[NSInvocation invoke] + 289
        [ERROR]         22  FrontBoardServices                  0x0000000110bdf76b __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
        [ERROR]         23  FrontBoardServices                  0x0000000110bdf5e4 -[FBSSerialQueue _performNext] + 189
        [ERROR]         24  FrontBoardServices                  0x0000000110bdf96d -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        [ERROR]         25  CoreFoundation                      0x0000000109c95311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        [ERROR]         26  CoreFoundation                      0x0000000109c7a59c __CFRunLoopDoSources0 + 556
        [ERROR]         27  CoreFoundation                      0x0000000109c79a86 __CFRunLoopRun + 918
        [ERROR]         28  CoreFoundation                      0x0000000109c79494 CFRunLoopRunSpecific + 420
        [ERROR]         29  GraphicsServices                    0x000000010b397a6f GSEventRunModal + 161
        [ERROR]         30  UIKit                               0x0000000104e9af34 UIApplicationMain + 159
        [ERROR]         31  fblogintest                         0x00000001028c2326 main + 310
        [ERROR]         32  libdyld.dylib                       0x000000010df2168d start + 1
        [ERROR]         33  ???                                 0x0000000000000001 0x0 + 1
        [ERROR] )
        [ERROR] libc++abi.dylib: terminating with uncaught exception of type NSException
        
  16. Ygor Lemos 2016-09-12

    I have actually created a very simple app just for testing this issue and also created the application on Facebook, so everything is wired app correctly. Does it help you if I provide you with this testing source??? (if you want I can also make you an admin or tester of the app on facebook dev platform so you can actually login and run the app or I can create test users and provide the test logins here). This way you can just drop the updated module on every change and I think it would make debugging faster.
  17. Hans Knöchel 2016-09-12

    Did you use a precompiled master? Since the PR is not merged, yet, you need to compile a custom 6.1.0 from the above PR. Let me package it for you and give it to test, so we can speed-up the process. *EDIT*: Please download and unzip [this file](https://www.dropbox.com/s/kuip20k1xjcjvn3/5.5.0.zip?dl=0) to ~/Library/Application Support/Titanium/mobilesdk/osx/5.5.0 and make sure to change the SDK-version to that one. It is the latest 5.5.0 build including the fixes from the above PR (in TiBase.h/m and TiApp.m).
  18. Ygor Lemos 2016-09-12

    Hi Hans, I couldn't use the precompiled master because the ones on build.appcelerator were all 2 days old, so I went and checked-out the entire master pointed to your commit: 28ad30f12bb28c464b1f6e03da10b37463b1ace6 (which is the last one on your pull request to titanium_mobile) I will try with the version you packaged above and report back soon.
  19. Ygor Lemos 2016-09-12

    I just downloaded your pre-packaged 5.5.0 and used that to make a clean build of the app. I have also used the ti.facebook that I built module from the latest commit on your PR (f0ade97). Unfortunately the app still gives the same crash after I tap OK on the SafariController. On a side note, previously if I tapped the bottom-right button on the SafariController to open the fb login site on Safari externally and perform the authentication on Safari, it did get back to the app and the login happened normally. Now in this version it crashes too.
  20. Ygor Lemos 2016-09-12

    Also, I have observed that if we make the login using the module's button (fb.createLoginButton) it doesn't crash when returning to the app, different behavior of calling the authorize() method directly. That said, it returns to the app without a crash but doesn't login the user since all state variables are nil/undefined.
  21. Hans Knöchel 2016-09-12

    Added an additional commit to fire a Ti.App.iOS.handleurl event to get notified about handled URL's. Relates to two other tickets, so I've put it here to link it.
  22. Chee Kiat Ng 2016-09-12

    More PRs!: 6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8358 5_5_X: https://github.com/appcelerator/titanium_mobile/pull/8357 master: https://github.com/appcelerator/titanium_mobile/pull/8356 facebook module: https://github.com/appcelerator-modules/ti.facebook/pull/64

    Steps to test

    Scenario A: Use the case above. It will fail to log in without crashing. Scenario B: Using the same case, follow these instructions to include a appname.entitlements in platform/ios: {quote} **Using Facebook module with iOS 10 and Xcode 8** To log in using facebook, we now have to include an entitlements file that enables Keychain Sharing Capabilities. To do so, create a /platform/ios/<appname>.entitlements file with this content {quote}
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
            <key>keychain-access-groups</key>
            <array>
                <!-- APP_ID same as the id value in the tiapp.xml file -->
                <string>$(AppIdentifierPrefix)APP_ID</string>
            </array>
        </dict>
        </plist>
        
  23. Ygor Lemos 2016-09-12

    @Chee 1. Do we really have to create the entitlements file on /platform/ios or can we add keychain-access-groups to the ios section on tiapp.xml ? 2. Also in "/platform/ios/.entitlements", refers to the bundle id or the app name string itself (that can be i18n'ed and varies in some cases) ? Thanks
  24. Hans Knöchel 2016-09-12

    [~ygbr] 1. It needs to be the entitlements-file, because the Info.plist is not the .entitlements file (the entitlements are used to manage app capabilities, the Info.plist to manage app settings) 2. I need to look-up the folder-structure, but it's similar to where you save localized app-titles as well. Reading your comment, you probably copied the proposed entitlements to your tiapp instead of a new file? That would solve the last mystery, why it worked for me but didn't for you.
  25. Ygor Lemos 2016-09-13

    @Hans I can confirm that after adding the entitlements to /platform/ios/fblogintest.entitlements file with keychain-access-groups it stopped crashing and facebook login now works both with the authorize() as with the facebook login button. Thanks Hans!!!
  26. Chee Kiat Ng 2016-09-13

    Please note that you need $(AppIdentifierPrefix) in the entitlements file in order to run on device.
  27. Eric Merriman 2016-09-13

    Verified with Ygor's sample that the workflow was successful. Got a red "1" indicating login. Created a new Facebook developer entry and set plist as required. Initially had issues with entitlements on the provision installing to device, but [~cng] has a solution there we should get tomorrow. Also verified the following as additional test.
        var fb = require("facebook");
        fb.initialize();
        
        var win = Ti.UI.createWindow({
            backgroundColor: "#fff"
        });
        var btn = Ti.UI.createButton({
            title: (fb.loggedIn) ? "Request write permissions and submit" : "Login"
        });
        
        btn.addEventListener("click", function() {
            if (fb.loggedIn) {
                requestPublishPermissions();
            } else {
                fb.permissions = ['email'];
                fb.authorize();
            }
        });
        
        fb.addEventListener("login", function(_e) {
            if (!_e.success) {
                btn.setTitle("Login");
                Ti.API.error("Login cancelled/failed!");
                Ti.API.error(_e);
                return;
            } else {
                Ti.API.info("Login succeeded");
                btn.setTitle("Request write permissions and submit");
            }
        });
        
        function requestPublishPermissions() {
            fb.requestNewPublishPermissions(['publish_actions'], fb.AUDIENCE_ONLY_ME, function(e) {
                if (!e.success) {
                    alert("Publish permissions denied!");
                    return;
                }
        
                var blob = Ti.UI.createView({
                    width: 500,
                    height: 500,
                    backgroundColor: "green"
                }).toImage();
        
                var args = {
                    picture: blob,
                    caption: "Great green view"
                };
        
                fb.requestWithGraphPath('me/photos', args, "POST", showRequestResult);
            });
        
        }
        
        function showRequestResult(e) {
            alert("Photo has been submitted, check your facebook photo album");
            Ti.API.info(e);
        }
        
        win.add(btn);
        win.open();
        
    All performed with: Xcode: 8.0 beta 6 (8S201h) iOS: 10.0.1 (14A403) Appc CLI Core: 5.5.0-6 Appc CLI NPM: 4.2.7 Appcelerator Studio: 4.7.1.201609100950 Titanium SDK: 5.5.0.v20160912200427 Facebook module: 5.2.5
  28. Chee Kiat Ng 2016-09-13

    New PRs with doc updates here: 5_5_X: https://github.com/appcelerator/titanium_mobile/pull/8362 6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8363 master: https://github.com/appcelerator/titanium_mobile/pull/8364 facebook PR: https://github.com/appcelerator-modules/ti.facebook/pull/65
  29. Hans Knöchel 2016-09-13

    Follow-up ticket to support Titanium SDK < 5.5.0: MOD-2297
  30. Eric Merriman 2016-09-14

    Verified fixed with: NPM Version: 2.15.1 Node Version: 4.4.3 Mac OS: 10.11.2 Appc CLI: 5.5.0 Appc CLI NPM: 4.2.7 Titanium SDK version: 5.5.0.GA Appcelerator Studio, build: 4.7.1.201609100950 Xcode 8.0 GM I used the sample code attached as well as the one mentioned in my previous comment. I noticed that the log in requires two button pushes before logging in, and will write a separate ticket for that and link here.
  31. Brian Freid 2016-09-16

    Please reopen this issue as the problem still exists.
  32. Chee Kiat Ng 2016-09-16

    [~bfreid] can you please provide more information of the problem you have and share with us the environment you are using? Make sure it's Facebook module 5.2.6. Is it failing for only iOS10 or everything? Thanks.
  33. Brian Freid 2016-09-16

  34. Brian Freid 2016-09-16

    I have just verified with the development team that this issue still exists and is becoming very visible with more and more people upgrading to IOS10.
  35. Brian Freid 2016-09-16

    @Chee: I've confirmed that we are using the Facebook module 5.2.6
  36. Chee Kiat Ng 2016-09-16

    [~bfreid] can you describe the scenario again? You meant the first attempt will cause the app to hang and not Facebook right? Is this happening on simulator? On simulator you have to provide an appname.entitlements file to platform/ios as instructed on the readme and docs for it to run. It'll be helpful if you can provide us a reproducible sample code so that we can isolate the problem you are facing.
  37. Brian Freid 2016-09-19

    @Chee we are having same issues on 5.2.7 as we had on 5.2.6. This is not done on a simulator, it is on a live app. the first time you install the application it works, from there on every time after will open login page and go back to the app and show it's loading till the login is prompted a 2nd time. the only way to get it work the first time thereafter is to uninstall/reinstall the app or reboot the device.
  38. Francisco Antonio Duran Ramirez 2016-09-19

    Hello Brian Freid. By my side it is working good. But I had to execute the logout method before executing the authorize method. Please try this: fb.initialize(); fb.logout(); fb.authorize(); Thanks, and best, Antonio.
  39. Brian Freid 2016-09-19

    Francisco, Thank you for the recommendation, unfortunately our login process is more complex and won't work as you suggested. Because of the problems that Appcelerator is having with logging, we are unable to trouble shoot the problem in more detail. We've tried several different recommendations and unfortunately none of them have been successful.
  40. Brian Freid 2016-09-20

    Can someone provide an update on the status of this issue?
  41. Hans Knöchel 2016-09-20

    [~bfreid] We didn't hear any open issue since TIMOB-23904 was fixed. If you still have issues with ti.facebook 5.2.7, please provide a test-case that is reproducible and we can take a look. Thanks!
  42. Brian Freid 2016-09-20

    @Hans Knoechel we are having same issues on 5.2.7 as we had on 5.2.6. This is not done on a simulator, it is on a live app. the first time you install the application it works, from there on every time after will open login page and go back to the app and show it's loading till the login is prompted a 2nd time. the only way to get it work the first time thereafter is to uninstall/reinstall the app or reboot the device.
  43. Hans Knöchel 2016-09-20

    [~bfreid] Once again, we cannot reproduce your issue without a valid demo-code to debug. Please provide one (isolated, runnable through a single app.js if possible) and we can speed-up the review of it. Thanks!
  44. Brian Freid 2016-09-20

  45. Hans Knöchel 2016-09-20

    Hey [~bfreid], very happy to hear that, thank you!
  46. Mitch Starnes 2016-09-22

    @Brian Freid: We have a very similar problem with a URL scheme. What was the fix for you?
  47. Mitch Starnes 2016-09-23

    What was the issue?
  48. Hani Hamadeh 2016-10-20

    Hi guys, I was still facing the error with the module's facebook button even with module version 5.2.7 . I replaced it with a normal button and it worked.
  49. Hans Knöchel 2016-10-20

    [~hini] It's confirmed to be working so it must be something with your environment. Make sure to follow the guide in the [Ti.Facebook docs](http://docs.appcelerator.com/platform/latest/#!/api/Modules.Facebook) to migrate and ensure to use at least 5.5.1.GA (both CLI and SDK) with Xcode 8 and iOS 10. Thanks!
  50. Hani Hamadeh 2016-10-20

    Thanks for replying Hans. I see from the thread that what was tested is using a normal button, not the module's facebook login buggon. I can confirm that using a normal button worked fine, but my initial code which uses the module's login button still causes the same behavior This works:
        var fbloginbutton = Ti.UI.createImageView({
        	image:'/images/loginwithfb.png',
        	height: Ti.UI.SIZE,
        	right: 25, left:25
            //title: "Login with Facebook"
        });
         
        fbloginbutton.addEventListener("click", function() {
            fb.authorize();
        });
        
        
    but this shows the blank safari screen and a warining in the logs: "Warning :-Presenting view controllers on detached view controllers is discouraged:"
        fb.createLoginButton({
        	readPermissions : ['user_friends', 'email'],
         	top : 10,
         	width : '88%',
         	height : '50',
         })
        
  51. Petr Cervenka 2016-11-17

    Thanks last post worked for me too!

JSON Source