embedded distrib: original gateway
This commit is contained in:
parent
09b290e579
commit
4a8fa4a3ce
|
@ -435,7 +435,7 @@ dependencies {
|
||||||
|
|
||||||
// Unifiedpush
|
// Unifiedpush
|
||||||
implementation 'com.github.UnifiedPush:android-connector:1.1.3'
|
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
|
// OSS License, gplay flavor only
|
||||||
gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
|
gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PushersManager @Inject constructor(
|
||||||
private fun getPusherAppId(context: Context) : String {
|
private fun getPusherAppId(context: Context) : String {
|
||||||
val appId = stringProvider.getString(R.string.pusher_app_id)
|
val appId = stringProvider.getString(R.string.pusher_app_id)
|
||||||
return if (UPHelper.isEmbeddedDistributor(context)) {
|
return if (UPHelper.isEmbeddedDistributor(context)) {
|
||||||
"${appId}.fcm"
|
appId
|
||||||
} else
|
} else
|
||||||
"${appId}.up"
|
"${appId}.up"
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,14 @@ val upHandler = object: MessagingReceiverHandler {
|
||||||
|
|
||||||
lateinit var data: JSONObject
|
lateinit var data: JSONObject
|
||||||
lateinit var notification: JSONObject
|
lateinit var notification: JSONObject
|
||||||
|
if (UPHelper.isEmbeddedDistributor(context)) {
|
||||||
|
try {
|
||||||
|
notification = JSONObject(message)
|
||||||
|
} catch (e: JSONException) {
|
||||||
|
Timber.e(e)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
data = JSONObject(message)
|
data = JSONObject(message)
|
||||||
notification = data.getJSONObject("notification")
|
notification = data.getJSONObject("notification")
|
||||||
|
@ -101,6 +109,15 @@ val upHandler = object: MessagingReceiverHandler {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
return
|
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 {
|
val eventId: String = try {
|
||||||
notification.getString("event_id")
|
notification.getString("event_id")
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
|
@ -108,6 +125,7 @@ val upHandler = object: MessagingReceiverHandler {
|
||||||
notification.put("event_id", "")
|
notification.put("event_id", "")
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
notification.getString("room_id")
|
notification.getString("room_id")
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
|
@ -191,7 +209,7 @@ val upHandler = object: MessagingReceiverHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the badge counter
|
// update the badge counter
|
||||||
val unreadCount = data.getJSONObject("counts").getInt("unread")
|
val unreadCount = data.getInt("unread")
|
||||||
BadgeProxy.updateBadgeCount(context, unreadCount)
|
BadgeProxy.updateBadgeCount(context, unreadCount)
|
||||||
|
|
||||||
val session = activeSessionHolder.getSafeActiveSession()
|
val session = activeSessionHolder.getSafeActiveSession()
|
||||||
|
|
Loading…
Reference in New Issue