How do I open an app in iOS with "appname: // openApp?"?

I need to open another app with parameters from my iOS app.

I have a specific url scheme provided by app developers to open:

secondApp://openApp?param1=XXX&param2=YYY

      

I'm trying to google how to open the app this way, but I haven't found any example on how to use this construct.

Can you provide me with a link or line of code on how to open the application this way?

+3


source to share


2 answers


You can check out this Inter-App Communication documentation provided by Apple. Alternatively, you can check out the tutorial . Here they send text to another application. Also, another detailed answer to your question can be found in here .

The following tutorial code will help you:



-(IBAction) openReceiverApp {
// Opens the Receiver app if installed, otherwise displays an error
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"secondApp://openApp?param1=XXX";
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
    [ourApplication openURL:ourURL];
    }
}

      

+4


source


To open a second app from an iOS app, simply use:



NSURL *url = [NSURL URLWithString:@"secondApp://openApp?param1=XXX&param2=YYY"];  //fill your params
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}

      

+3


source







All Articles