我目前正在通过RCTLinking API处理ios通用链接。出于某些原因,我需要使用Firebase动态链接,我想知道是否可以在我的应用程序中使用它们。我的问题是在以下方面的实施:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
和
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
这似乎是不兼容的,因为我需要返回RCTLinkingManager和RNFirebaseLinks
有解决方案吗
您可以在restorationHandler
函数中使用下面的代码:
BOOL handled = [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
if (!handled) {
handled = [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
return handled;
回答这个问题有点迟了,但目前提出的答案是行不通的。它将无法打开Firebase In-App Messaging中的操作,因为NO
返回的RNFirebaseLinks
将被RCTLinkingManager
覆盖,YES
将用于恢复处理程序。
如果您遇到此问题,请尝试以下操作:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL handledLink = [[RNFirebaseLinks instance] application:application openURL:url options:options];
if (!handledLink) {
handledLink = [RCTLinkingManager application:application openURL:url options:options];
}
return handledLink;
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {
BOOL handleRestore = [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
if (handleRestore) {
handleRestore = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
return handleRestore;
}
我目前的设置和需要是react-navigation
v3和react-native-firebase
v5