mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-31 03:16:05 +00:00
Add notifications for UnifiedPush unregistrations/failures
This commit is contained in:
@@ -3,6 +3,9 @@ package chat.simplex.app
|
||||
import chat.simplex.common.model.CC
|
||||
import chat.simplex.common.platform.Log
|
||||
import chat.simplex.common.platform.chatModel
|
||||
import chat.simplex.common.platform.ntfManager
|
||||
import chat.simplex.common.views.helpers.generalGetString
|
||||
import chat.simplex.res.MR
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
@@ -58,12 +61,22 @@ class PushService: PushService() {
|
||||
|
||||
override fun onRegistrationFailed(reason: FailedReason, instance: String) {
|
||||
Log.d(TAG, "onRegistrationFailed: $reason")
|
||||
// TODO: notification to inform about failed registration
|
||||
val title = generalGetString(MR.strings.icon_descr_instant_notifications)
|
||||
val text = when (reason) {
|
||||
FailedReason.NETWORK -> generalGetString(MR.strings.unifiedpush_registration_failed_network)
|
||||
FailedReason.VAPID_REQUIRED, // Should not happen, VAPID will be required
|
||||
FailedReason.INTERNAL_ERROR -> generalGetString(MR.strings.unifiedpush_registration_failed_unknown)
|
||||
FailedReason.ACTION_REQUIRED -> generalGetString(MR.strings.unifiedpush_registration_failed_action)
|
||||
|
||||
}
|
||||
ntfManager.showMessage(title, text)
|
||||
}
|
||||
|
||||
override fun onUnregistered(instance: String) {
|
||||
Log.d(TAG, "onUnregistered")
|
||||
// TODO: notification to inform about unregistration
|
||||
val title = generalGetString(MR.strings.icon_descr_instant_notifications)
|
||||
val text = generalGetString(MR.strings.unifiedpush_unregistered)
|
||||
ntfManager.showMessage(title, text)
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
chatModel.controller.sendCmd(
|
||||
null,
|
||||
|
||||
@@ -230,6 +230,9 @@ object NtfManager {
|
||||
val builder = NotificationCompat.Builder(context, MessageChannel)
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setStyle(
|
||||
NotificationCompat.BigTextStyle().bigText(text)
|
||||
)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setGroup(MessageGroup)
|
||||
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
|
||||
|
||||
@@ -293,6 +293,10 @@
|
||||
<string name="warning_push_needs_push_service">You don\'t have any push service installed on your device.\n\nPlease installed one and try again.\n\nFor more information, visit\ </string>
|
||||
<string name="select_push_service">Select Push Service</string>
|
||||
<string name="select_push_service_intro">Multiple push services are installed on your system, please select the service you wish to use.</string>
|
||||
<string name="unifiedpush_unregistered">SimpleX is no longer registered with your UnifiedPush distributor. The distributor may have been uninstalled or been logged out. You should reset your notifications settings.</string>
|
||||
<string name="unifiedpush_registration_failed_network">Registration with your UnifiedPush distributor failed due to a network issue. Please try again when your network is back.</string>
|
||||
<string name="unifiedpush_registration_failed_action">Registration with your UnifiedPush distributor failed due to a missing requirement from your distributor.</string>
|
||||
<string name="unifiedpush_registration_failed_unknown">Registration with your UnifiedPush distributor failed due to an unknown issue. This could be a missing requirement from your distributor.</string>
|
||||
|
||||
<!-- local authentication notice - SimpleXAPI.kt -->
|
||||
<string name="la_notice_title_simplex_lock">SimpleX Lock</string>
|
||||
|
||||
Reference in New Issue
Block a user