- Home /
Unity 5.5 and Facebook SDK not working well together in iOS
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?
Answer by Frank84 · Dec 02, 2016 at 02:07 AM
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;
}
Answer by ubberkid · Jan 21, 2017 at 06:51 AM
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.
Answer by Emmanuel_Charon · Dec 20, 2016 at 09:55 PM
This fix was also posted here: https://developers.facebook.com/bugs/900542723380664/?__mref=message_bubble (by Jing Liao) and worked for me. Just add 2 files in the unity project, rebuild, and it works.
Answer by GeekCats · Jun 12, 2017 at 02:36 PM
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?
Your answer
Follow this Question
Related Questions
Facebook - Is it possible to logout other active sessions? 0 Answers
Xcode hook up with Unity 1 Answer