Question

I am trying to open my app MyApp from another app, I've already defined the custom url for MyApp (i.e. myapp://).

If I write myapp:// in safari and click on go it will open MyApp. Now what I want is a simple app with only a UIButton "Launch MyApp" and when I click it MyApp will launch.

I tried it by doing this:

-(IBAction)launchMyApp:(id)sender
{
    NSString *mystr=[[NSString alloc] initWithFormat:@"myapp://"];
    NSURL *myurl=[[NSURL alloc] initWithString:mystr];
    [[UIApplication sharedApplication] openURL:myurl];
}

but nothing happened. If it is possible to implement this functionality please provide me the code.

Thanks

Was it helpful?

Solution

Solved the problem

I don't know how but it worked with the same code I've written in the question:

-(IBAction)launchMyApp:(id)sender
{
    NSString *mystr=[[NSString alloc] initWithFormat:@"myapp://"];
    NSURL *myurl=[[NSURL alloc] initWithString:mystr];
    [[UIApplication sharedApplication] openURL:myurl];
} 

OTHER TIPS

If it works in Safari, it may work in a UIWebView. Try displaying the page you used in Safari in a UIWebView and see if it wokrs !

Use some actual URI, not just scheme and then nothing, e.g. myapp://launch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top