在我的Ionic App中,我通过Firebase Cloud Messaging从我自己的服务器接收推送通知。我正在发送通知与一个帖子请求到 https://fcm.googleapis.com/fcm/send
. 他们有 data
钥匙组,有 title
, a body
和 content-available
发送到1。
在我的应用中,我使用Capacitor的推送通知插件来接收通知,像这样。
PushNotifications.addListener('pushNotificationReceived', (notification: PushNotification) => {
alert('Push received ' + JSON.stringify(notification));
});
当应用程序打开并可见时,它的工作原理是一样的, 但当它在后台时,什么都没有发生,直到我再次打开它。有什么办法可以让我在App处于后台的时候收到这个消息吗?