我正在尝试使用GCM推送通知API。到目前为止,它运作良好,但我不确定如何发布其他数据。
我按照这个页面上的步骤进行操作:https://developers.google.com/web/fundamentals/getting-started/push-notifications/step-07
所以我最终编写了一个像这样的curl请求:
有没有一种方法可以读取此事件中的
谢谢阅读!
curl --header "Authorization: key=myKey" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[myRegistrationId], \"additionalData\": {\"user_id\":\"1\"}}"
然后我的sw.js(我的服务工作者)。self.addEventListener('push', function(event) {
console.log('Push message', event);
var title = 'test a';
event.waitUntil(
self.registration.showNotification(title, {
body: 'The Message',
icon: '/assets/img/logo.png',
tag: 'my-tag'
}));
});
有没有一种方法可以读取此事件中的
additionalData
?或者我不应该这样做吗?谢谢阅读!
curl
请求。我尝试添加additionalData
。 - Koeno