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.


1 Answer

1

Probably not relevant any longer, but in case someone is looking for an answer, here is a good article I found about the topic - Override UnityAppController in iOS - Questions & Answers - Unity Discussions

The link is is to this same answer. Probably by mistake