Skip to content

Add null checking for push raw data #261

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ public void onReceive(Context context, Intent intent) {
* An {@code Intent} containing the channel and data of the current push notification.
*/
protected void onPushReceive(Context context, Intent intent) {
String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA);
if (pushDataStr == null) {
PLog.e(TAG, "Can not get push data from intent.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Can not get/Unable to read/g

return;
}

JSONObject pushData = null;
try {
pushData = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA));
pushData = new JSONObject(pushDataStr);
} catch (JSONException e) {
PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
}
Expand Down