我正在为 React Native 应用程序添加通用/深度链接,它还使用 AppsFlyer React Native 插件/iOS SDK(但我相信这不是问题)。每当我单击通用链接(AppsFlyer OneLink)时,它会启动应用程序,但application:continueUserActivity:restorationHandler
根本不会调用该方法。当我通过配置的 URL 方案启动时,它工作正常。我添加了一个willContinueUserActivityWithType
方法,当应用程序以 的NSUserActivity
类型启动时运行,NSUserActivityTypeBrowsingWeb
但之后它只是正常启动应用程序。这是 AppDelegate.m 中的代码:
#import <RNAppsFlyer.h>
@implementation AppDelegate
// ...
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(nonnull NSString *)userActivityType {
if ([userActivityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
return YES; // using the xcode debbugger I can see it gets to here
}
return NO;
}
// handle Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler]; // I don't think this is an issue. But I can provide more details about AppsFlyer if you need it
return YES;
}
// other library/framework initialistion
@end
Appsflyer github here上有一个问题,但那里的建议都没有奏效,而且显然它已在我正在使用的最新框架版本(6.2.41)上修复。这里的 React Native github 上也有一个问题,但是我尝试了这些建议(禁用远程 JS 调试、发布构建等),但没有任何效果;实际上在发布模式下,willContinueUserActivityWithType
根本不会被调用。不过,我继续在这里进行实验。