Нужны некоторые рекомендации о том, как заставить RNN работать с response-native-siri-shortcut .
Пожалуйста, потерпите меня, если мой пост слишком многословен, так как я нуб с xCode
и objective C
, поэтому не хочу ничего пропустить.
Итак, у меня есть пара вопросов / проблем с попыткой заставить две библиотеки работать вместе:
1. Настройка initialProperties
с помощью RCTRootView
react-native-siri-shortcuts
устанавливает приложение в AppDelegate.m
следующим образом:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
// Check if the app launched with any shortcuts
BOOL launchedFromShortcut = [launchOptions objectForKey:@"UIApplicationLaunchOptionsUserActivityDictionaryKey"] != nil;
//Add a boolean to the initialProperties to let the app know you got the initial shortcut
NSDictionary *initialProperties = @{ @"launchedFromShortcut":@(launchedFromShortcut) };
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"doesthismatter"
initialProperties:initialProperties // Add the initial properties here
launchOptions:launchOptions];
...
}
В V2 RNN rootView больше не используется, вместо этого мы просто вызываем:
[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
Поэтому мы не можем передать initialProperties
до rootView
.
2. Доступ к rootView
в других частях кода
Продолжение настройки react-native-siri-shortcut
:
// This method checks for shortcuts issued to the app
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler
{
UIViewController *viewController = [self.window rootViewController];
RCTRootView *rootView = (RCTRootView*) [viewController view];
// If the initial properties say the app launched from a shortcut (see above), tell the library about it.
if ([[rootView.appProperties objectForKey:@"launchedFromShortcut"] boolValue]) {
ShortcutsModule.initialUserActivity = userActivity;
rootView.appProperties = @{ @"launchedFromShortcut":@NO };
}
[ShortcutsModule onShortcutReceivedWithUserActivity:userActivity];
return YES;
}
Поскольку RCTRootView
не используется для регистрации нашего приложения, сработает ли эта часть кода?
Я уже искал в репозитории проблемы, связанные с initialProps
и reactView
, и те несколько проблем, которые я обнаружил, не получили ответа и были закрыты из-за бездействия.
Любая помощь будет принята с благодарностью.