要使用FBSDK,我需要在app delegate中使用此代码段
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation ]; // Add any custom logic here. return handled; }
要使用LinkingManager,我需要在app delegate中使用此代码段
#import "RCTLinkingManager.h" - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; }
他们显然是重复的.我如何将两者结合起来使两个库都有效?
我不知道任何Objective-C
解决方法
当然,您只能在AppDelegate中实现此方法一次.
[[FBSDKApplicationDelegate …和[RCTLinkingManager …都返回BOOL.
您可以将两个片段放在同一个方法中.如果[RCTLinkingManager …和[[FBSDKApplicationDelegate …]返回YES,我建议返回YES.否则,返回NO.
它可能看起来像这样:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { BOOL handledFB = [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation ]; BOOL handledRCT = [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; return handledFB || handledRCT; }
我不能保证,你可以在同一个应用程序中使用FBSDKApplicationDelegate和RCTLinkingManager,因为我从未使用过这个.但是你的代码至少应该编译.