diff --git a/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushService.kt b/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushService.kt index fb4e262560..dc7bf893d7 100644 --- a/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushService.kt +++ b/app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiPushService.kt @@ -4,6 +4,7 @@ import android.os.Bundle import com.huawei.hms.push.HmsMessageService import com.huawei.hms.push.RemoteMessage import dagger.hilt.android.AndroidEntryPoint +import org.json.JSONException import org.session.libsession.utilities.TextSecurePreferences import org.session.libsignal.utilities.Base64 import org.session.libsignal.utilities.Log @@ -17,13 +18,9 @@ class HuaweiPushService: HmsMessageService() { @Inject lateinit var pushRegistry: PushRegistry @Inject lateinit var pushReceiver: PushReceiver - override fun onCreate() { - Log.d(TAG, "onCreate Huawei Service") - super.onCreate() - } - override fun onMessageReceived(message: RemoteMessage?) { - Log.d(TAG, "onMessageReceived: $message.") + Log.d(TAG, "onMessageReceived") + message?.dataOfMap?.takeIf { it.isNotEmpty() }?.let(pushReceiver::onPush) ?: pushReceiver.onPush(message?.data?.let(Base64::decode)) } @@ -33,10 +30,11 @@ class HuaweiPushService: HmsMessageService() { override fun onNewToken(token: String?, bundle: Bundle?) { Log.d(TAG, "New HCM token: $token.") - onNewToken(token) + pushRegistry.register(token) } override fun onDeletedMessages() { - pushRegistry.refresh(true) + Log.d(TAG, "onDeletedMessages") + pushRegistry.refresh(false) } }