如何替换-(BOOL)应用程序:openURL:sourceApplication:批注:(id)批注 [英] How to replace - (BOOL)application: openURL: sourceApplication: annotation:(id)annotation
问题描述
好吧,我尽力解决了这个问题,但是绝对没有运气.
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及更高版本)已弃用:请改用application:openURL:options:.产生以下内容.但这不被称为.我想念什么?
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.
推荐答案
iOS9以后不推荐使用方法" application:openURL:sourceApplication:annotation:".因此,基本上如@ user2559325所建议,此回调将无法在iOS9以下的设备中使用.请参考以下SDK界面.
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,请使用application:openURL:options:")
这篇关于如何替换-(BOOL)应用程序:openURL:sourceApplication:批注:(id)批注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!