javascript - Chrome push notifications. Message identification -
while send notification client, have data:
$> curl --header "authorization: key=$key" --header content-type:"application/json" https://gcm-http.googleapis.com/gcm/send -d "{\"registration_ids\":[\"$subs\"]}" {"multicast_id":5959734605210485936,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1454898928592704%592683fbf9fd7ecd"}]}
this multicast_id , message_id params.
my question is: how can 1 of (or both) these params serviceworker script?
self.addeventlistener('push', function (event) { ... // need that: msgid = event.message_id; m_castid = event.multicast_id; ... });
in other words, need of possible way determine message inside serviceworker script.
thanks in advance,
with best regards,
nikolai
solved!
i don`t know how message id, found how identify subscription:
self.addeventlistener('push', function (event) { ... self.registration.pushmanager .getsubscription() .then( function( subscription ) { var registrationid = subscription.endpoint.split('/'); registrationid = registrationid[ registrationid.length - 1 ]; ... }); ... });
may useful somebody.
Comments
Post a Comment