Skip to content

Commit 8d672e3

Browse files
committed
fix new API with user auth token in README
1 parent f6aaef5 commit 8d672e3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ $notifications = array(
2727
array(
2828
'endpoint' => 'https://updates.push.services.mozilla.com/push/abc...', // Firefox 43+
2929
'payload' => 'hello !',
30-
'userPublicKey' => 'dahaj5365sq',
30+
'userPublicKey' => 'BPcMbnWQL5GOYX/5LKZXT6sLmHiMsJSiEvIFvfcDvX7IZ9qqtq68onpTPEYmyxSQNiH7UD/98AUcQ12kBoxz/0s=', // base 64 encoded, should be 88 chars
31+
'userAuthToken' => 'RMpCEzkgBaVj0Zj0', // base 64 encoded, should be 16 chars
3132
), array(
3233
'endpoint' => 'https://android.googleapis.com/gcm/send/abcdef...', // Chrome
3334
'payload' => null,
3435
'userPublicKey' => null,
36+
'userAuthToken' => null,
3537
), array(
3638
'endpoint' => 'https://example.com/other/endpoint/of/another/vendor/abcdef...',
3739
'payload' => '{"msg":"test"}',
38-
'userPublicKey' => 'fsqdjknadsanlk',
40+
'userPublicKey' => '(stringOf88Chars)',
41+
'userAuthToken' => '(stringOf16Chars)',
3942
),
4043
);
4144

@@ -46,7 +49,8 @@ foreach ($notifications as $notification) {
4649
$webPush->sendNotification(
4750
$notification['endpoint'],
4851
$notification['payload'], // optional (defaults null)
49-
$notification['userPublicKey'] // optional (defaults null)
52+
$notification['userPublicKey'], // optional (defaults null)
53+
$notification['userAuthToken'] // optional (defaults null)
5054
);
5155
}
5256
$webPush->flush();
@@ -56,6 +60,7 @@ $webPush->sendNotification(
5660
$notifications[0]['endpoint'],
5761
$notifications[0]['payload'], // optional (defaults null)
5862
$notifications[0]['userPublicKey'], // optional (defaults null)
63+
$notifications[0]['userAuthToken'], // optional (defaults null)
5964
true // optional (defaults false)
6065
);
6166
```
@@ -78,7 +83,7 @@ $apiKeys = array(
7883
);
7984

8085
$webPush = new WebPush($apiKeys);
81-
$webPush->sendNotification($endpoint, null, null, true);
86+
$webPush->sendNotification($endpoint, null, null, null, true);
8287
```
8388

8489
### Payload length and security

0 commit comments

Comments
 (0)