Handle callbacks for push notification actions.
We send custom intents when push notifications are received, opened, or dismissed.
If you have a specific use case for these scenarios, you will need to make a listener for these intents by creating a custom BroadcastReceiver.
@Override
public void ocambaNewToken(String token, Context context) {
//new token received
}
@Override
public void ocambaNotificationUser(RemoteMessage remoteMessage, Context context) {
//users notification received
if (remoteMessage.getNotification() != null) {
Log.i(TAG, "Title: " + remoteMessage.getNotification().getTitle()); Log.i(TAG, "Text: " + remoteMessage.getNotification().getBody());
}
}
@Override
public void ocambaNotificationReceived(OcambaNotificationObject message, Context context) {
//ocamba notification received
Log.i(TAG, "Ocamba Received Notification: " + message.getObject());
}
@Override
public void ocambaNotificationClick(OcambaNotificationObject message, Context context) {
//ocamba notification clicked
Log.i(TAG, "Ocamba Received Notification: " + message.getObject());
}
@Override
public void ocambaNotificationDismissed(Context context) {
//ocamba notification dismissed
}
@Override
public void ocambaNotificationActionButtons(String action, Context context{
//ocamba notification action buttons
}
@Override
public void ocambaNotificationCustomAction(String action, Context context){
//ocamba notification custom data
}
@Override
public void ocambaNotificationMultiMessageReceived(ArrayList<OcambaNotificationObject> multiMessageList, Context context) {
//multimessage received
}
Add Broadcast Receiver to application tags in AndroidManifest.xml:
<receiver android:name=".BroadcastReceiverTest" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name= "PACKAGE_NAME.OCAMBA_NOTIFICATION_CLICK" />
<action android:name= "PACKAGE_NAME.OCAMBA_NOTIFICATION_RECEIVED" />
<action android:name= "PACKAGE_NAME.OCAMBA_NOTIFICATION_TOKEN" />
<action android:name= "PACKAGE_NAME.OCAMBA_NOTIFICATION_USER" />
<action android:name="PACKAGE_NAME.OCAMBA_NOTIFICATION_ACTION_BUTTONS"/>
<action android:name= "PACKAGE_NAME. OCAMBA_NOTIFICATION_CUSTOM_ACTION" />
<action android:name= "PACKAGE_NAME.OCAMBA_NOTIFICATION_DISMISSED" />
<action android:name="PACKAGE_NAME.OCAMBA_NOTIFICATION_MULTI_MESSAGE_RECEIVED" />
</intent-filter>
</receiver>
NOTE: rename BroadcastReceiverTest with your receiver name and add package name before it (do not use ${applicationId}).
NOTE: From android 12 there is notification trampoline restriction - this means that we need to open default activity before we open browser. On previous version we do it from broadcast receiver.
Your feedback helps us improve our docs.