RN Deep Linking for Android
1. AppDelegate.m
导入:
#import <React/RCTLinkingManager.h>
文件末尾 @end 前加入:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
2. 在 xcode 中设置
3. 调用 Deep Linking
如果使用的是 iOS 模拟器, 可以通过以下命令调用:
> npx uri-scheme open galoiszhou://home --ios
> xcrun simctl openurl booted galoiszhou://home
如果是真机, 可以在 safari 浏览器直接打开:
galoiszhou://home
|