File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,29 @@ const messaging = getMessaging(firebaseApp)
4646</script>
4747```
4848
49+ If you find yourself using this very often, you can create a composable for it:
50+
51+ ::: code-group
52+
53+ ``` ts [composables/firebase-messaging.ts]
54+ import { getMessaging } from ' firebase/messaging'
55+ import { useFirebaseApp } from ' vuefire'
56+
57+ export function useFirebaseMessaging() {
58+ return getMessaging (useFirebaseApp ())
59+ }
60+ ```
61+
62+ ``` vue [MyComponent.vue]
63+ <script setup>
64+ import { useFirebaseMessaging } from '~/composables/firebase-messaging'
65+
66+ const messaging = useFirebaseMessaging()
67+ </script>
68+ ```
69+
70+ :::
71+
4972In the case of Services that require initialization, you should do it alongside the initialization of the Firebase App:
5073
5174``` ts
You can’t perform that action at this time.
0 commit comments