Skip to content

Instantly share code, notes, and snippets.

@scottyab
Last active August 17, 2020 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottyab/90a92c0e753c41cef105bc2b65e581d6 to your computer and use it in GitHub Desktop.
Save scottyab/90a92c0e753c41cef105bc2b65e581d6 to your computer and use it in GitHub Desktop.
Sample of how an app "MyApp" would intergrate and enable Beacon SDK push notifications
class MyAppFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
if(remoteMessage.data.isNotEmpty()) {
processNewMessage(remoteMessage.data)
}
}
private fun processNewMessage(remoteMessageData: Map<String, String>) {
if (BeaconPushNotificationsProcessor.isBeaconNotification(remoteMessageData)) {
val beaconPushProcessor = BeaconPushNotificationsProcessor()
beaconPushProcessor.process(this, remoteMessageData)
} else {
processMyAppNotification(remoteMessageData)
}
}
override fun onNewToken(token: String) {
Beacon.setFirebaseCloudMessagingToken(token)
storeAndUploadTokenToMyAppServer(token)
}
private fun processMyAppNotification(remoteMessageData: Map<String, String>) {
TODO("Not yet implemented")
}
private fun storeAndUploadTokenToMyAppServer(token: String) {
TODO("Not yet implemented")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment