diff --git a/apps/multiplatform/android/src/main/AndroidManifest.xml b/apps/multiplatform/android/src/main/AndroidManifest.xml
index d6059896a5..b226d2709f 100644
--- a/apps/multiplatform/android/src/main/AndroidManifest.xml
+++ b/apps/multiplatform/android/src/main/AndroidManifest.xml
@@ -186,6 +186,13 @@
android:foregroundServiceType="mediaPlayback|microphone|camera|remoteMessaging"
/>
+
+
+
+
+
+
onVerification(pn.verification)
+ }
+ // TODO: Start same job than the periodic service ?
+ // Receiving the push notif is enough to wake the app and fetch msgs
+ // But it may not be enough when the phone is in doze, or with some
+ // vendors
+ }
+
+ override fun onNewEndpoint(endpoint: PushEndpoint, instance: String) {
+ Log.d(TAG, "onNewEndpoint")
+ endpoint.pubKeySet ?: run {
+ // Should not happen
+ Log.w(TAG, "Missing pubKeySet")
+ return
+ }
+ CoroutineScope(Dispatchers.Default).launch {
+ chatModel.controller.sendCmd(
+ null,
+ CC.APIRegisterWebPush(endpoint.url, endpoint.pubKeySet!!.auth, endpoint.pubKeySet!!.pubKey),
+ log = true
+ )
+ }
+ }
+
+ override fun onRegistrationFailed(reason: FailedReason, instance: String) {
+ Log.d(TAG, "onRegistrationFailed: $reason")
+ // TODO: notification to inform about failed registration
+ }
+
+ override fun onUnregistered(instance: String) {
+ Log.d(TAG, "onUnregistered")
+ // TODO: notification to inform about unregistration
+ CoroutineScope(Dispatchers.Default).launch {
+ chatModel.controller.sendCmd(
+ null,
+ CC.APIDeleteSavedNtf(),
+ log = true
+ )
+ }
+ }
+
+ companion object {
+ private const val TAG = "PushService"
+ }
+}
\ No newline at end of file
diff --git a/apps/multiplatform/android/src/main/java/chat/simplex/app/platform/PushManager.kt b/apps/multiplatform/android/src/main/java/chat/simplex/app/platform/PushManager.kt
index fe64afc633..f5f78233a6 100644
--- a/apps/multiplatform/android/src/main/java/chat/simplex/app/platform/PushManager.kt
+++ b/apps/multiplatform/android/src/main/java/chat/simplex/app/platform/PushManager.kt
@@ -55,7 +55,7 @@ object PushManager {
showSelectPushServiceDialog(context, distributors) {
UnifiedPush.saveDistributor(context, it)
register(context)
- onSuccess
+ onSuccess()
}
}
}
@@ -202,4 +202,4 @@ object PushManager {
} as String
}
-}
\ No newline at end of file
+}
diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt
index 7b4c6914da..99240edd64 100644
--- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt
+++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt
@@ -3717,6 +3717,9 @@ sealed class CC {
class ResetAgentServersStats(): CC()
class GetAgentSubsTotal(val userId: Long): CC()
class GetAgentServersSummary(val userId: Long): CC()
+ class APIRegisterWebPush(val endpoint: String, val auth: String, val p256dh: String): CC()
+ class APIVerifySavedNtf(val code: String): CC()
+ class APIDeleteSavedNtf(): CC()
val cmdString: String get() = when (this) {
is Console -> cmd
@@ -3919,6 +3922,9 @@ sealed class CC {
is ResetAgentServersStats -> "/reset servers stats"
is GetAgentSubsTotal -> "/get subs total $userId"
is GetAgentServersSummary -> "/get servers summary $userId"
+ is APIRegisterWebPush -> "/_ntf register webpush $endpoint $auth $p256dh INSTANT"
+ is APIDeleteSavedNtf -> "/_ntf delete saved"
+ is APIVerifySavedNtf -> "/_ntf verify $code"
}
val cmdType: String get() = when (this) {
@@ -4087,6 +4093,9 @@ sealed class CC {
is ResetAgentServersStats -> "resetAgentServersStats"
is GetAgentSubsTotal -> "getAgentSubsTotal"
is GetAgentServersSummary -> "getAgentServersSummary"
+ is APIRegisterWebPush -> "apiRegisterWebPush"
+ is APIDeleteSavedNtf -> "apiDeleteSavedNtf"
+ is APIVerifySavedNtf -> "apiVerifySavedNtf"
}
data class ItemRange(val from: Long, val to: Long)
diff --git a/cabal.project b/cabal.project
index 0452f09216..f20fd0fdb5 100644
--- a/cabal.project
+++ b/cabal.project
@@ -11,8 +11,13 @@ constraints: zip +disable-bzip2 +disable-zstd
source-repository-package
type: git
- location: https://github.com/simplex-chat/simplexmq.git
- tag: 54a2a6c9051f610b8c7533369d9e9cce81af06ad
+ location: https://github.com/p1gp1g/simplexmq.git
+ tag: 15154ef75168f115e54220c8f906c30bab071eae
+
+-- source-repository-package
+-- type: git
+-- location: https://github.com/simplex-chat/simplexmq.git
+-- tag: 54a2a6c9051f610b8c7533369d9e9cce81af06ad
source-repository-package
type: git
diff --git a/scripts/nix/sha256map.nix b/scripts/nix/sha256map.nix
index 1ef1b2f51f..f6f560f571 100644
--- a/scripts/nix/sha256map.nix
+++ b/scripts/nix/sha256map.nix
@@ -1,4 +1,5 @@
{
+ "https://github.com/p1gp1g/simplexmq.git"."15154ef75168f115e54220c8f906c30bab071eae" = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
"https://github.com/simplex-chat/simplexmq.git"."54a2a6c9051f610b8c7533369d9e9cce81af06ad" = "02c6hh5vffm23gz2gkn6rq2ifcyj5c9s6kz0kyk055i78gsfhp43";
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
"https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d";