-
Notifications
You must be signed in to change notification settings - Fork 21
How to postpone registering for push notifications
MobileMessaging SDK by default registers for push notifications during MobileMessaging.start() procedure. It is possible to disable this default behaviour. This might be needed in case your app should support other push notifications vendors in addition to (or instead of) Infobip's one, or you want to have a more flexible approach of when and where the user will be prompted to allow receiving Push Notifications.
In order to not register for push notifications during MobileMessaging.start() procedure add withoutRegisteringForRemoteNotifications() to the start call:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
MobileMessaging.withApplicationCode(<#your application code#>, notificationType: <#for example MMUserNotificationType(options: [.alert, .sound])#>)?.withoutRegisteringForRemoteNotifications()?.start()
...
} expand to see Objective-C code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MMUserNotificationType *notificationType = [[MMUserNotificationType alloc] initWithOptions:@[MMUserNotificationType.alert, MMUserNotificationType.sound]];
[[[MobileMessaging withApplicationCode:<#your application code#> notificationType: notificationType] withoutRegisteringForRemoteNotifications] start:nil];
...
}You can register for push notifications later by calling MobileMessaging.registerForRemoteNotifications().
expand to see Objective-C code
[MobileMessaging registerForRemoteNotifications];If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.