Notification Center
Controlling Notification Center
If the host app wishes to get notified about the Push Notification Ads and Push Notification Events (VIEWED, CLOSED_NOTIFICATION and CLICK) to display in the Apps Notification Center, they can subscribe to the listener as the example below:
public class MainAplication extends Application implements OTAPromotionReceiverListener, NotificationsListener {
@Override
public void onCreate() {
super.onCreate();
// ...
// Listener to receive push notification ads
IUApp.addOTAPromotionReceiverListener(this);
// Listener to receive the push notification events
IUApp.addNotificationListener(this);
}
@Override
public void onOTAPromotionReceived(OtaPromotion otaPromotion) {
// ...
}
@Override
public void onNotificationActionDismiss(String s, OtaEvent.Type type) {
// ...
}
}
Note:
Leaving the app without unsubscribe might cause crash due to Null pointers.
To unsubscribe from OTAPromotionReceiverListener
and NotificationListener
, you can call the methods as below:
// Unsubscribe from OTAPromotionReceiverListener
IUApp.removeOTAPromotionReceiverListener(OTAPromotionReceiverListener otaPromotionListener);
// Unsubscribe from NotificationListener
IUApp.removeNotificationListener(NotificationsListener notificationListener);
Send event (Optional)
If the host app wishes to synchronize the actions between notification center and device's notification center, the method below should be used to send informations about campaigns' events to DR SDK.
// <EVENT> receives one of the following values: VIEWED, CLOSED_NOTIFICATION or CLICK
// adId comes from method onOTAPromotionReceived
IUApp.sendEvent(context, adId, OtaEvent.Type.<EVENT>);
Updated about 2 years ago