Skip to content

Commit 390fa34

Browse files
committed
[messaging] Add VAPID key support
1 parent 4bf7d07 commit 390fa34

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

messaging/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ List of Cloud Messaging hooks:
1818
### useToken
1919

2020
```js
21-
const [token, loading, error] = useToken(messaging);
21+
const [token, loading, error] = useToken(messaging, vapidKey);
2222
```
2323

2424
Get a token from Firebase Cloud Messaging
2525

2626
The `useToken` hook takes the following parameters:
2727

2828
- `messaging`: `messaging.Messaging` instance for your Firebase app
29+
- `vapidKey`: a `string` representing the VAPID key credential needed for Cloud Messaging
2930

3031
Returns:
3132

messaging/useToken.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { LoadingHook, useLoadingValue } from '../util';
44

55
export type TokenHook = LoadingHook<string | null, Error>;
66

7-
export default (messaging: Messaging): TokenHook => {
7+
export default (messaging: Messaging, vapidKey?: string): TokenHook => {
88
const { error, loading, setError, setValue, value } = useLoadingValue<
99
string | null,
1010
Error
1111
>();
1212

1313
useEffect(() => {
14-
getToken(messaging).then(setValue).catch(setError);
14+
getToken(messaging, { vapidKey }).then(setValue).catch(setError);
1515
}, [messaging]);
1616

1717
const resArray: TokenHook = [value, loading, error];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-firebase-hooks",
3-
"version": "5.0.0-alpha.3",
3+
"version": "5.0.0-alpha.4",
44
"description": "React Hooks for Firebase",
55
"author": "CS Frequency Limited (https://csfrequency.com)",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)