gpt4 book ai didi

javascript - 将通知导航到它属于 react-native 的屏幕

转载 作者:行者123 更新时间:2023-11-29 17:07:27 24 4
gpt4 key购买 nike

我在我的应用程序中添加了推送通知,效果很好。

我想实现通知,这样当我的设备收到通知并且我点击该通知时,它应该会把我带到那个特定的通知屏幕。目前我正在使用 ios 设备。

我正在使用 https://www.npmjs.com/package/react-native-push-notification

最佳答案

如果您还没有在通知数据负载中为自己添加更多信息,这将指向您自己要呈现哪个屏幕:

{
foreground: false, // BOOLEAN: If the notification was received in foreground or not
userInteraction: false, // BOOLEAN: If the notification was opened by the user from the notification area or not
message: 'My Notification Message', // STRING: The notification message
data: {
yourKey: 'value'
}, // OBJECT: The push data
}

一旦您收到通知,请访问此函数中的额外数据字段:

 onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );
},

完成后,将相应的屏幕推送到 View 堆栈或在渲染函数内动态生成 View 或将 initialRoute 设置为您想要显示的屏幕。我假设您正在为多个屏幕使用导航器。

关于javascript - 将通知导航到它属于 react-native 的屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41426696/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com