π¦Push Notifications - Firebase (Advanced)
We are using Firebase Service to provide a Push Notification functionality.
π§ Bubble.io Plugin
[Element] Natively - Push Notifications (Firebase)
Initialization:
On initialization, the element will try to get the current notification permission status. (No need to call it on the Page Is Load event)
Element Events:
Firebase FMC Token Updated - get called when FMC token was updated.
Firebase APNS Token Updated - get called when APNS token was updated.
Notification permissions authorized - get called when the user clicks Allow on permission alert.
Notification permissions denied - get called when the user clicks Decline on permission alert.
Notification permissions status updated - get called when permission status was updated because of the user's action.
Topic subscription status - get called when topic subscription status was updated because of the user's action: subscribe/unsubscribe.
Element States:
Permission Status - Yes or No.
Firebase FCM Token - FMC token's text value.
Firebase APNS Token - APNS token's text value
Topic subscription status - 'SUCCESS' if the 'subscribe' action was successful
Topic unsubscribe status - 'SUCCESS' if the 'unsubscribe' action was successful
Element Actions:
Request the user's push notification permission - displays a systems popup with your Notification Permissions Text
Get the user's Firebase APNS Token - Reload the user's Firebase APNS token
Get the user's Firebase FCM Token - Reload the user's Firebase FCM token
Get the user's push notification permission status
Subscribe to topic
Topic ID - the FCM topic name
Unsubscribe from topic
Topic ID - the FCM topic name
How to send Push Notifications with Firebase?
Firebase Console - Firebase Console Docs
Topic messaging - Firebase Topic Messaging Docs
Cloud Messaging REST API
To a topic subscribers
To a single user
Bubble - Setup example
Request Push Notification permission whenever you need it.

Save APNS token to your user model (only for iOS)


Save FCM token to your user model


π JavaScript SDK
NativelyNotifications
How to set up?
Make sure you've prepared your app and Firebase for Push Notifications.
call firebase_request_permission (required for both iOS & Android).
call firebase_get_apns_token (will return the APNS token for iOS).
call firebase_get_token (will return the FCM token).
Save FMC token and the APNS token (for iOS) somewhere (for example, save them in the user's fcm_token property and apns_token property).
Recommendations
Request the user's notification permission. You can do that in any necessary place. For example: show a popup that explains to the user's why your app needs it (so, it can be a better experience when just displaying a system popup)
Identify a user by using FCM token.
Check the fcm_token value on each login (It can be changed)
Last updated
Was this helpful?