How to completely stop or start receiving push messages - infobip/mobile-messaging-sdk-ios GitHub Wiki
Important
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, you can send silent campaigns.
Disabling the push registration
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:
if let installation = MobileMessaging.getInstallation() {
installation.isPushRegistrationEnabled = false
MobileMessaging.saveInstallation(installation, completion: { error in
if let error = error {
< handle error if not nil >
}
})
}
Enabling the push registration
In order to enable current user back to receiving push messages, you 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:
if let installation = MobileMessaging.getInstallation() {
installation.isPushRegistrationEnabled = false
MobileMessaging.saveInstallation(installation, completion: { error in
if let error = error {
< handle error if not nil >
}
})
}
Retrieving the current push registration status
In order to get the current registration status, use the following code:
let isPushRegistrationEnabled = MobileMessaging.getInstallation().isPushRegistrationEnabled