AnsweredAssumed Answered

[SDK17] App Delegate OpenURL

Question asked by sfpx on Oct 21, 2018
Latest reply on Oct 21, 2018 by sfpx

I 'm trying to use the url scheme of the sdk project to run some functions instead of launching the database.

Let's say that I have the following 2 url schemes in my info.plist

myapp

myapp2

 

myapp would be used to launch the actual database

ex: myapp://~/mydb.fmp12

 

myapp2 would be used to run a special function

ex: myapp2://specialfunction

 

It works fine but the special operation is a gps tracking that sends data to the app via the url scheme.

Ex: myapp://~/mydb.fmp12?Script=receivecoordinates

 

Unfortunately those calls won't work even though the completionhandler says the url has succesfully opened.

 

Below is a code that illustrates my problem without the complicated gps tracking code.

 

 

- (BOOL)application:(UIApplication *)app

            openURL:(NSURL *)url

            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options

{

   

    if ([[url host] isEqualToString:@"specialfunction"])

    {

  

        NSString *URLSTRING =[NSString stringWithFormat:@"myapp://~/mydb.fmp12?Script=atest"];

       

        NSURL *URL = [NSURL URLWithString:URLSTRING];

        NSLog(@"URL: %@", URLSTRING);

        [app openURL:URL options:@{} completionHandler:^(BOOL success) {

            if (success) {

                NSLog(@"Opened url");

            }

        }];

    }

   

    return YES;

}

From my database I run the Open URL script step "myapp2://specialfunction"

The console window will show "Opened url" but the script is never called.

If I run the Open URL script step "myapp://~/mydb.fmp12?Script=atest" directly from the database it will work.

In the above code, if I replace the myapp url by an http url, it will work and safari will be launched.

 

If I remove the code above from the appdelegate file, I can successfully call "myapp://~/mydb.fmp12?Script=atest" from my gps tracking code (using a file monitoring to actually launch the code)

 

 

Any idea or suggestion ?

Outcomes