Search Unity

Facebook login crash

Discussion in 'iOS and tvOS' started by Simon75012, Dec 13, 2016.

  1. Simon75012

    Simon75012

    Joined:
    Sep 15, 2016
    Posts:
    79
    Hi,
    Everything was going fine and since few days i got the following error when i tried to login to facebook on Facebook :

    The crash happen when the facebook popup is active and i click anywhere on this screen (login and cancel button)

    I'm using mobile social plugin by stan asset, i tried to update the plugin, unistall/reinstall/downgrade/upgrade facebook sdk, but i got the same error.

    I don't know what "Invalid identifier: 'fb_mobile_login_native_app_switch_dialog_result'. Must be between 1 and 40 characters, and must be contain only alphanumerics, _, - or spaces, starting with alphanumeric or _. " mean.
    What identifier are they talking about? I just fill the "app Id" field in the facebook settings.

    Stan asset support told me that the error is not coming from their plugin.
    I'm fighting with this since a week :s

    Thanks

    Using:
    ios 10.0.2
    Xcode 8.0
    Facebook SDK 7.8 and 7.9
    Unity 5.5.0
     
    Last edited: Dec 13, 2016
  2. Simon75012

    Simon75012

    Joined:
    Sep 15, 2016
    Posts:
    79
  3. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    I am experiencing a crash similar to this also on Unity 5.5.0f3. We don't have the facebook popup, we app switch to facebook instead, but our app crashes when it attempts to switch back from Facebook.

    The only error I can get is a SIGABRT in main.mm at

    Code (CSharp):
    1. UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]);
    Will update if I find a solution.
     
  4. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    168
  5. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
  6. Vaidas_B

    Vaidas_B

    Unity Technologies

    Joined:
    Jun 17, 2016
    Posts:
    18
  7. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    168
    In the mean time @Benzino07, use these to do the automatic subclassing:

    create a file in your Plugins->iOS folder called OverrideUnityAppController.h and put this in it:

    Code (csharp):
    1.  #import "UnityAppController.h"
    2.  
    3. @interface OverrideUnityAppController : UnityAppController
    4.  
    5. - (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation;
    6.  
    7. @end
    and also create one called OverrideUnityAppController.mm with the following:

    Code (csharp):
    1. #import "OverrideUnityAppController.h"
    2.  
    3. #include "PluginBase/AppDelegateListener.h"
    4.  
    5.  
    6. @implementation OverrideUnityAppController
    7.  
    8. - (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
    9. {
    10.     NSMutableArray* keys    = [NSMutableArray arrayWithCapacity:3];
    11.     NSMutableArray* values    = [NSMutableArray arrayWithCapacity:3];
    12.  
    13.     auto addItem = [&](NSString* key, id value)
    14.     {
    15.         [keys addObject:key];
    16.         if (value == nil) {
    17.             [values addObject:[NSNull null]];
    18.         } else {
    19.             [values addObject:value];
    20.         }
    21.     };
    22.  
    23.     addItem(@"url", url);
    24.     addItem(@"sourceApplication", sourceApplication);
    25.     addItem(@"annotation", annotation);
    26.  
    27.     NSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys];
    28.     AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);
    29.     return YES;
    30. }
    31.  
    32. @end
    33.  
    34. IMPL_APP_CONTROLLER_SUBCLASS(OverrideUnityAppController)
    This should make the change permanently until its fixed in 5.5.x
     
  8. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    This fix won't necessarily work if you already have an overridden UnityAppController class in your project. Some third-party plugins do this so you might be unaware of it.

    I have 2 plugins (Helpshift and AppsFlyer) that both want to do this already so I had to hack them together into a single class for them both to work.
     
  9. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Hi @Kujo87

    Thanks for the code but that doesn't work for me. it just never calls my custom function. I also try to override the memory warning call, but same thing, it never gets called. I'm thinking @andymads might be correct in that another library has already overridden it, although I can't see one perhaps it in a lib.
     
  10. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    168
    ahh, makes sense yeah - I don't have any overriders thankfully, so been able to make it happen this way.