diff --git a/vector/build.gradle b/vector/build.gradle index f7804bb5dc..62cc8eaae7 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -435,7 +435,7 @@ dependencies { // Unifiedpush implementation 'com.github.UnifiedPush:android-connector:1.1.3' - gplayImplementation 'com.github.UnifiedPush:android-embedded_fcm_distributor:1.0.2' + gplayImplementation 'com.github.UnifiedPush:android-embedded_fcm_distributor:1.1.0' // OSS License, gplay flavor only gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' diff --git a/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt b/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt index 6462bcf3c8..6910c0ae0c 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt @@ -70,7 +70,7 @@ class PushersManager @Inject constructor( private fun getPusherAppId(context: Context) : String { val appId = stringProvider.getString(R.string.pusher_app_id) return if (UPHelper.isEmbeddedDistributor(context)) { - "${appId}.fcm" + appId } else "${appId}.up" } 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 c9fa4bfca1..a50a4b6f4e 100755 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -94,13 +94,30 @@ val upHandler = object: MessagingReceiverHandler { lateinit var data: JSONObject lateinit var notification: JSONObject - try { - data = JSONObject(message) - notification = data.getJSONObject("notification") - } catch (e: JSONException) { - Timber.e(e) - return + if (UPHelper.isEmbeddedDistributor(context)) { + try { + notification = JSONObject(message) + } catch (e: JSONException) { + Timber.e(e) + return + } + } else { + try { + data = JSONObject(message) + notification = data.getJSONObject("notification") + } catch (e: JSONException) { + Timber.e(e) + return + } + try { + notification.put("unread", + notification.getJSONObject("count").getInt("unread")) + } catch (e: JSONException) { + Timber.i("No unread on notification") + notification.put("unread", 0) + } } + val eventId: String = try { notification.getString("event_id") } catch (e: JSONException) { @@ -108,6 +125,7 @@ val upHandler = object: MessagingReceiverHandler { notification.put("event_id", "") "" } + try { notification.getString("room_id") } catch (e: JSONException) { @@ -191,7 +209,7 @@ val upHandler = object: MessagingReceiverHandler { } // update the badge counter - val unreadCount = data.getJSONObject("counts").getInt("unread") + val unreadCount = data.getInt("unread") BadgeProxy.updateBadgeCount(context, unreadCount) val session = activeSessionHolder.getSafeActiveSession()