Skip to content

Commit

Permalink
embedded distrib: original gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Jun 30, 2021
1 parent 09b290e commit 4a8fa4a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,38 @@ 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) {
Timber.i("No event_id on notification")
notification.put("event_id", "")
""
}

try {
notification.getString("room_id")
} catch (e: JSONException) {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4a8fa4a

Please sign in to comment.