如何将pushMessage(聊天)传递给通知?
如何让它在前台接收推送通知(当应用程序仍然打开时)和后台(不打开应用程序)*目前它将在关闭应用程序后收到通知
我应该在哪个部分工作?
App.js
--------
PushNotification.configure({
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );
// process the notification . * this will overwrite the My Notification 1 below
PushNotification.localNotification({
foreground: true,
title: "My Notification Title",
message: "My Notification 2", // (required)
});
// required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
});
class App extends Component{
componentDidMount(){
const connection = signalr.hubConnection('https://api.abc.com');
const proxy = connection.createHubProxy('chatHub');
proxy.on('pushMessage', (chat) => {
PushNotification.localNotification({
foreground: true,
title: "My Notification Title",
message: "My Notification 1", // (required)
});
});
}
}