This commit is contained in:
andrew
2023-08-03 14:14:55 +09:30
parent 41d24ef2c3
commit cc6f880665
6 changed files with 131 additions and 108 deletions

View File

@@ -31,16 +31,17 @@ class HuaweiPushManager @Inject constructor(
if (force) cancel() else if (isActive) return
}
val appId = "107146885"
val appId = "107205081"
val tokenScope = "HCM"
val hmsInstanceId = HmsInstanceId.getInstance(context)
genericPushManager.refresh(TextSecurePreferences.getFCMToken(context), force)
MainScope().launch(Dispatchers.IO) {
val token = hmsInstanceId.getToken(appId, tokenScope)
Log.d(TAG, "refresh() with huawei token: $token")
genericPushManager.refresh(token, force)
Log.d(TAG, "refresh() hmsInstanceId => huawei token: $token")
//
//// genericPushManager.refresh(token, force)
}
}
}

View File

@@ -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.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.utilities.Log
import java.lang.Exception
import javax.inject.Inject
@@ -40,6 +41,10 @@ class HuaweiPushNotificationService: HmsMessageService() {
override fun onNewToken(token: String?, bundle: Bundle?) {
Log.d("pnh", "New HCM token: $token.")
if (token == TextSecurePreferences.getFCMToken(this)) return
TextSecurePreferences.setFCMToken(this, token)
pushManager.refresh(true)
}
override fun onMessageReceived(message: RemoteMessage?) {

View File

@@ -80,7 +80,7 @@
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=107146885">
android:value="appid=107205081">
</meta-data>
<meta-data

View File

@@ -24,9 +24,10 @@ class GenericPushManager @Inject constructor(
private val tokenManager: FcmTokenManager,
private val pushManagerV2: PushManagerV2,
) {
fun refresh(token: String, force: Boolean): Promise<*, Exception> {
Log.d(TAG, "refresh() called")
fun refresh(token: String?, force: Boolean): Promise<*, Exception> {
Log.d(TAG, "refresh($token, $force) called")
token ?: return emptyPromise()
val userPublicKey = TextSecurePreferences.getLocalNumber(context) ?: return emptyPromise()
val userEdKey = KeyPairUtilities.getUserED25519KeyPair(context) ?: return emptyPromise()
@@ -62,6 +63,11 @@ class GenericPushManager @Inject constructor(
userEd25519Key: KeyPair,
namespaces: List<Int> = listOf(Namespace.DEFAULT)
): Promise<*, Exception> {
android.util.Log.d(
TAG,
"register() called with: token = $token, publicKey = $publicKey, userEd25519Key = $userEd25519Key, namespaces = $namespaces"
)
val v1 = PushManagerV1.register(
device = device,
token = token,