-
Notifications
You must be signed in to change notification settings - Fork 17
How to completely stop or start receiving push messages
Push registration is enabled by default, that means that you don't need to use method for enabling it. Disabled push registration is the one that will completely stop receiving push notifications. Disabling push registration is needed to be used only if you want to opt out of receiving notifications. If you just don't want notifications to be displayed in the notification center, send silent campaign, or use method .withoutDisplayNotification().
In order to disable the current user from receiving push messages, you have to change his push registration status. Here are the steps:
- Start MobileMessaging SDK in a way it's described in the Quick Start Guide if it is not started yet.
- Once the SDK has been successfully initialized and started, do the following:
val installation = Installation()
installation.isPushRegistrationEnabled = false
MobileMessaging.getInstance(context).saveInstallation(installation, object : ResultListener<Installation>() {
override fun onResult(result: Result<Installation, MobileMessagingError>) {
// process result here
}
})
expand to see Java code
Installation installation = new Installation();
installation.setPushRegistrationEnabled(false);
MobileMessaging.getInstance(context).saveInstallation(installation, new ResultListener<Installation>() {
@Override
public void onResult(Result<Installation, MobileMessagingError> result) {
// process result here
}
});
In order to enable current user back to receiving push messages, you need to enable user's push registration:
- Start MobileMessaging SDK in a way it's described in the Quick Start Guide if it is not started yet.
- Once the SDK has been successfully initialized and started, do the following:
val installation = Installation()
installation.isPushRegistrationEnabled = true
MobileMessaging.getInstance(context).saveInstallation(installation, object : ResultListener<Installation>() {
override fun onResult(result: Result<Installation, MobileMessagingError>) {
// process result here
}
})
expand to see Java code
Installation installation = new Installation();
installation.setPushRegistrationEnabled(true);
MobileMessaging.getInstance(context).saveInstallation(installation, new ResultListener<Installation>() {
@Override
public void onResult(Result<Installation, MobileMessagingError> result) {
// process result here
}
});
In order to get the current registration status, use the following code:
var isPushRegistrationEnabled = MobileMessaging.getInstance(this).installation.isPushRegistrationEnabled
expand to see Java code
boolean isPushRegistrationEnabled = MobileMessaging.getInstance(this).getInstallation().isPushRegistrationEnabled();
If you have any questions or suggestions, feel free to send an email to support@infobip.com or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
Geofencing API- DEPRECATED- Android Manifest components
- Privacy settings
- In-app chat
- Infobip RTC calls and UI
- Backup rules