Professional Documents
Culture Documents
Scot Ringa Files
Scot Ringa Files
kotlin
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.media.RingtoneManager
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.google.firebase.example.messaging.R
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
// [START receive_message]
override fun onMessageReceived(remoteMessage: RemoteMessage) {
// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
Log.d(TAG, "From: ${remoteMessage.from}")
// [START on_new_token]
/**
* Called if the FCM registration token is updated. This may occur if the
security of
* the previous token had been compromised. Note that this is called when the
* FCM registration token is initially generated so this is where you would
retrieve the token.
*/
override fun onNewToken(token: String) {
Log.d(TAG, "Refreshed token: $token")
val notificationId = 0
notificationManager.notify(notificationId, notificationBuilder.build())
}
companion object {
private const val TAG = "MyFirebaseMsgService"
}