I have implemented a URL Scheme and use it to pass data to my app by calling method. The entire code is shown as below
- (BOOL)application:(UIApplication *)a
I believe there is a better answer now as,
application:handleOpenURL:
application:openURL:sourceApplication:annotation:
Both are deprecated in ios 9. Apple suggestion is:Use
application:openURL:options:
instead.
application:openURL:options:
has different behaviour than the old ones, as it will be executed in case the app was in background or will launch.
So, you need to handle the URL opening within it only. like below:
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary *)options {
// Check the calling application Bundle ID
if ([[url scheme] isEqualToString:@"yuvitime"])
{
NSLog(@"URL scheme:%@", [url scheme]);
NSString * yuvitimeRequestValue = [url query];
NSDictionary * userInfor = [[NSDictionary alloc]initWithObjectsAndKeys:yuvitimeRequestValue, @"YuvitimeRequest", nil];
NSNotificationCenter * notificationCentre = [NSNotificationCenter defaultCenter];
[notificationCentre postNotificationName:@"URLSCHEMEACTIVATEDNOTIFICATION" object:self userInfo:userInfor];
return YES;
}
else
return NO;
}