Skip to content

Instantly share code, notes, and snippets.

@flurrydev
Created October 19, 2018 01:52
Show Gist options
  • Select an option

  • Save flurrydev/a4a7d88af171c93673cd1dd175f93104 to your computer and use it in GitHub Desktop.

Select an option

Save flurrydev/a4a7d88af171c93673cd1dd175f93104 to your computer and use it in GitHub Desktop.
/\*
\* This method will only be called whenever a Flurry notification is received, regardless of
\* whether app is in foreground or in background. To determine app
\* state, you can either track it yourself or call FlurryMessaging.isAppInForeground
\*/
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// determine if push is from Flurry
if (FlurryMessaging.isFlurryMessage(remoteMessage)) {
//retrieve flurry message
FlurryMessage flurryMessage = FlurryMessaging.convertFcmMessageToFlurryMessage(remoteMessage);
// log flurry message received event
FlurryMessaging.logNotificationReceived(flurryMessage);
if (FlurryMessaging.isAppInForeground()) {
// handle notification knowing app is in foreground
} else {
// handle notification knowing app is in background
}
/\*\*
\* IMPORTANT:
\* When creating a notification, you may use the Flurry helper method FlurryMessaging.showNotification()
\* or create your own. If you use the Flurry helper method, Flurry will automatically
\* log the click and dismissed notification events. In the event that the notification is clicked,
\* Flurry will launch the launcher or "click_action" activity with the Intent.FLAG_ACTIVITY_NEW_TASK flag.
\* If you choose to create your own notification, be sure to call FlurryMessaging.logNotificationClicked and
\* FlurryMessaging.logNotificationCancelled as the respective events occur.
\*
\* FlurryMessage is a Parcelable object and can be passed as an extra through intents.
\* Flurry provides helper methods to do so.
\* See - FlurryMessaging.addFlurryMessageToIntentExtras and FlurryMessaging.getFlurryMessageFromIntent
\*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment