Is there any doc on how to use the new AppDelegateListener? More specifically I looking at using the onOpenURL event that is being triggered from the XCode's application: openURL:sourceApplication:annotation I really don't want to write code into the UnityAppController, or use a category and override it, or use the PostProcessBuildPlayer to monkey patch it. Thanks!
no need to do anything of it if you dont want to change actual impl. Everything you put into Plugins/iOS will be added to final xcode project Also, you can create your custom app controller subclass: you just need to IMPL_APP_CONTROLLER_SUBCLASS(YourSubclassName); somewhere in your mm files to make unity use it
Thanks Alexey! 2 more questions: 1.) Is there a way to get the URL inside of Unity code? or would I have to write that in XCode and pass it in myself? 2.) For the IMPL_APP_CONTROLLER_SUBCLASS macro, do I do something like this? Code (csharp): @implementation UnityAppControllerSub - (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation { //custom code here like set a user preference or parse the url return [super application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } @end IMPL_APP_CONTROLLER_SUBCLASS(UnityAppControllerSub); and then stick that in a UnityAppControllerSub.mm file under the plugins/iOS directory?
well, yes - you write the code yes, just dont forget that you actually need to subclass/inherit from UnityAppController
Can you be a little more specific please? In UnityAppController.mm it has this method - (BOOL)applicationUIApplication*)application openURLNSURL*)url sourceApplicationNSString*)sourceApplication annotationid)annotation that sends off the passed url and other data with AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); How and where do I respond to that notification inside Unity in order to access the passed url? Thanks
>>How and where do I respond to that notification inside Unity in order to access the passed url? this is native ios notification, so you write objc code to do what you want (register listener and pass url)
Seem to have got it working. Added this to top of UnityAppController.mm extern void UnitySendMessage(constchar *, constchar *, constchar *); then inside this method - (BOOL)applicationUIApplication*)application openURLNSURL*)url sourceApplicationNSString*)sourceApplication annotationid)annotation I added UnitySendMessage("ReceiveMessages", "openURLComplete", "Message to send"); So ReceiveMessages is a gameobject, openURLComplete is the function and "Message to send" is the test string I passed. Was able to debug it in unity so it seems fine. Thanks
PS to pass the URL I used const char *URLString = [[url absoluteString] UTF8String]; UnitySendMessage("ReceiveMessages", "openURLComplete", URLString);
Where do I paste this code " extern void UnitySendMessage(constchar *, constchar *, constchar *); " when I pasted this at the top,below the import functions I got a error message "Unknown type name 'constchar' ".Where to paste this