diff --git a/vector-app/src/gplay/AndroidManifest.xml b/vector-app/src/gplay/AndroidManifest.xml index a5f0eae6be..3aa6fbcb2b 100755 --- a/vector-app/src/gplay/AndroidManifest.xml +++ b/vector-app/src/gplay/AndroidManifest.xml @@ -8,18 +8,12 @@ android:name="firebase_analytics_collection_deactivated" android:value="true" /> - - + - - + - - - + diff --git a/vector/build.gradle b/vector/build.gradle index 65adc7089c..a5538053fc 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -257,7 +257,7 @@ dependencies { // UnifiedPush implementation 'com.github.UnifiedPush:android-connector:2.0.1' // UnifiedPush gplay flavor only - gplayImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.1.3') { + gplayImplementation('com.google.firebase:firebase-messaging:23.0.8') { exclude group: 'com.google.firebase', module: 'firebase-core' exclude group: 'com.google.firebase', module: 'firebase-analytics' exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' diff --git a/vector/src/fdroid/AndroidManifest.xml b/vector/src/fdroid/AndroidManifest.xml index 29dac6533e..15db89ca13 100644 --- a/vector/src/fdroid/AndroidManifest.xml +++ b/vector/src/fdroid/AndroidManifest.xml @@ -28,20 +28,6 @@ android:enabled="true" android:exported="false" /> - - - - - - - ).toString().toByteArray()) + intent.putExtra(EXTRA_TOKEN, fcmHelper.getFcmToken()) + baseContext.sendBroadcast(intent) + } +} diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index c4022576c3..29eef172ae 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -423,6 +423,20 @@ + + + + + + + diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/receiver/KeepInternalDistributor.kt b/vector/src/main/java/im/vector/app/core/pushers/KeepInternalDistributor.kt similarity index 96% rename from vector/src/fdroid/java/im/vector/app/fdroid/receiver/KeepInternalDistributor.kt rename to vector/src/main/java/im/vector/app/core/pushers/KeepInternalDistributor.kt index 3feee8c63b..63725f01a3 100644 --- a/vector/src/fdroid/java/im/vector/app/fdroid/receiver/KeepInternalDistributor.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/KeepInternalDistributor.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.fdroid.receiver +package im.vector.app.core.pushers import android.content.BroadcastReceiver import android.content.Context diff --git a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt index 8e88e44627..ec7cb50732 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -46,6 +46,8 @@ import org.matrix.android.sdk.api.logger.LoggerTag import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.getRoom import org.matrix.android.sdk.api.session.room.getTimelineEvent +import org.unifiedpush.android.connector.EXTRA_BYTES_MESSAGE +import org.unifiedpush.android.connector.EXTRA_TOKEN import org.unifiedpush.android.connector.MessagingReceiver import timber.log.Timber import javax.inject.Inject @@ -60,6 +62,7 @@ class VectorMessagingReceiver : MessagingReceiver() { @Inject lateinit var notificationDrawerManager: NotificationDrawerManager @Inject lateinit var notifiableEventResolver: NotifiableEventResolver @Inject lateinit var pushersManager: PushersManager + @Inject lateinit var fcmHelper: FcmHelper @Inject lateinit var activeSessionHolder: ActiveSessionHolder @Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var vectorDataStore: VectorDataStore @@ -166,6 +169,19 @@ class VectorMessagingReceiver : MessagingReceiver() { } } + override fun onReceive(context: Context, intent: Intent) { + // Injections happens here + super.onReceive(context, intent) + + // if it is from FirebaseReceiver, then the token has been rejected + if (unifiedPushHelper.isEmbeddedDistributor() + && intent.getStringExtra(EXTRA_TOKEN) == fcmHelper.getFcmToken()) { + intent.getByteArrayExtra(EXTRA_BYTES_MESSAGE)?.let { + onMessage(context, it, "") + } + } + } + /** * Internal receive method. *