-1

I want to open the app with myapp://something?id=123 when an user with the app installed visits http://myapp.com/something?id=123 and if an user does not have an app then open url in browser.

Also, is Bundle URL Scheme can start with numeric?

My Current info.plist file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>myapp</string>
            </array>
            <key>CFBundleURLName</key>
            <string>com.organizationname.myapp</string>
        </dict>
    </array>
    ....

</dict>
</plist>

Edit:

Following is the my scenario.

I received an URL in email (e.g. http://techfuzionwithsam.wordpress.com). When I tap on that URL on my iPhone i want to open my application if installed otherwise open the browser

MilanPanchal
  • 2,943
  • 1
  • 19
  • 37
  • What? You question is very unclear, please provide more information. – Popeye Feb 06 '14 at 12:59
  • Search a bit around the internet first. A scheme cannot start with a number. You would find that in the URL/URI specification. Javascript can detect if an application is installed and redirect to different links depending on the result. – Sulthan Feb 06 '14 at 13:01

2 Answers2

1

Your initial link in the email will need to send them to a page that can redirect them to the app or site. Just include this javascript on the page:

setTimeout(function() {
    if (!document.webkitHidden)
        window.location = "http://www.myotherurl.com";
}, 250);
window.location = "myapp://something?id=123";
Lance
  • 8,872
  • 2
  • 36
  • 47
1

First you should include a statement on your page http://myapp.com/something like this:

setTimeout(function() {
    if (!document.webkitHidden)
        window.location = "http://myapp.com/download";
}, 200);
window.location = "myapp://something?id=123";

In addition to ensure your app can execute right, you should add some statement in your app, like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    ...

    NSString *outSideUrl = launchOptions[UIApplicationLaunchOptionsSourceApplicationKey];
    if (outSideUrl) {
        // ...
    } else {
        // ...
    }
    return YES;
}
jiwq
  • 43
  • 4