【问题标题】:Navigate notification to screen it belongs in react-native将通知导航到它属于 react-native 的屏幕
【发布时间】:2017-01-02 12:17:45
【问题描述】:

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

我想实现通知,以便当我的设备上出现通知并且我单击该通知时,它应该将我呈现到该特定通知屏幕。目前我正在使用ios设备。

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

【问题讨论】:

  • 您有没有找到成功的解决方案?我现在也在努力解决这个问题

标签: javascript android ios push-notification react-native


【解决方案1】:

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

{
    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 );
     },

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多