Well I tried my best to resolve this but had absoultely no luck.
I have this paragraph that use to work properly. But need to resolve the deprecate method.
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(@"%@",url.scheme);
NSString *path = [[NSBundle mainBundle] pathForResource: @"Info" ofType: @"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path];
NSString *str = [NSString stringWithFormat:@"fb%@",[dict objectForKey: @"FacebookAppID"]] ;
BOOL result = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
if (result) {
return YES;
}
return [self.instagram handleOpenURL:url];
}
I see that it is now deprecated.
iOS (4.2 and later) Deprecated:Use application:openURL:options: instead. Which produces the following. But this is not called. What am I missing?
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{
NSLog(@"%@",url.scheme);
NSString *path = [[NSBundle mainBundle] pathForResource: @"Info" ofType: @"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path];
NSString *str = [NSString stringWithFormat:@"fb%@",[dict objectForKey: @"FacebookAppID"]] ;
BOOL result = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
if (result) {
return YES;
}
return [self.instagram handleOpenURL:url];
}
Thank you in advance for reviewing and any help is greatly appreciated.
The method "application:openURL:sourceApplication:annotation:" is deprecated from iOS9 onwards. So basically as @user2559325 suggests , this call back will not work in devices below iOS9. Please refer the following SDK interface.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation
NS_DEPRECATED_IOS(4_2, 9_0, "Please use application:openURL:options:")
Look at this post. It's is in swift but its basically the same implementation.
In objective-c it would be something like this
NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:nil];
The method you are using is available from iOS 9.0 onwards. It will not be called in devices below iOS 9.0.
Also for it to work in iOS 9+ devices. You have to add the LSApplicationQueriesSchemes key to your Info plist
LSApplicationQueriesSchemes (Array - iOS) Specifies the URL schemes you want the app to be able to use with the canOpenURL: method of the UIApplication class. For each URL scheme you want your app to use with the canOpenURL: method, add it as a string in this array. Read the canOpenURL: method description for important information about declaring supported schemes and using that method.
To learn about the converse operation of registering the URL schemes an app can handle, read the description of the CFBundleURLTypes key.
This key is supported in iOS 9.0 and later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With