Untitled
unknown
plain_text
7 months ago
2.3 kB
4
Indexable
// En NotificationContext.tsx, 1-122 - Modificar el método responseListener.current
responseListener.current =
Notifications.addNotificationResponseReceivedListener((response) => {
console.log(
"🔔 Notification Response: ",
JSON.stringify(response, null, 2),
);
// Extraer los datos de la notificación
const data = response.notification.request.content.data;
const url = data?.url;
if (url && typeof url === 'string') {
DeviceEventEmitter.emit('NotificationTapped', { url });
}
});
// En index.tsx agregar un useEffect
useEffect(() => {
const notificationTapListener = DeviceEventEmitter.addListener(
'NotificationTapped',
(data) => {
if (data.url) {
setUri(data.url);
if (webViewRef.current) {
webViewRef.current.reload();
}
}
}
);
return () => notificationTapListener.remove();
}, []);
// Para iOS, en ios/toqueApp/AppDelegate.mm
// Agregar después del método messaging:didReceiveRegistrationToken:
// Manejo de notificaciones cuando la app está en primer plano
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
}
// Manejo de notificaciones cuando el usuario interactúa
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
NSDictionary *userInfo = response.notification.request.content.userInfo;
// Pasar los datos de la notificación
if (self.bridge) {
[NSNotificationCenter.defaultCenter postNotificationName:@"RemoteNotificationReceived" object:self userInfo:userInfo];
}
completionHandler();
}
En android/ revisar que MainActivity.java incluya:
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}Editor is loading...
Leave a Comment