Search Unity

[SOLVED] ios intent and url scheme - openUrl has nil arguments

Discussion in 'iOS and tvOS' started by Stamp-Enzi, Aug 13, 2019.

  1. Stamp-Enzi

    Stamp-Enzi

    Joined:
    Aug 17, 2017
    Posts:
    17
    Hey all!

    I have upgraded from 2018.3.12f1 to 2019.1.13f1.
    Seems like my intent handling of url schemes has broken and I'm pretty much stuck on it.

    The app opens correctly when the deeplink is called from the browser and it then jumps into UnityAppController.mm:
    Code (CSharp):
    1. - (BOOL)application:(UIApplication*)app openURL:(NSURL*)url options:(NSDictionary<NSString*, id>*)options
    Problem is that every parameter is nil, so I figured it's not much use that my custom AppController is not called when the parameters aren't even working and don't contain any data.

    What to do? I haven't found anything on it. Some methods/calls are deprecated with ios10 but I don't even make it that far and the UnityAppController path should work correct, right?

    Any help is appreciated if you've run into this problem yourself.
    Maybe a permission problem? I have run out of ideas.

    Thanks and greetings,
    Enzi
     
  2. Stamp-Enzi

    Stamp-Enzi

    Joined:
    Aug 17, 2017
    Posts:
    17
    Bump
    Does no one have this issue? Just me?
     
    Last edited: Aug 19, 2019
  3. jwtan_unity

    jwtan_unity

    Unity Technologies

    Joined:
    Nov 28, 2018
    Posts:
    12
    How are you launching your deeplink? Do you tap on a url in Notes or Safari?

    Can you give an example url of the deeplink you are having problems with?
     
  4. Stamp-Enzi

    Stamp-Enzi

    Joined:
    Aug 17, 2017
    Posts:
    17
    The URL is launched from Safari, the link is: stampmanager://GetToken
    Xcode is 10.3
    Before I postprocessed the plist to add the url scheme. Now I can do it directly in Unity.
    I have tried both, the resulting config file is the same.
    I've tried compiling versions with ios 9 and 12. Doesn't seem to make any difference.
     
  5. jwtan_unity

    jwtan_unity

    Unity Technologies

    Joined:
    Nov 28, 2018
    Posts:
    12
    You should be able to extend UnityAppController and override openURL such that you can retrieve the deeplink url (i.e. stampmanager://GetToken) that was used to open your app. I've just tested this functionality on 2019.1.13f1 and it is working. Also, the signature for openURL has not changed between 2018.3.12f1 and 2019.1.13f1.

    Are you already extending UnityAppController? Can you please show me your implementation?
     
  6. Stamp-Enzi

    Stamp-Enzi

    Joined:
    Aug 17, 2017
    Posts:
    17
    Okay thanks! The file hasn't seen changes for some versions now.
    You can find it attached. Had to rename it to cs to be able to upload.
     

    Attached Files:

  7. jwtan_unity

    jwtan_unity

    Unity Technologies

    Joined:
    Nov 28, 2018
    Posts:
    12
    You need to override openURL using the correct signature. You can find the required signature by looking in UnityAppController. You actually referenced the correct signature in your first post.

    What you are using
    Code (CSharp):
    1. - (BOOL)application:(UIApplication*)application
    2.             openURL:(NSURL*)url
    3.   sourceApplication:(NSString*)sourceApplication
    4.          annotation:(id)annotation
    What you need
    Code (CSharp):
    1. - (BOOL)application:(UIApplication*)app
    2.             openURL:(NSURL*)url
    3.             options:(NSDictionary<NSString*, id>*)options
     
  8. Stamp-Enzi

    Stamp-Enzi

    Joined:
    Aug 17, 2017
    Posts:
    17
    That was indeed the only problem. I've implemented the new method header and it's working again now. Thanks so much!

    Seems like I don't understand some fundamental inner workings of Obj C. The call to openUrl in UnityAppController with no arguments threw me off so much I never even tried to implement the new one, thinking it wouldn't work anyway. Now that was a good learning lesson for the future.
    Thanks again!
     
  9. jwtan_unity

    jwtan_unity

    Unity Technologies

    Joined:
    Nov 28, 2018
    Posts:
    12
    No problem at all. Glad to help. :)