public abstract class PushNotificationReceiver
extends android.content.BroadcastReceiver
This class handles clicks on a notification received by PushNotificationClickedActivity
while the application is in the background as well as notifications received directly by the
application via EpiMessagingService.onMessageReceived(RemoteMessage)
.
You have to inherit from this class to implement how to react to notifications.
Usually, the inheriting class loads the activity triggered by the push notification
and optionally calls the tracking URL.
Add this receiver declaration to your AndroidManifest.xml
:
<receiver android:name=".YourInheritedClassName" android:enabled="true" android:exported="true" > <intent-filter> <action android:name="your.packagename.NOTIFICATION_CLICKED" /> <action android:name="your.packagename.NOTIFICATION_RECEIVED" /> </intent-filter> </receiver> Replace your.packagename in the above declaration to match the value of the property "package_name" in your google-services.json. Note, that in case you plan to ship two different apps with this SDK you should choose different package names.
Constructor and Description |
---|
PushNotificationReceiver() |
Modifier and Type | Method and Description |
---|---|
void |
onNotificationClicked(android.content.Context context,
PushMessage message)
This method handles a click on a notification.
|
void |
onNotificationReceived(android.content.Context context,
PushMessage message)
This method handles a notification received while the application is in the foreground.
|
void |
onReceive(android.content.Context context,
android.content.Intent intent)
This method handles a click on a notification or a notification received while the
application is in the foreground and calls the
onNotificationClicked(Context, PushMessage) or
onNotificationReceived(Context, PushMessage) method. |
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
public void onReceive(android.content.Context context, android.content.Intent intent)
onNotificationClicked(Context, PushMessage)
or
onNotificationReceived(Context, PushMessage)
method.onReceive
in class android.content.BroadcastReceiver
context
- Application contextintent
- The intent for the action com.episerver.sdk.push.NOTIFICATION_CLICKED
or com.episerver.sdk.push.NOTIFICATION_RECEIVED
.public void onNotificationClicked(android.content.Context context, PushMessage message)
This method handles a click on a notification. You have to implement this method to react on the click.
Depending on the message delivered in the parameter message
, the click on a
notification usually opens an action.
To track the click on a notification, invoke EpiSdk.trackOpen(Context, PushMessage)
.
context
- Application contextmessage
- Push message which has been clicked onpublic void onNotificationReceived(android.content.Context context, PushMessage message)
This method handles a notification received while the application is in the foreground. You have to implement this method to react on the notification.
Depending on the message delivered in the parameter message
, you could update
your app, open a specific activity, show a custom notification or simply discard the message,
i.e. just not doing anything.
To track the reception of the notification, invoke EpiSdk.trackOpen(Context, PushMessage)
.
context
- Application contextmessage
- Push message which has been received while the app is in the foreground