-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing kv pairs properties #219
base: master
Are you sure you want to change the base?
Conversation
* Determine if the message is bearing key-value pairs | ||
*/ | ||
val RemoteMessage.hasKlaviyoKeyValuePairs: Boolean | ||
get() = this.isKlaviyoMessage && (this.data[KlaviyoNotification.KEY_VALUE_PAIRS_KEY]?.let { true } ?: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.data.containsKey(KlaviyoNotification.KEY_VALUE_PAIRS_KEY)
probs cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't I have to wrap everything in an if/else then too? (the let
statement no longer works)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need the let i mean, it should just return a bool of whether that key is present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as val RemoteMessage.isKlaviyoMessage: Boolean get() = this.data.containsKey("_k")
elsewhere in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oo oops I was looking at the wrong method* (RemoteMessage.keyValuePairs) this makes more sense
/** | ||
* Parse out the key-value pairs into a string:string map | ||
*/ | ||
val RemoteMessage.keyValuePairs: Map<String,String>? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we have a gap in our test coverage, this file has no corresponding test file. Would you mind adding a file in the same dir as KlaviyoPushServiceTest
to cover your changes, and we'll backfill tests for other stuff in the future.
Description
Added two new extension properties to
RemoteMessage
s:hasKlaviyoKeyValuePairs
which is a boolean (true
if message payloads contain kv-pairs,false
otherwise)keyValuePairs
optionalMap<String,String>
which is the dictionary of kv-pairs itself (deserialized from json)Check List
No.
How can I do this?
Changelog / Code Overview
Test Plan
onSilentPushMessageReceived
method)Related Issues/Tickets