diff --git a/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushManager.kt b/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushManager.kt
index 6e495357f3..87a78ef035 100644
--- a/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushManager.kt
+++ b/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushManager.kt
@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.notifications
import android.content.Context
+import android.util.Log
import com.huawei.hmf.tasks.Tasks
import com.huawei.hms.aaid.HmsInstanceId
import dagger.hilt.android.qualifiers.ApplicationContext
@@ -9,9 +10,12 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
+import org.session.libsession.utilities.TextSecurePreferences
import javax.inject.Inject
import javax.inject.Singleton
+private val TAG = HuaweiPushManager::class.java.name
+
@Singleton
class HuaweiPushManager @Inject constructor(
@ApplicationContext private val context: Context,
@@ -27,13 +31,16 @@ class HuaweiPushManager @Inject constructor(
if (force) cancel() else if (isActive) return
}
+ val appId = "107146885"
+ val tokenScope = "HCM"
val hmsInstanceId = HmsInstanceId.getInstance(context)
MainScope().launch(Dispatchers.IO) {
- val task = hmsInstanceId.aaid
- Tasks.await(task)
- if (!isActive) return@launch // don't 'complete' task if we were canceled
- task.result?.id?.let { genericPushManager.refresh(it, force) }
+ val token = hmsInstanceId.getToken(appId, tokenScope)
+
+ Log.d(TAG, "refresh() with huawei token: $token")
+
+ genericPushManager.refresh(token, force)
}
}
}
diff --git a/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushNotificationService.kt b/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushNotificationService.kt
index 507787123c..7dae82dd30 100644
--- a/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushNotificationService.kt
+++ b/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushNotificationService.kt
@@ -5,18 +5,45 @@ import com.huawei.hms.push.HmsMessageService
import com.huawei.hms.push.RemoteMessage
import dagger.hilt.android.AndroidEntryPoint
import org.session.libsignal.utilities.Log
+import java.lang.Exception
import javax.inject.Inject
@AndroidEntryPoint
class HuaweiPushNotificationService: HmsMessageService() {
+ init {
+ Log.d("pnh", "init Huawei Service")
+ }
+
@Inject lateinit var pushManager: PushManager
@Inject lateinit var pushHandler: PushHandler
+
+ override fun onCreate() {
+ Log.d("pnh", "onCreate Huawei Service")
+ super.onCreate()
+ }
+
+ override fun onMessageDelivered(p0: String?, p1: Exception?) {
+ Log.d("pnh", "onMessageDelivered")
+ super.onMessageDelivered(p0, p1)
+ }
+
+ override fun onMessageSent(p0: String?) {
+ Log.d("pnh", "onMessageSent")
+ super.onMessageSent(p0)
+ }
+
+ override fun onNewToken(p0: String?) {
+ Log.d("pnh", "onNewToken")
+ super.onNewToken(p0)
+ }
+
override fun onNewToken(token: String?, bundle: Bundle?) {
- Log.d("Loki", "New HCM token: $token.")
+ Log.d("pnh", "New HCM token: $token.")
pushManager.refresh(true)
}
override fun onMessageReceived(message: RemoteMessage?) {
+ Log.d("pnh", "onMessageReceived: $message.")
pushHandler.onPush(message?.dataOfMap)
}
override fun onDeletedMessages() {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cc63ab6a87..d6bed361e5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -78,6 +78,16 @@
android:theme="@style/Theme.Session.DayNight"
tools:replace="android:allowBackup">
+
+
+
+
+
+