Riad
Riad
TTCTheo's Typesafe Cult
Created by Riad on 10/8/2024 in #questions
React native : how to handle notification actions clicks on android on background/killed states
I've been struggling with this issue for so long ( 1 week ) to handle click quick actions on notifications soo basically the situation is i receive a ( data-only ) remote message and then push a local notification and add actions to it, but when it comes to handling em in background and quit state, i click the actions nothing happens here's the code i call on my index.js
PushNotification.configure({ onNotification: function (notification) { const appState = AppState.currentState; if (appState !== 'active') { if (!notification.userInteraction) { PushNotification.localNotification({ channelId: '// some chennel id', title: notification.data.title, message: notification.data.message, priority: 'high', actions: JSON.parse(notification.data.actions).map( (item: any) => item.title, ), smallIcon: 'ic_notification_icon', largeIcon: '', bigText: '', subText: '', bigPictureUrl: '', userInfo: notification.data, }); } else { const actionIdentifier = notification.action; if (!actionIdentifier) return; switch (actionIdentifier) { case 'YES': console.log('YEEEEES'); break; case 'NO': console.log('NOOOOP'); break; case 'CHECK': console.log('check it') // this action should open the app and navigate to a notifs screen break; default: console.log('No actionIdentifier selected', actionIdentifier); break; } } } }, });
1 replies