googlearchive / web-push-encryption

[Deprecated] Encryption Utilities for Web Push protocol
Apache License 2.0
84 stars 23 forks source link

Not getting payload #46

Closed uqutub closed 8 years ago

uqutub commented 8 years ago

From Server am using: webpush.sendWebPush('my push messsage', subscription).then(function(resolve,reject){ console.log('chrome resolve: ', resolve); console.log('chrome reject: ', reject); });

result of resolve: { statusCode: 201, statusMessage: 'Created', body: '' }

on client getting push event: {data: PushMessageData, type: "push", target: ServiceWorkerGlobalScope, currentTarget: ServiceWorkerGlobalScope, eventPhase: 2…}

i always found empty object: PushMessageData {}

bt4R9 commented 8 years ago

Hi, uqutub. PushMessageData is a special interface to interact with a payload. There are several methods for a data extraction. For example PushMessageData.json(). You can find more here https://developer.mozilla.org/ru/docs/Web/API/PushMessageData

uqutub commented 8 years ago

thanks. will check this out.

but this sendWebPush function takes first parrameter as message and then encrypt it and set to the body property, but when it is sending and get resloved callback it shows body empty, not getting message on client side in data.

zeeshanhanif commented 8 years ago

I'm facing the same problem. Body is empty

uqutub commented 8 years ago

it is resolved,

actually the issue is in all documentation we have read to get data from event by event.data.json() but it gives error, we have get data from event.data.text();

thanks .