【发布时间】:2021-03-31 11:09:29
【问题描述】:
我目前在 react-native 中使用 this 库来安排本地通知,当我从通知中心或应用程序顶部点击通知时,我想将用户重定向到特定屏幕。目前 react-native-push-notification 库使用已弃用的旧 UILocalNotification 类。
下面是我配置本地通知的代码。
onNotification 是当用户从 iOS 的通知中心启动应用时触发的回调方法,类似地 onAction 适用于 Android。
/**
* To configure for local notifications
*/
export function localNotificationConfigure() {
PushNotification.configure({
onNotification: async function (notification) {
console.log('notification.data', notification.userInteraction);
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
onAction: async function (notification) {
console.log('notification', notification.userInteraction);
},
permissions: {
alert: true,
badge: true,
sound: true,
},
popInitialNotification: true,
requestPermissions: Platform.OS === 'ios',
});
}
有什么方法可以实现这一点。是否因为使用 UILocalNotification 的 lib 已被弃用,我无法在代码中恢复操作。任何帮助表示赞赏。
【问题讨论】:
标签: android ios react-native uilocalnotification react-native-push-notification