3

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

I have specific URL scheme provided from the developers of the App that have to be opened:

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

I try to search Google how to open App in this way but I did not found any example how to use this construct.

Can you provide me with link or a row of code how to open App in this way?

new2ios
  • 1,350
  • 2
  • 25
  • 56
  • check Inter-App Communication tutorial https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html – Kumar Aug 06 '15 at 09:19

2 Answers2

4

You can look into this documentation of Inter-App Communication provided by Apple. Also, you can look into this tutorial. Here, they are sending text to another app. Also, another detailed answer to your question can be found in here.

Following code from the tutorial 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];
    }
}
Community
  • 1
  • 1
Munahil
  • 2,381
  • 1
  • 14
  • 24
  • Although this is potentially quite a good answer, it is essentially a "link only" answer. You should include some information from your links so that if the information behind the links is ever changed/lost, the answer still makes sense. See [this link](http://meta.stackexchange.com/questions/225370/your-answer-is-in-another-castle-when-is-an-answer-not-an-answer) – James Webster Aug 06 '15 at 09:33
  • Thanks for informing, I will edit my answer accordingly – Munahil Aug 06 '15 at 09:35
3

To open second app from your iOS app, just use:

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