Skip to content

Commit fe34de7

Browse files
committed
Prevents NPE while processing a Push notification data
1 parent dd05419 commit fe34de7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

android/src/main/kotlin/com/exponea/ExponeaPushReceiver.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ class ExponeaPushReceiver : BroadcastReceiver() {
2727

2828
val actionInfo = intent.getSerializableExtra(ExponeaExtras.EXTRA_ACTION_INFO) as? NotificationAction
2929
val url = actionInfo?.url
30-
val pushData = intent.getSerializableExtra(ExponeaExtras.EXTRA_CUSTOM_DATA) as Map<String, String>
31-
val additionalDataType = object : TypeToken<Map<String, Any?>?>() {}.getType()
32-
val additionalData = Gson().fromJson(pushData["attributes"], additionalDataType) as Map<String, Any?>?
30+
val pushData = intent.getSerializableExtra(ExponeaExtras.EXTRA_CUSTOM_DATA) as? Map<String, String>
31+
val additionalData = pushData?.let {
32+
val additionalDataType = object : TypeToken<Map<String, Any?>?>() {}.getType()
33+
Gson().fromJson(it["attributes"], additionalDataType) as? Map<String, Any?>
34+
}
3335
OpenedPushStreamHandler.handle(OpenedPush(action, url, additionalData))
3436
}
3537
}

example/android/app/src/main/kotlin/com/exponea/example/MainApplication.java

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)