I recently upgraded to unity 5.5 and facebook sdk 7.8.0.
Since i did this fb login in iOS fails in UnityAppController.mm, in this function:
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
NSMutableArray* keys = [NSMutableArray arrayWithCapacity:3];
NSMutableArray* values = [NSMutableArray arrayWithCapacity:3];
auto addItem = [&](NSString* key, id value)
{
[keys addObject:key];
[values addObject:value];
};
addItem(@"url", url);
addItem(@"sourceApplication", sourceApplication);
//FAILS ON THE FOLLOWING LINE BECAUSE annotation IS NULL
addItem(@"annotation", annotation);
NSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys];
AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);
return YES;
}
If i comment out the line that tries to add “annotation” variable to the array it works fine.
Login in android works fine.
Anyone know how to fix this or work around it without having to manually edit the file?
This is still an issue with Unity 5.5.0f3 and Facebook SDK 7.9.0. I fixed it by replacing the method with the older version for now just in case the “annotation” key is actually used for something.
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
NSMutableArray* keys = [NSMutableArray arrayWithCapacity:3];
NSMutableArray* values = [NSMutableArray arrayWithCapacity:3];
#define ADD_ITEM(item) do{ if(item) {[keys addObject:@#item]; [values addObject:item];} }while(0)
ADD_ITEM(url);
ADD_ITEM(sourceApplication);
ADD_ITEM(annotation);
#undef ADD_ITEM
NSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys];
AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);
return YES;
}
https://unity3d.com/unity/qa/patch-releases
Theres Patch 5.5.0p4 that addresses this issue (:
(856989) - iOS: Fixed crash in application:openURL:sourceApplication:annotation due to missing null check with Facebook SDK.
This fix was also posted here: Log into Facebook (by Jing Liao) and worked for me. Just add 2 files in the unity project, rebuild, and it works.
I am in Unity 5.6.1f1 and Facebook SDK 7.9.4 and i am getting this error when sharing. Also Logins keeps re-asking on every app opening. (IOS and Android app)
Can somebody help me please?