Manage the subscription state using localStorage, IndexedDB, or a server-side solution(e.g. in Firestore, store per-user), depending on the flow of your app.
Create a notification section in settings, in navbar or just prompt it directly(not recommended, bad UX).
On UI interaction such as a subscribe
button, call subscribeNotifications
with the related parameters(subscribe = true/false, token
), then persist the notification state.
You can create and manage the notifications from Firebase Console. You can also create some cloud functions to create them manually or on some action(maybe when a new post inserted to firestore).