Skip to main content

Android - Push Receiver Module Interface

PushReceiverModule interface helps you connect into the Firebase push notification system. Useful if your module needs to send or receive notifications.

Implementation

Create a class, and have it inherit the PushReceiverModule. Once inherited, override the functions provided and add your logic as required.

class PushReceiver(private val sdkUtils: SdkUtils): PushReceiverModule {

/**
* On enroll, gives you access to the [NotificationManager], which allows you to create your own
* channels.
*/
override fun createNotificationChannel(context: Context, notificationManager: NotificationManager) {

}

/**
* When Firebase issues a new token, it will be sent to your module here, allowing you to keep up to date
*/
override fun onNewToken(token: String) {

}

/**
* When Firebase sends a notification to the device, Core will send it to each module to verify if the notification
* is theirs. If the remote message is yours then consume it and return true. Otherwise return false and do
* not consume it
*/
override fun willConsumeNotification(
context: Context,
remoteMessage: com.google.firebase.messaging.RemoteMessage
): Boolean {

// Return true if the notification is yours and you are going to consume it
return remoteMessage.data.containsKey(myKey)
}
}

Triggering From Core

PushReceiverModule is triggered automatically and does not require any work done on Tecton. Once the device is enrolled into the Firebase system, you will start receiving notifications and updated tokens when required.

SDKPushUtils

SdkUtils provides the SDKPushUtils which can be used to access the current registration token as well as other information associated to push notifications. See SDKUtils SDKPushUtils for more information.

Update Your settings.json

Ensure your settings.json file in the root of the DevApp is updated to reflect your module changes. Learn more in Configuring settings.json.