use of com.onesignal.NotificationBundleProcessor.ProcessedBundleResult in project OneSignal-Android-SDK by OneSignal.
the class GcmBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
// Google Play services started sending an extra non-ordered broadcast with the bundle:
// { "COM": "RST_FULL", "from": "google.com/iid" }
// Result codes are not valid with non-ordered broadcasts so omit it to prevent errors to the logcat.
Bundle bundle = intent.getExtras();
if (bundle == null || "google.com/iid".equals(bundle.getString("from")))
return;
ProcessedBundleResult processedResult = processOrderBroadcast(context, intent, bundle);
// Null means this isn't a GCM / FCM message.
if (processedResult == null) {
setResultCode(Activity.RESULT_OK);
return;
}
// OR app developer setup a extender service to handle the notification.
if (processedResult.isDup || processedResult.hasExtenderService) {
// Abort to prevent other GCM receivers from process this Intent.
abortBroadcast();
return;
}
// AND the setting is enabled to allow filtering in this case.
if (processedResult.isOneSignalPayload && OneSignal.getFilterOtherGCMReceivers(context)) {
abortBroadcast();
return;
}
setResultCode(Activity.RESULT_OK);
}
use of com.onesignal.NotificationBundleProcessor.ProcessedBundleResult in project OneSignal-Android-SDK by OneSignal.
the class GcmBroadcastReceiver method processOrderBroadcast.
private static ProcessedBundleResult processOrderBroadcast(Context context, Intent intent, Bundle bundle) {
if (!isGcmMessage(intent))
return null;
ProcessedBundleResult processedResult = NotificationBundleProcessor.processBundle(context, bundle);
// Return if the notification will NOT be handled by normal GcmIntentService display flow.
if (processedResult.processed())
return processedResult;
Intent intentForService = new Intent();
intentForService.putExtra("json_payload", NotificationBundleProcessor.bundleAsJSONObject(bundle).toString());
intentForService.putExtra("timestamp", System.currentTimeMillis() / 1000L);
intentForService.setComponent(new ComponentName(context.getPackageName(), GcmIntentService.class.getName()));
startWakefulService(context, intentForService);
return processedResult;
}
use of com.onesignal.NotificationBundleProcessor.ProcessedBundleResult in project OneSignal-Android-SDK by OneSignal.
the class FCMBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
// Do not process token update messages here.
// They are also non-ordered broadcasts.
Bundle bundle = intent.getExtras();
if (bundle == null || "google.com/iid".equals(bundle.getString("from")))
return;
OneSignal.initWithContext(context);
NotificationBundleProcessor.ProcessBundleReceiverCallback bundleReceiverCallback = new NotificationBundleProcessor.ProcessBundleReceiverCallback() {
@Override
public void onBundleProcessed(@Nullable ProcessedBundleResult processedResult) {
// Null means this isn't a FCM message
if (processedResult == null) {
setSuccessfulResultCode();
return;
}
// 2. OR work manager is processing the notification
if (processedResult.isDup() || processedResult.isWorkManagerProcessing()) {
// Abort to prevent other FCM receivers from process this Intent.
setAbort();
return;
}
setSuccessfulResultCode();
}
};
processOrderBroadcast(context, intent, bundle, bundleReceiverCallback);
}
Aggregations