- Home /
Override UnityAppController in iOS
I want to pass a parameter to an Unity iOS app via a URL using an iOS plugin. I have successfully passed a parameter via URL by adding/editing the following the UnityAppController in Xcode:
- (void) callUnitySendMessage:(const char*)object Method:(const char*)method Parameter:(const char*)parameter
{
UnitySendMessage(object, method, parameter);
}
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
NSString* hostString = url.host;
[self callUnitySendMessage:"NativeInterfaceReceiver"
Method:"TestThisFunction"
Parameter:hostString.UTF8String];
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;
}
I’d prefer to do this via a Unity plugin so that I don’t have to edit anything in Xcode. I figure I should be able to do this by overriding this function with a subclass of UnityAppController called MyAppController under Plugins/iOS. But how do I get MyAppController to replace UnityAppController? This is what I have so far--not sure if I'm on the right track.
Answer by sokoloff06 · Oct 19, 2019 at 11:59 AM
Probably not relevant any longer, but in case someone is looking for an answer, here is a good article I found about the topic - https://answers.unity.com/questions/1200828/override-unityappcontroller-in-ios.html
Your answer
Follow this Question
Related Questions
AssetBundle won't download on iPad 0 Answers
how to fix the "unityexception : launching ios project via xcode failed" exception ? 0 Answers
huge iOS build size even with empty scene 0 Answers
ISN_GameCenterManager.mm - No matching function for call to 'UnitySendMessage' 0 Answers
touch of the controls 0 Answers