Commit e26e797b authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix noty type

parent fa3948b2
package com.biganto.visual.roompark.data package com.biganto.visual.roompark.data
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.data.service.notification.INotificationCenter import com.biganto.visual.roompark.data.service.notification.INotificationCenter
import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage import com.google.firebase.messaging.RemoteMessage
...@@ -12,6 +13,11 @@ class RoomParkMessageService : FirebaseMessagingService() { ...@@ -12,6 +13,11 @@ class RoomParkMessageService : FirebaseMessagingService() {
@Inject @Inject
lateinit var notyCenter: INotificationCenter lateinit var notyCenter: INotificationCenter
init {
notyCenter = RoomParkApplication.component.provideNotifivations()
}
override fun onNewToken(p0: String) { override fun onNewToken(p0: String) {
super.onNewToken(p0) super.onNewToken(p0)
Timber.d("NEW TOKEN REGISTERED: ${p0}") Timber.d("NEW TOKEN REGISTERED: ${p0}")
...@@ -24,7 +30,7 @@ class RoomParkMessageService : FirebaseMessagingService() { ...@@ -24,7 +30,7 @@ class RoomParkMessageService : FirebaseMessagingService() {
// Check if message contains a data payload. // Check if message contains a data payload.
if (remoteMessage.data.size > 0) { if (remoteMessage.data.size > 0) {
Timber.d("Message data payload: %s", remoteMessage.data) Timber.d("Message data payload: %s", remoteMessage.data)
notyCenter.showPushNotifyMessage(remoteMessage.notification?.body?:"Уведомление")
if ( /* Check if data needs to be processed by long running job */true) { // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher. if ( /* Check if data needs to be processed by long running job */true) { // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
// scheduleJob() // scheduleJob()
} else { // Handle message within 10 seconds } else { // Handle message within 10 seconds
...@@ -33,7 +39,8 @@ class RoomParkMessageService : FirebaseMessagingService() { ...@@ -33,7 +39,8 @@ class RoomParkMessageService : FirebaseMessagingService() {
} }
// Check if message contains a notification payload. // Check if message contains a notification payload.
if (remoteMessage.notification != null) { if (remoteMessage.notification != null) {
Timber.d("Message Notification Body: %s", remoteMessage.notification!!.body) Timber.d("Message Notification Body: %s", remoteMessage.notification?.body)
notyCenter.showPushNotifyMessage(remoteMessage.notification?.body?:"Уведомление")
} }
// Also if you intend on generating your own notifications as a result of a received FCM // Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below. // message, here is where that should be initiated. See sendNotification method below.
......
...@@ -131,12 +131,28 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif ...@@ -131,12 +131,28 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
override fun showPushNotifyMessage(message: String){ override fun showPushNotifyMessage(message: String){
val pendingIntent = PendingIntent.getActivity(context
, PENDING_REQUEST_CODE
, toDownloadsIntent
, PendingIntent.FLAG_ONE_SHOT
)
val noty = pushNotyBuilder val noty = pushNotyBuilder
.setContentTitle(context.getString(R.string.notification_content_title))//getString(R.string.app_name)) .setContentTitle(context.getString(R.string.notification_content_title))//getString(R.string.app_name))
.setPriority(NotificationCompat.PRIORITY_HIGH) .setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIcon(R.mipmap.ic_launcher) .setSmallIcon(R.mipmap.ic_launcher)
.setContentText(message)
.setColor(notificationSystemColor) .setColor(notificationSystemColor)
.setContentTitle(context.getString(R.string.notification_content_title))
.setContentIntent(pendingIntent)
.setContentText(message)
.setStyle(NotificationCompat.BigTextStyle()
.setBigContentTitle(context.getString(R.string.notification_content_title))
.bigText(
message
))
.setAutoCancel(true)
.build() .build()
actualNotifyManager.notify( actualNotifyManager.notify(
...@@ -168,7 +184,7 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif ...@@ -168,7 +184,7 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
.setColor(notificationSystemColor) .setColor(notificationSystemColor)
.setLargeIcon(icon) .setLargeIcon(icon)
.setContentIntent(pendingIntent) .setContentIntent(pendingIntent)
.setAutoCancel(false) .setAutoCancel(true)
.build() .build()
actualNotifyManager.notify( actualNotifyManager.notify(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment