I am not getting device token in iPhone 5 (10.2.1) and SE(10.3.1) and other 5 related devices but successfully getting tokens in all iPhone 6 (including plus, SE) and 7, and 7+ also.
This is my code for registering
func registerForPushNotification(let application: UIApplication) {
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.applicationIconBadgeNumber = 0
if pushNotificationSettings.types != .None {
application.registerForRemoteNotifications()
}
}
And this is my code for collecting token
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let characterSet: NSCharacterSet = NSCharacterSet( charactersInString: "<>" )
let deviceTokenString: String = ( deviceToken.description as NSString )
.stringByTrimmingCharactersInSet( characterSet )
.stringByReplacingOccurrencesOfString( " ", withString: "" ) as String
print( deviceTokenString )
}
Any help?