BatchPush

@interface BatchPush

Provides Batch-related Push methods Actions you can perform in BatchPush.

  • Controls whether Batch should tell iOS 12+ that your application supports opening in-app notification settings from the system. Supporting this also requires implementing the corresponding method in UNUserNotificationCenterDelegate.

    Declaration

    Objective-C

    @property (class) int supportsAppNotificationSettings;
  • Do not call this method, as BatchPush only consists of static methods.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Setup Batch Push system. You can call this method from any thread.

    @deprecated

    Declaration

    Objective-C

    + (void)setupPush;
  • Change the used remote notification types when registering. This does NOT change the user preferences once already registered: to do so, you should point them to the native system settings. Default value is: BatchNotificationTypeBadge | BatchNotificationTypeSound | BatchNotificationTypeAlert

    Declaration

    Objective-C

    + (void)setRemoteNotificationTypes:(id)type;

    Parameters

    type

    A bit mask specifying the types of notifications the app accepts.

  • Call this method to trigger the iOS popup that asks the user if they wants to allow notifications to be displayed, then get a Push token. The default registration is made with Badge, Sound and Alert. If you want another configuration: call setRemoteNotificationTypes:. You should call this at a strategic moment, like at the end of your welcome.

    Batch will automatically ask for a push token when the user replies.

    Declaration

    Objective-C

    + (void)requestNotificationAuthorization;
  • Call this method to ask iOS for a provisional notification authorization. Batch will then automatically ask for a push token.

    Provisional authorization will NOT show a popup asking for user authorization, but notifications will NOT be displayed on the lock screen, or as a banner when the phone is unlocked. They will directly be sent to the notification center, accessible when the user swipes up on the lockscreen, or down from the statusbar when unlocked.

    This method does nothing on iOS 11 or lower.

    Declaration

    Objective-C

    + (void)requestProvisionalNotificationAuthorization;
  • Ask iOS to refresh the push token. If the app didn’t prompt the user for consent yet, this will not be done. You should call this at the start of your app, to make sure Batch always gets a valid token after app updates.

    Declaration

    Objective-C

    + (void)refreshToken;
  • Open the system settings on your applications’ notification settings.

    Declaration

    Objective-C

    + (void)openSystemNotificationSettings;
  • Call this method to trigger the iOS popup that asks the user if they wants to allow Push Notifications, then get a Push token. The default registration is made with Badge, Sound and Alert. If you want another configuration: call setRemoteNotificationTypes:. You should call this at a strategic moment, like at the end of your welcome.

    Equivalent to calling +[BatchPush requestNotificationAuthorization]

    Declaration

    Objective-C

    + (void)registerForRemoteNotifications;
  • Call this method to trigger the iOS popup that asks the user if they want to allow Push Notifications and register to APNS. Default registration is made with Badge, Sound and Alert. If you want another configuration: call setRemoteNotificationTypes:. You should call this at a strategic moment, like at the end of your welcome.

    @deprecated

    Declaration

    Objective-C

    + (void)registerForRemoteNotificationsWithCategories:(id)categories;

    Parameters

    categories

    A set of UIUserNotificationCategory or UNNotificationCategory instances that define the groups of actions a notification may include. If you try to register UIUserNotificationCategory instances on iOS 10, Batch will automatically do a best effort conversion to UNNotificationCategory. If you don’t want this behaviour, please use the standard UIApplication methods.

  • Set the notification action categories to iOS. You should call this every time your app starts.

    Warning

    On versions prior to iOS 10, this call MUST be followed by registerForRemoteNotifications, or else the categories will NOT be updated.

    Declaration

    Objective-C

    + (void)setNotificationsCategories:(id)categories;

    Parameters

    categories

    A set of UIUserNotificationCategory or UNNotificationCategory instances that define the groups of actions a notification may include. If you try to register UIUserNotificationCategory instances on iOS 10, Batch will automatically do a best effort conversion to UNNotificationCategory. If you don’t want this behaviour, please use the standard UIApplication methods.

  • Clear the application’s badge on the homescreen. You do not need to call this if you already called dismissNotifications.

    Declaration

    Objective-C

    + (void)clearBadge;
  • Clear the app’s notifications in the notification center. Also clears your badge. Call this when you want to remove the notifications. Your badge is removed afterwards, so if you want one, you need to set it up again.

    @waning Be careful, this method also clears your badge.

    Declaration

    Objective-C

    + (void)dismissNotifications;
  • Set whether Batch Push should automatically try to handle deeplinks By default, this is set to YES. You need to call everytime your app is restarted, this option is not persisted.

    If your goal is to implement a custom deeplink format, you should see Batch.deeplinkDelegate which allows you to manually handle the deeplink string, but doesn’t put the burden of parsing the notification payload on you.

    Please note that setting this to false will DISABLE the deeplink delegate, leaving the handling of the link entirely up to you.

    Warning

    If Batch is set to handle your deeplinks, it will automatically call the fetch completion handler (if applicable) with UIBackgroundFetchResultNewData.

    Declaration

    Objective-C

    + (void)enableAutomaticDeeplinkHandling:(id)handleDeeplinks;
  • Get Batch Push’s deeplink from a notification’s userInfo.

    Declaration

    Objective-C

    + (id)deeplinkFromUserInfo:(id)userData;

    Return Value

    Batch’s Deeplink, or nil if not found.

  • Get the last known push token.

    Your application should still register for remote notifications once per launch, in order to keep this value valid.

    Warning

    The returned token might be outdated and invalid if this method is called too early in your application lifecycle.

    Declaration

    Objective-C

    + (id)lastKnownPushToken;

    Return Value

    A push token, nil if unavailable.

  • Disable the push’s automatic integration. If you call this, you are responsible of forwarding your application’s delegate and UNUserNotificationCenterDelegate calls to Batch. If you don’t, some parts of the SDK and Dashboard will break. Calling this method automatically calls disableAutomaticNotificationCenterIntegration.

    Warning

    This must be called before you start Batch, or it will have no effect.

    Declaration

    Objective-C

    + (void)disableAutomaticIntegration;
  • Registers a device token to Batch. You should call this method in “application:didRegisterForRemoteNotificationsWithDeviceToken:”.

    Warning

    If you didn’t call “disableAutomaticIntegration”, this method will have no effect. If you called it but don’t implement this method, Batch’s push features will NOT work.

    Declaration

    Objective-C

    + (void)handleDeviceToken:(id)token;

    Parameters

    token

    The untouched “deviceToken” NSData argument given to you in the application delegate method.

  • Check if the received push is a Batch one.

    Warning

    If you have a custom push implementation into your app you should call this method before doing anything else.

    Declaration

    Objective-C

    + (id)isBatchPush:(id)userInfo;

    Parameters

    userInfo

    The untouched “userInfo” NSDictionary argument given to you in the application delegate method.

    Return Value

    If it returns true, you should not handle the push.

  • Deprecated

    Implement UNUserNotificationCenterDelegate using BatchUNUserNotificationCenterDelegate or your own implementation

    Make Batch process a notification. You should call this method in “application:didReceiveRemoteNotification:” or “application:didReceiveRemoteNotification:fetchCompletionHandler:”.

    Warning

    If you didn’t call “disableAutomaticIntegration”, this method will have no effect. If you called it but don’t implement this method, Batch’s push features will NOT work.

    Declaration

    Objective-C

    + (void)handleNotification:(id)userInfo;

    Parameters

    userInfo

    The untouched “userInfo” NSDictionary argument given to you in the application delegate method.

  • Make Batch process a notification action. You should call this method in “application:handleActionWithIdentifier:forRemoteNotification:completionHandler:” or “application:handleActionWithIdentifier:forRemoteNotification:withResponseInfo:completionHandler:”.

    Warning

    If you didn’t call “disableAutomaticIntegration”, this method will have no effect. If you called it but don’t implement this method, Batch’s push features will NOT work.

    Declaration

    Objective-C

    + (void)handleNotification:(id)userInfo actionIdentifier:(id)identifier;

    Parameters

    userInfo

    The untouched “userInfo” NSDictionary argument given to you in the application delegate method.

    identifier

    The action’s identifier. Used for tracking purposes: it can match your raw action name, or be a more user-friendly string;

  • Deprecated

    Use BatchPush.requestNotificationAuthorization()

    Make Batch process the user notification settings change. You should call this method in “application:didRegisterUserNotificationSettings:”.

    Warning

    If you didn’t call “disableAutomaticIntegration”, this method will have no effect. If you called it but don’t implement this method, Batch’s push features will NOT work.

    Declaration

    Objective-C

    + (void)handleRegisterUserNotificationSettings:(id)notificationSettings;

    Parameters

    notificationSettings

    The untouched “notificationSettings” UIUserNotificationSettings* argument given to you in the application delegate method.

UserNotifications methods

  • Make Batch process a foreground notification. You should call this method if you set your own UNUserNotificationCenterDelegate, in userNotificationCenter:willPresentNotification:withCompletionHandler:

    Declaration

    Objective-C

    + (void)handleUserNotificationCenter:(id)center
                 willPresentNotification:(id)notification
           willShowSystemForegroundAlert:(id)willShowSystemForegroundAlert;

    Parameters

    center

    Original center argument

    notification

    Original notification argument

    willShowSystemForegroundAlert

    Whether you will tell the framework to show this notification, or not. Batch uses this value to adjust its behaviour accordingly for a better user experience. Return ‘true’ if you’re returning .alert (or more) to iOS’ completion handler.

  • Make Batch process a background notification open/action. You should call this method if you set your own UNUserNotificationCenterDelegate, in userNotificationCenter:didReceiveNotificationResponse:

    Declaration

    Objective-C

    + (void)handleUserNotificationCenter:(id)center
          didReceiveNotificationResponse:(id)response;

    Parameters

    center

    Original center argument

    response

    Original response argument