Jeremy Sh Jeremy Sh - 11 months ago 66
iOS Question

Navigate to specific view with URL Scheme

I added a url scheme newConversation to my info.plist so that when a user clicks on a link in a browser/email it will redirect him to the app. This works perfectly fine.

I was wondering how I can open the app to a specific view controller when clicking this url?

I tried using:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if ([url.scheme isEqualToString:@"newConversation"]) {
NSLog(@"url schemeeeee");
emailLink = YES;
[self initWindow];
return YES;

but not getting anywhere with that.



Your app should only have one scheme (such as myappscheme) registered for your app. Then if you need to handle different actions, you provide more specific URLs with that scheme:


Then you get /newConversation for the URL's path. Then your code becomes:

if ([url.path isEqualToString:@"/newConversation"]) {
} else if ([url.path isEqualToString:@"/doSomethingElse"]) {