Travail sur un projet IOS réac-natif.Effectuer une action après une notification push lorsque l'application est désactivée: react-native, IOS
Lorsque l'application est mort et une notification push est reçue -
Je veux l'application pour accéder à une autre page en fonction de la charge utile de la notification. Lorsque l'application est au premier plan ou en arrière-plan - tout fonctionne très bien. lorsque l'application est supprimée - l'application s'ouvre elle-même.
ajouté ci-dessous est mon code Appdelegate.m. J'attrape la notification et la connecte à la console, mais je ne sais pas comment l'envoyer à react-native.
utilisant RN 0,46
expo 19 (à ExpoKit détaché)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor whiteColor];
[[ExpoKit sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
_rootViewController = [ExpoKit sharedInstance].rootViewController;
_window.rootViewController = _rootViewController;
[_rootViewController loadReactApplication];
[_window makeKeyAndVisible];
if ([launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (notification) {
//logs the notification's payload
NSLog(@"app recieved notification from remote%@",notification);
} else {
NSLog(@"app did not recieve notification");
}
}
return YES;
}
https://jsfiddle.net/nirbenya/pxojj7qv/
Merci, mais mon application n'a pas été lancée à partir d'une URL externe. il a été lancé –
@ NirBen-Yair quel service utilisez-vous pour envoyer des notifications? – bennygenel
PushNotificationsIOS normal fourni avec reac-native. rien de personnalisé comme un signal ou une base de feu. J'ai également éjecté de l'expo et je pense que cela pourrait être lié. –