Skip to content
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

Added result to GCM broadcast aborts #642

Merged
merged 2 commits into from
Oct 5, 2018
Merged
Changes from 1 commit
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 @@ -73,7 +73,7 @@ public void onReceive(Context context, Intent intent) {

// Null means this isn't a GCM / FCM message.
if (processedResult == null) {
setResult(Activity.RESULT_OK);
setSuccessfulResultCode();
return;
}

Expand All @@ -95,17 +95,27 @@ public void onReceive(Context context, Intent intent) {
return;
}

setResult(Activity.RESULT_OK);
setSuccessfulResultCode();
}

private void setResult(int code) {
private void setSuccessfulResultCode() {
if (isOrderedBroadcast())
setResultCode(code);
setResultCode(Activity.RESULT_OK);
}

private void setAbort() {
if (isOrderedBroadcast())
if (isOrderedBroadcast()) {
// Prevents other BroadcastReceivers from firing
abortBroadcast();

// RESULT_OK prevents the following confusing logcat entry;
// W/GCM: broadcast intent callback: result=CANCELLED forIntent {
// act=com.google.android.c2dm.intent.RECEIVE
// flg=0x10000000
// pkg=com.onesignal.example (has extras)
// }
setResultCode(Activity.RESULT_OK);
}
}

private static ProcessedBundleResult processOrderBroadcast(Context context, Intent intent, Bundle bundle) {
Expand Down