Javascript 如何使用react native实现推送通知
每当应用程序处于后台或关闭时,Socket.io频道就会断开连接。如何始终保持频道连接,因为我必须在聊天应用程序中包含推送通知功能 在react native上处理通知的最佳方式是什么 这取决于您支持的平台,在设备上接收移动推送通知的最佳方式是实施特定于平台的解决方案 你为什么这么做 因为即使你的应用程序关闭或处于后台,用户也会在屏幕上收到通知,你可以处理它 对于iOS: 您必须使用服务器发送推送通知 对于Android: 你必须使用 为了使实现更容易,您可以使用以下服务:Javascript 如何使用react native实现推送通知,javascript,android,ios,react-native,push-notification,Javascript,Android,Ios,React Native,Push Notification,每当应用程序处于后台或关闭时,Socket.io频道就会断开连接。如何始终保持频道连接,因为我必须在聊天应用程序中包含推送通知功能 在react native上处理通知的最佳方式是什么 这取决于您支持的平台,在设备上接收移动推送通知的最佳方式是实施特定于平台的解决方案 你为什么这么做 因为即使你的应用程序关闭或处于后台,用户也会在屏幕上收到通知,你可以处理它 对于iOS: 您必须使用服务器发送推送通知 对于Android: 你必须使用 为了使实现更容易,您可以使用以下服务: 如何用
var PushNotification = require('react-native-push-notification');
PushNotification.configure({
onRegister: function(token) {
// Call when your device register the token
// You have to pass this token to the API or services like OneSignal, Pusher etc...
console.log( 'TOKEN:', token );
},
// This is trigger when a remote notification is received or open
onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );
},
// This is only for Android
senderID: "YOUR GCM (OR FCM) SENDER ID",
// This is only for iOS
permissions: {
alert: true,
badge: true,
sound: true
},
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
// Ask the permission to receive notifications
requestPermissions: true,
});
您还拥有实现您选择的服务的库,如:
- 推手:
- 一个信号:
- 火基:
我希望我的回答能帮助您,谢谢您的回答。@JulienKode您能告诉我当用户点击通知时如何触发一些操作吗?