适用于FBSDK和LinkingManager的AppDelegate.m [英] AppDelegate.m for both FBSDK and LinkingManager

查看:150
本文介绍了适用于FBSDK和LinkingManager的AppDelegate.m的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用FBSDK,我需要在app delegate中使用此代码段

To use FBSDK I need this snippet in 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中使用此代码段

To use LinkingManager I need this snippet in 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

They're obviously duplicates. How do I combine the two so both libraries work? I don't know any Objective-C

推荐答案

当然,你只能在你的方法中实现这个方法一次 AppDelegate

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

[[FBSDKApplicationDelegate ... [RCTLinkingManager ... 都返回 BOOL

您可以将两个片段放在同一个方法中。我建议返回 YES ,如果 [RCTLinkingManager ... [[FBSDKApplicationDelegate] ... 返回。否则,返回

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.

它可能如下所示:

- (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 在同一个应用程序中,因为我从未使用过这个。但是你的代码至少应该编译。

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.

这篇关于适用于FBSDK和LinkingManager的AppDelegate.m的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆