AppDelegate.m for both FBSDK and LinkingManager

前端 未结 3 1757
失恋的感觉
失恋的感觉 2021-02-20 05:24

To use FBSDK I need this snippet in app delegate

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url 
    sourceApplication:(NSString *)sourceA         


        
3条回答
  •  野性不改
    2021-02-20 05:38

    Of course, you can implement this method only once in your AppDelegate.

    [[FBSDKApplicationDelegate... and [RCTLinkingManager... both return a BOOL.

    You can put both snippets in the same method. I would suggest to return YES, if both [RCTLinkingManager... and [[FBSDKApplicationDelegate... return YES. Otherwise, return NO.

    It could look like this:

    - (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;
    }
    

    I can't guarantee, that you can use FBSDKApplicationDelegate and RCTLinkingManager in the same app, because I have never worked with this. But your code should at least compile.

提交回复
热议问题