Code Block #import <Cordova/CDV.h> #import <UserNotifications/UserNotifications.h> #import <Foundation/Foundation.h> @interface plugin : CDVPlugin <UNUserNotificationCenterDelegate,UIApplicationDelegate> { } - (void)registerCloudMessagingToken:(CDVInvokedUrlCommand*)command; @end @implementation plugin - (void)registerCloudMessagingToken:(CDVInvokedUrlCommand*)command { //Registering for notifications UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ if( !granted ){ NSLog(@"User denied request to create notifications"); } }]; [[UIApplication sharedApplication] registerForRemoteNotifications]; NSLog(@" Register for remote notifications" ); } - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{ NSLog(@"didReceiveNotificationResponse"); } - (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification{ NSLog(@"openSettingsForNotification"); } - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{ NSLog(@"willPresentNotification"); } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ NSLog(@"hehehehe"); } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{ NSLog(@"Failed to register device for push notifications"); } @end
So thats the code, heheheh is never being printed. Despite I register for push notifications.And not even Failed to register device for push notifications is being printed. Nothing is being printed other than "Register for remote notifications"