0

I am using Today extension in ios.

I have multiple view controller with different info. and I am displaying some info in tableview using Today extension. when click on row then I want to open related viewcontroller with info.

I have tried following code.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   {
      NSURL *url = [NSURL URLWithString:@"ReadText://"];
      [self.extensionContext openURL:url completionHandler:nil];

   }

I have set url schemes in info.plist

but using this code I can only open root viewcontroller.

appreciate for help.

Vinod Jadhav
  • 1,055
  • 1
  • 15
  • 37

1 Answers1

1

Yes you can open the customViewController progrmattically by passing custom data to urlSchemes.

NSURL *url = [NSURL URLWithString:@"ReadText://customViewController"];

Implement the delegate method and get the string from url and than push the customViewController progrmattically.

 -(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
       NSString *viewController =  [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
       if([viewController isEqualToString:@"customViewController"]) {
          //push customViewController on rootViewController
       }
  }
codester
  • 36,891
  • 10
  • 74
  • 72
  • actual problem is app delegate method doesn't called? – Vinod Jadhav Dec 30 '14 at 07:35
  • try applicationdidfinishlaunching with NSURL *url = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey]; – codester Dec 30 '14 at 07:40
  • If the app delegate method doesn't get called, then either (a) you didn't configure the URL scheme properly, or (b) you're calling the wrong URL scheme (maybe you mistyped it?). – Tom Harrington Jan 04 '15 at 22:58