9

For iOS 12 Push Notifications are not working and working in below versions

My App is in Appstore. Push notification is working fine in iOS 11, but in iOS 12 it is not working. I am not receiving any push notification for iOS 12 devices. I have checked the device token and certificate in my server. All are correct. I have also checked the notification properties in settings app. All are fine. But I didn't receive any notification.

This is the code i used for push notifications.

Can you please suggest me what would be the issue. How to Fix This?

func registerForPushNotifications() {

    if #available(iOS 10.0, *){

        let center = UNUserNotificationCenter.current()
        center.delegate = self
        center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
            if (granted)
            {
                UIApplication.shared.registerForRemoteNotifications()
            }
            else{
                //Do stuff if unsuccessful...
                 UIApplication.shared.registerForRemoteNotifications()
            }
            // Enable or disable features based on authorization.
        }
    }
    else
    {

        let types: UIUserNotificationType = [UIUserNotificationType.badge, UIUserNotificationType.alert, UIUserNotificationType.sound]
        let settings: UIUserNotificationSettings = UIUserNotificationSettings( types: types, categories: nil )
        UIApplication.shared.registerUserNotificationSettings( settings )
        UIApplication.shared.registerForRemoteNotifications()

    }

}



@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

    let userInfo = response.notification.request.content.userInfo as NSDictionary

    print(userInfo)


}
Sandeep Baddula
  • 181
  • 1
  • 9

1 Answers1

3

I had the same problem when my app running in "debug",
I run app in "release" and notification worked fine

Yusef.Naser
  • 123
  • 1
  • 6
  • Hi, for me also the push notifications are not working, if we build the project from xcode it is not woorking, if i build the project from command prompt then the notifications are coming. i am using firebase push notifications in ionic framework version 3. i updated my mac ios version to 12 and the xcode version to 10, then notifications stopped working.. can any help to sort out of this problem... – Midhunsai Oct 22 '18 at 09:34