Bubbl delivers push notifications via FCM. Your app can show a modal when a notification is received or opened.
<service
android:name="tech.bubbl.sdk.services.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>Without this, notifications will never reach the SDK.
private fun handleNotificationIntent(intent: Intent?) {
intent?.getStringExtra("payload")?.let { json ->
val notification = Gson().fromJson(
json,
NotificationRouter.DomainNotification::class.java
)
ModalFragment.newInstance(notification)
.show(supportFragmentManager, "notification_modal")
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleNotificationIntent(intent)
}Notifications can open your activity or deliver content while your app is already open.
private fun registerModalReceiver() {
LocalBroadcastManager.getInstance(this).registerReceiver(
modalReceiver,
IntentFilter(NotificationRouter.BROADCAST)
)
}This allows the SDK to deliver payloads while the app is running, even if it did not open the activity.
Tooltip
If you do not want to show modals, you can ignore the payload and just let the system notification appear.