Skip to content

Handle In-app Content

To handle NearIT content in your app, override the userNotificationCenter(_:didReceive:withCompletionHandler:) and the userNotificationCenter(_:willPresent:withCompletionHandler:) methods of your UNUserNotificationCenterDelegate:

// AppDelegate
func application(_ application: UIApplication, 
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    if #available(iOS 10.0, *) {
        // Using AppDelegate as a delegate for UNUserNotificationCenter
        UNUserNotificationCenter.current().delegate = self

@available(iOS 10.0, *)
extension AppDelegate : UNUserNotificationCenterDelegate {

    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                willPresent notification: UNNotification,
                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
                                                  willPresent: notification,
                                                  withCompletionHandler: completionHandler)

    func userNotificationCenter(_ center: UNUserNotificationCenter, 
                                didReceive response: UNNotificationResponse, 
                                withCompletionHandler completionHandler: @escaping () -> Void) {
        let isNearNotification = NearManager.shared.showContentFrom(response) { (content, trackingInfo, error) in
            if let error = error {
                // there was an error
// Declare a UNUserNotificationCenterDelegate
@interface AppDelegate()<UNUserNotificationCenterDelegate>;


// Set the delegate in didFinishLaunching
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
    [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound completionHandler:^(BOOL granted, NSError * _Nullable error) {
        // Enable or disable features based on authorization.
    return YES;

// UNUserNotificationCenterDelegate implementation
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    [[NITManager defaultManager] userNotificationCenter:center willPresent:notification withCompletionHandler:completionHandler];

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
    BOOL isNearNotification = [[NITManager defaultManager] showContentFrom:response completion:^(NITReactionBundle * _Nullable content, NITTrackingInfo * _Nullable trackingInfo, NSError * _Nullable error) {
        if (error) {
            // there was an error

If you want to customize your notifications, see this section.

If you want to achieve the same results for iOS9, you can checkout our snippets in this section.

If you must handle NearIT Custom Json "What", refer to this documentation.

Notification History

If you want to show the user notification history, you can show it with our view controller:

let historyVC = NITNotificationHistoryViewController()
NITNotificationHistoryViewController *historyVC = [[NITNotificationHistoryViewController alloc] init];
[historyVC show];

or you can show it in your UINavigationController:

let historyVC = NITNotificationHistoryViewController() rootNavController!)
NITNotificationHistoryViewController *historyVC = [[NITNotificationHistoryViewController alloc] init];
[historyVC showWithNavigationController:rootNavController];

This is the result:

Inbox list

If you want to customize the behaviour and look of our UIs or to manually handle the user notification history, head over the notification history section.

If you want to get notified when new content is available (useful if you want to display a badge), you can register for messages updates. See the section for more info.

Coupon History

If you want to show the user coupon list, you can show it with our view controller:

let vc = NITCouponListViewController()
NITCouponListViewController *vc = [[NITCouponListViewController alloc] init];
[vc show];

This is the result:

Coupon list Coupon detail

If you want to customize the behaviour and look of our UI or to manually handle the user coupons, head over to the coupon section