Class BasePushService
-
- All Implemented Interfaces:
public abstract class BasePushService extends MobileService
Represents the base class for all the push related service.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumBasePushService.PushProviderpublic interfaceBasePushService.BackgroundNotificationInterceptorInterface to intercept push message when message in background. please note: the interceptor work only when enableAutoMessageHandling = true and if want to show a push message, pushNotificationEvent.displayNotification() must be called.
public interfaceBasePushService.ForegroundNotificationInterceptorInterface to intercept push message when message in foreground. please note: the interceptor work only when enableAutoMessageHandling = true if want to show a push message, pushNotificationEvent.displayNotification() must be called. or want to show push message on some conditions, pushNotificationEvent.displayNotificationWhen() must be called.
public final classBasePushService.PushNotificationEventA notification message corresponding to a PushNotificationEvent which decide the push message can be displayed or display on some conditions.
-
Field Summary
Fields Modifier and Type Field Description public final static StringNOTIFICATION_IDpublic final static StringNOTIFICATION_DATA_FROM_SERVERpublic final static StringNOTIFICATION_ID_FROM_SERVERpublic final static StringNOTIFICATION_TITLE_FROM_SERVERpublic final static StringNOTIFICATION_ALERT_FROM_SERVERpublic final static StringNOTIFICATION_CONDITIONpublic final static StringPERSISTED_STORE_FILE_NAMEprivate PushCallbackListenercallbackListenerprivate BooleanisEnableAutoMessageHandlingprivate BooleanisEnableBadgeMessageprivate NotificationChannelbadgeServiceChannelprivate BasePushService.ForegroundNotificationInterceptorforegroundNotificationInterceptorprivate BasePushService.BackgroundNotificationInterceptorbackgroundNotificationInterceptorprivate BasePushService.PushProviderpushProviderprivate Applicationapplicationprivate StringapiKey
-
Constructor Summary
Constructors Constructor Description BasePushService()
-
Method Summary
Modifier and Type Method Description final PushCallbackListenergetCallbackListener()final UnitsetCallbackListener(PushCallbackListener callbackListener)final BooleanisEnableAutoMessageHandling()Enable auto message handling. final UnitsetEnableAutoMessageHandling(Boolean isEnableAutoMessageHandling)Enable auto message handling. final BooleanisEnableBadgeMessage()final UnitsetEnableBadgeMessage(Boolean isEnableBadgeMessage)final NotificationChannelgetBadgeServiceChannel()final UnitsetBadgeServiceChannel(NotificationChannel badgeServiceChannel)final BasePushService.ForegroundNotificationInterceptorgetForegroundNotificationInterceptor()final UnitsetForegroundNotificationInterceptor(BasePushService.ForegroundNotificationInterceptor foregroundNotificationInterceptor)final BasePushService.BackgroundNotificationInterceptorgetBackgroundNotificationInterceptor()final UnitsetBackgroundNotificationInterceptor(BasePushService.BackgroundNotificationInterceptor backgroundNotificationInterceptor)final BasePushService.PushProvidergetPushProvider()final UnitsetPushProvider(BasePushService.PushProvider pushProvider)final UnitsetPersistedNotification(Boolean persistedNotification)Unitinit(Application application, String apiKey)Initializes the mobile service final UnitsetPushServiceConfig(PushServiceConfig pushServiceConfig)Setup push related config. final UnitstoreNotificationMessage(Boolean isForeground, PushRemoteMessage message, ForegroundPushNotificationReady foregroundPushNotificationReady)Stores the notification from system tray, notification will be displayed depending condition. UnitonStateChange(ApplicationState state)Notified when application state changes. final BooleancheckPredefinedCondition()final UnitsetPushCallbackListener(PushCallbackListener callbackListener)Sets the push callback listener. final UnitaddForegroundPushNotificationConditions(ForegroundPushNotificationReady foregroundPushNotificationReady)Add predefined condition for push message, all the conditions ready the push message will show. final UnitinitRemoteNotificationParameters(RemoteNotificationParameters parameters)final UnitupdateRemoteNotificationParameters(RemoteNotificationParameters parameters)Unitreset()Resets the mobile service to the state that just initialized. UnitstartPush()UnitregisterTokenToServer()UnitupdateRegistration(RemoteNotificationParameters parameters, RemoteNotificationClient.CallbackListener listener)UnitunregisterPushSync(RemoteNotificationClient.CallbackListener listener)UnitstopPush()abstract BasePushService.PushProviderpushProvider()final UnitregisterToServer(String token, Function1<Boolean, Unit> callback)final UnitunregisterFromServer(RemoteNotificationClient.CallbackListener listener)final UnitupdateServerRegistration(String token, RemoteNotificationClient.CallbackListener listener)final UnitupdatePushMessageStatus(String notificationId, PushRemoteMessage.NotificationStatus status)final UnitsubscribeTopic(String topic, RemoteNotificationClient.CallbackListener listener)final UnitgetAllSubscribedTopics(RemoteNotificationClient.CallbackListenerWithResult listener)final UnitunsubscribeTopic(String topic, RemoteNotificationClient.CallbackListener listener)final static UnitremoveRegistrationFromServer(RemoteNotificationClient.CallbackListener listener)Removes the registration from server final static UnitsendRegistrationToServer(String token)Sends the token to the mobile services back end. final static UnitupdateRegistrationToServer(String token, RemoteNotificationClient.CallbackListener listener)Update registration to the mobile services back end. final static UnitsetPushMessageStatus(String notificationId, PushRemoteMessage.NotificationStatus status)Sends the push message status to server. -
Methods inherited from class com.sap.cloud.mobile.foundation.mobileservices.MobileService
enableNetworkPolicy, getApiKey, getApplication, isApplicationInitialized, mayStartNewProcess, setApiKey, setApplication -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getCallbackListener
final PushCallbackListener getCallbackListener()
-
setCallbackListener
final Unit setCallbackListener(PushCallbackListener callbackListener)
-
isEnableAutoMessageHandling
final Boolean isEnableAutoMessageHandling()
Enable auto message handling.
-
setEnableAutoMessageHandling
final Unit setEnableAutoMessageHandling(Boolean isEnableAutoMessageHandling)
Enable auto message handling.
-
isEnableBadgeMessage
final Boolean isEnableBadgeMessage()
-
setEnableBadgeMessage
final Unit setEnableBadgeMessage(Boolean isEnableBadgeMessage)
-
getBadgeServiceChannel
final NotificationChannel getBadgeServiceChannel()
-
setBadgeServiceChannel
final Unit setBadgeServiceChannel(NotificationChannel badgeServiceChannel)
-
getForegroundNotificationInterceptor
final BasePushService.ForegroundNotificationInterceptor getForegroundNotificationInterceptor()
-
setForegroundNotificationInterceptor
final Unit setForegroundNotificationInterceptor(BasePushService.ForegroundNotificationInterceptor foregroundNotificationInterceptor)
-
getBackgroundNotificationInterceptor
final BasePushService.BackgroundNotificationInterceptor getBackgroundNotificationInterceptor()
-
setBackgroundNotificationInterceptor
final Unit setBackgroundNotificationInterceptor(BasePushService.BackgroundNotificationInterceptor backgroundNotificationInterceptor)
-
getPushProvider
final BasePushService.PushProvider getPushProvider()
-
setPushProvider
final Unit setPushProvider(BasePushService.PushProvider pushProvider)
-
setPersistedNotification
final Unit setPersistedNotification(Boolean persistedNotification)
-
init
Unit init(Application application, String apiKey)
Initializes the mobile service
-
setPushServiceConfig
final Unit setPushServiceConfig(PushServiceConfig pushServiceConfig)
Setup push related config.
- Parameters:
pushServiceConfig- Config info about notification builder and notification channel.
-
storeNotificationMessage
final Unit storeNotificationMessage(Boolean isForeground, PushRemoteMessage message, ForegroundPushNotificationReady foregroundPushNotificationReady)
Stores the notification from system tray, notification will be displayed depending condition. Handles the message with data payload from advanced push when app is in background.
- Parameters:
isForeground- is set to true for message from foregroundmessage- contains the notification will be displayedforegroundPushNotificationReady- is the condition decided in which activity the notification will be displayed.
-
onStateChange
Unit onStateChange(ApplicationState state)
Notified when application state changes. This function will be called on Main thread.
-
checkPredefinedCondition
final Boolean checkPredefinedCondition()
-
setPushCallbackListener
final Unit setPushCallbackListener(PushCallbackListener callbackListener)
Sets the push callback listener.
- Parameters:
callbackListener- the listener
-
addForegroundPushNotificationConditions
final Unit addForegroundPushNotificationConditions(ForegroundPushNotificationReady foregroundPushNotificationReady)
Add predefined condition for push message, all the conditions ready the push message will show.
- Parameters:
foregroundPushNotificationReady- true condition ready, false not
-
initRemoteNotificationParameters
final Unit initRemoteNotificationParameters(RemoteNotificationParameters parameters)
-
updateRemoteNotificationParameters
final Unit updateRemoteNotificationParameters(RemoteNotificationParameters parameters)
-
reset
Unit reset()
Resets the mobile service to the state that just initialized.
-
startPush
Unit startPush()
-
registerTokenToServer
@WorkerThread() Unit registerTokenToServer()
-
updateRegistration
@WorkerThread() Unit updateRegistration(RemoteNotificationParameters parameters, RemoteNotificationClient.CallbackListener listener)
-
unregisterPushSync
@WorkerThread() Unit unregisterPushSync(RemoteNotificationClient.CallbackListener listener)
-
stopPush
Unit stopPush()
-
pushProvider
abstract BasePushService.PushProvider pushProvider()
-
registerToServer
final Unit registerToServer(String token, Function1<Boolean, Unit> callback)
-
unregisterFromServer
final Unit unregisterFromServer(RemoteNotificationClient.CallbackListener listener)
-
updateServerRegistration
final Unit updateServerRegistration(String token, RemoteNotificationClient.CallbackListener listener)
-
updatePushMessageStatus
final Unit updatePushMessageStatus(String notificationId, PushRemoteMessage.NotificationStatus status)
-
subscribeTopic
final Unit subscribeTopic(String topic, RemoteNotificationClient.CallbackListener listener)
-
getAllSubscribedTopics
final Unit getAllSubscribedTopics(RemoteNotificationClient.CallbackListenerWithResult listener)
-
unsubscribeTopic
final Unit unsubscribeTopic(String topic, RemoteNotificationClient.CallbackListener listener)
-
removeRegistrationFromServer
@Deprecated(message = "Deprecated since 5.1", replaceWith = @ReplaceWith(imports = {}, expression = "unregisterFromServer")) final static Unit removeRegistrationFromServer(RemoteNotificationClient.CallbackListener listener)Removes the registration from server
-
sendRegistrationToServer
@Deprecated(message = "Deprecated since 5.1", replaceWith = @ReplaceWith(imports = {}, expression = "registerToServer")) final static Unit sendRegistrationToServer(String token)Sends the token to the mobile services back end.
- Parameters:
token- Baidu or Firebase token to be sent.
-
updateRegistrationToServer
@Deprecated(message = "Deprecated since 5.1", replaceWith = @ReplaceWith(imports = {}, expression = "updateServerRegistration")) final static Unit updateRegistrationToServer(String token, RemoteNotificationClient.CallbackListener listener)Update registration to the mobile services back end.
- Parameters:
token- Baidu or Firebase token to be sent.
-
setPushMessageStatus
@Deprecated(message = "Deprecated since 5.1", replaceWith = @ReplaceWith(imports = {}, expression = "updatePushMessageStatus")) final static Unit setPushMessageStatus(String notificationId, PushRemoteMessage.NotificationStatus status)Sends the push message status to server.
- Parameters:
notificationId- The notification ID which is from server push messages.status- The message consumption status, it could be either 'consumed' or 'received'
-
-
-
-