-1

I m developing application for iOS and there is sharing feature on whatsApp i did this part now i want that i would share link on WhatsApp if user click on this and user has installed this application then it would be opened otherwise app store link will be opened. Please share idea if anyone had did this part earlier. I think i need to crate custom url but don't know how it can be done. I have used this code.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
        sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  NSLog(@"Calling Application Bundle ID: %@", sourceApplication);
  NSLog(@"URL scheme:%@", [url scheme]);
  NSLog(@"URL query: %@", [url query]);

  return YES;
}
mccc
  • 2,354
  • 1
  • 20
  • 22
Mohit
  • 516
  • 7
  • 24
  • possible duplicate of [How to launch safari and open URL from iOS app](http://stackoverflow.com/questions/12416469/how-to-launch-safari-and-open-url-from-ios-app) – Sheshnath Oct 14 '14 at 13:38
  • 1
    @sheshnath the question is about how to let WhatApp open your app not how to open an other app. – rckoenes Oct 14 '14 at 13:41
  • Is it? Darn, wording, man... – mccc Oct 14 '14 at 13:43

1 Answers1

2

You need to add you one app URL scheme on the info.plist, once you have done this iOS will know that the entered URL will start your app.

I'm not sure whether WhatApp will detect custom app URL sheme and handle a click on that link correctly.

enter image description here

Or via the project settings: enter image description here

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • Thanks I did it but now problem is if i haven't install application then how it could be opened application on iTunes. – Mohit Oct 15 '14 at 10:28
  • @Mohit it can't, iOS does not support this. You will have to route the opening of your app via a website that will try and start your app via javascript and if it times out you open your app in the AppStore. – rckoenes Oct 15 '14 at 11:07
  • I don't know if my application is installed then how it will open?Please give a idea – Mohit Oct 15 '14 at 12:30
  • Just as in my previous comment, you can't. Only by opening a webpage can you check it a bit. You open your app url via javascript and if it times out you open the App Store. – rckoenes Oct 15 '14 at 12:55