package com.clickdelivery.nativebridge import android.app.* import android.content.Context import android.os.Build import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage class ClickDeliveryFirebaseService:FirebaseMessagingService(){override fun onNewToken(token:String){getSharedPreferences("clickdelivery_push",Context.MODE_PRIVATE).edit().putString("fcm_token",token).apply()} override fun onMessageReceived(m:RemoteMessage){val manager=getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;val channel="clickdelivery_orders";if(Build.VERSION.SDK_INT>=26)manager.createNotificationChannel(NotificationChannel(channel,"ClickDelivery",NotificationManager.IMPORTANCE_HIGH));val n=if(Build.VERSION.SDK_INT>=26)Notification.Builder(this,channel) else Notification.Builder(this);n.setSmallIcon(applicationInfo.icon).setContentTitle(m.notification?.title?:m.data["title"]?:"ClickDelivery").setContentText(m.notification?.body?:m.data["body"]?:"Nueva actualización").setAutoCancel(true);manager.notify((System.currentTimeMillis()%100000).toInt(),n.build())}}