0
votes

I have a custom defined URL scheme and a TARGET app that registered this scheme to be recognized.

When I launch a WEB app in mobile Safari and I push a button in the WEB App, there is an URL link provided by the button, and a dedicated TARGET application is launched - which is the desired behaviour.

However if I launch a native SOURCE app, and implement an action on a UIButton, and there I call the appdelegate to openURL and pass the same url that is used from the web app, TARGET app is not launched. The [UIApplication canOpenURL] check even returns NO, which is strange, since TARGET App DID register that custom URL Scheme correctly, otherwise it would not work from the web app.

Any help?

PS:SOURCE and TARGET are just convenient names for SO.

UPDATE:

- (IBAction)handleAction:(id)sender
{
    NSString *urlString = @"nda://nda.undernda/actionundernda?someparamters..";

BOOL isURLSchemeRegistered = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:urlString]];

if (isURLSchemeRegistered == YES)
    {
        [[UIApplication sharedApplication] openURL:[NSURL     URLWithString:urlString]];
    }
else
  {
    //go to appstore
  }
}
1
There's not enough info to answer your question. Please supply the scheme you're using as well as code examples and screenshot of scheme settings?miken.mkndev
Update your question with the actual code you use to call openURL:.rmaddy
please provide us the code so we can see what you're talking about!Apollo SOFTWARE
I added the code.This method is ridiculously trivial..And I can't disclose the url content, I am under NDA..so I am not sure how it can help...Earl Grey
Stupid questions time: (1) is the URL scheme complicated enough to have a possible typo in the native code that would cause it to fail there but not in your canned webpage? (2) What version of iOS and have you checked the plist entries for scheme support to make sure there's nothing odd there? I can't think of anything that would qualify, but since you're down to the fact that the app-level scheme handling doesn't seem to be being recognized, there may be some config subtlety going on that is almost correct...Brad Brighton

1 Answers

1
votes

Ok ,so the problem was that he url had characters that were not escaped using UTF8 encoding.

Solution:

    NSString *urlString = @"sorry..can't show this :(";
NSString *escapedUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url =[ NSURL URLWithString:escapedUrlString];

[[UIApplication sharedApplication] openURL:url];