Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Support for encrypted payload #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

delitestudio
Copy link

User can set an (externally) encrypted payload as described in #22 to be used with Chrome.

@delitestudio
Copy link
Author

Here it is an example on how to use it:

$sender = new PHP_GCM\Sender($api_key);
$payload = Minishlink\WebPush\Encryption::padPayload(json_encode($payload_data), false);

$encrypted = Minishlink\WebPush\Encryption::encrypt(
    $payload,
    $localPublicKey,
    $salt,
    version_compare(phpversion(), '7.1', '>=')
);

$message = new PHP_GCM\Message('push');
$message->publicKey($encrypted['localPublicKey']);
$message->salt($encrypted['salt']);
$message->rawData(base64_encode($encrypted['cipherText']));

$sender->sendNoRetryMulti($message, array($token));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants