Intercepting notifications
iOS 10
@objc
class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
[your code]
BatchPush.handle(userNotificationCenter: center, didReceive: response)
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
[your code]
BatchPush.handle(userNotificationCenter: center, willPresent: notification, willShowSystemForegroundAlert: true)
// Since you set willShowSystemForegroundAlert to true, you should call completionHandler([.alert, .sound, .badge])
// If set to false, you'd call completionHandler([])
}
}// NotificationDelegate.h
@import Foundation;
@import UserNotifications;
@interface NotificationDelegate : NSObject <UNUserNotificationCenterDelegate>
@end
// NotificationDelegate.m
#import "NotificationDelegate.h"
@import Batch;
@implementation NotificationDelegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)())completionHandler {
[your code]
[BatchPush handleUserNotificationCenter:center
didReceiveNotificationResponse:response];
completionHandler();
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
[your code]
[BatchPush handleUserNotificationCenter:center
willPresentNotification:notification
willShowSystemForegroundAlert:YES];
// Since you set willShowSystemForegroundAlert to true, you should call completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound)
// If set to false, you'd call completionHandler(0)
}
@endiOS 9 and lower
Overriding Batch's Deeplink Handling
Last updated

