|
|
|
@ -1,14 +1,11 @@
|
|
|
|
|
package org.thoughtcrime.securesms.loki.api
|
|
|
|
|
|
|
|
|
|
import android.R
|
|
|
|
|
import android.app.NotificationManager
|
|
|
|
|
import android.app.PendingIntent
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.graphics.Color
|
|
|
|
|
import android.media.RingtoneManager
|
|
|
|
|
import androidx.core.app.NotificationCompat
|
|
|
|
|
import androidx.core.app.NotificationManagerCompat
|
|
|
|
|
import com.google.firebase.messaging.FirebaseMessagingService
|
|
|
|
|
import com.google.firebase.messaging.RemoteMessage
|
|
|
|
|
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob
|
|
|
|
|
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
|
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
|
|
|
|
import org.whispersystems.libsignal.logging.Log
|
|
|
|
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
|
|
|
|
@ -37,6 +34,24 @@ class PushNotificationService : FirebaseMessagingService() {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Log.d("Loki", "Failed to decode data for message.")
|
|
|
|
|
val builder = NotificationCompat.Builder(this, NotificationChannels.OTHER)
|
|
|
|
|
.setSmallIcon(network.loki.messenger.R.drawable.ic_notification)
|
|
|
|
|
.setColor(this.getResources().getColor(network.loki.messenger.R.color.textsecure_primary))
|
|
|
|
|
.setContentTitle("Session")
|
|
|
|
|
.setContentText("You've got a new message.")
|
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
|
|
|
.setAutoCancel(true)
|
|
|
|
|
with(NotificationManagerCompat.from(this)) {
|
|
|
|
|
notify(11111, builder.build())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onDeletedMessages() {
|
|
|
|
|
org.thoughtcrime.securesms.logging.Log.d("Loki", "Called onDeletedMessages.")
|
|
|
|
|
super.onDeletedMessages()
|
|
|
|
|
val token = TextSecurePreferences.getFCMToken(this)
|
|
|
|
|
val userPublicKey = TextSecurePreferences.getLocalNumber(this) ?: return
|
|
|
|
|
LokiPushNotificationManager.register(token, userPublicKey, this, true)
|
|
|
|
|
}
|
|
|
|
|
}
|