1

I have an issue with URL Scheme in plist file as "m.zameen.com" but i type this in iPhone's safari browser not op[en but when i open using :// it opened

    // In AppDelegate.m file

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{

  if([[url host] isEqualToString:@"page"]){

    if([[url path] isEqualToString:@"/main"]){

      [self.mainController setViewControllers:@[[[DLViewController alloc] init]] animated:YES];
    }

    else if([[url path] isEqualToString:@"/page1"]){

      [self.mainController pushViewController:[[Page1ViewController alloc] init] animated:YES];
    } 
    return YES;
  }

  else{

    return NO;
  }

}
 // In DLViewController.m file

- (IBAction)page1Clicked:(id)sender {
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"m.zameen.com://page/page1"]];
}


// In Page1ViewController.m file

- (IBAction)mainPageClicked:(id)sender {
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"m.zameen.com://page/main"]];
}
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
Mian Rizwan
  • 39
  • 1
  • 1
  • 4
  • Do you want to open other app or your own app from safari(from your website)? – Pushparaj Mar 30 '15 at 06:44
  • You can open app from safari using following references: http://stackoverflow.com/questions/6964515/launching-app-or-app-store-from-safari http://stackoverflow.com/questions/5746289/determine-if-an-app-exists-and-launch-that-app-on-ios – Pushparaj Mar 30 '15 at 06:52
  • Why have you just asked the exact same question again but with less information. http://stackoverflow.com/questions/29307384/ios-how-to-implement-deep-linking-in-ios-app Voting to close as a duplicate. If you have an edit for your other question then please edit that question and don't go asking the exact same question again – Popeye Mar 30 '15 at 07:18
  • possible duplicate of [iOS - How to implement deep linking in iOS to move to a Specific page not on home page?](http://stackoverflow.com/questions/29486013/ios-how-to-implement-deep-linking-in-ios-to-move-to-a-specific-page-not-on-hom) – Simon Apr 07 '15 at 08:47

1 Answers1

0

In your project Info tab, add a new URL Type with the scheme you want to use to open the app, for example 'myAwesomeAppScheme', using your app bundle identifier 'com.myCompany.myAwesomeApp' in the identifier field and the scheme you want in the URL Schemes field:enter image description here

Then in you app delegate you can check if the opened url has your scheme with something like this

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if ([url.scheme isEqualToString:@"myAwesomeAppScheme"]) {
        ...
    }
}

And finally to open the app from an external app, the link has to be something like myAwesomeAppScheme://parameters/for/opening/viewcontrollers?otherParam=blahblah

Juan de la Torre
  • 1,297
  • 9
  • 19
  • 1
    actually i dont want to open the app from an external app , i want to open safari browser and type the link if that scheme app exist then open the app otherwise open the itunes link to install the app – Mian Rizwan Mar 30 '15 at 06:03
  • Pass the application appstore URl link to the button action, that will load the app store with specific application searched, from there you can open/install an app – Teja Swaroop Apr 04 '18 at 14:32