Skip to content

Instantly share code, notes, and snippets.

@cristainlika
Last active January 27, 2017 10:46
Show Gist options
  • Save cristainlika/f23a44ff0b4a11d4dfd3de883a6e21ef to your computer and use it in GitHub Desktop.
Save cristainlika/f23a44ff0b4a11d4dfd3de883a6e21ef to your computer and use it in GitHub Desktop.
ios remote push notification (production environment ) not working ios9 where it is full working ios10 . what can i do ?
Note : also i am testing by apn tester both ios9 and io10 it is working fine .. my project in swift 2 .
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//ask for user to permited push notification
registerForPushNotifications(application)
//crate notification with sound alert, Badge , and sound
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
//add nofification type in system notification
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
//register for remot notificaiton not local
return true
}
//MARK:- Push Notification configaratin
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
if notificationSettings.types != .None{
application.registerForRemoteNotifications()
}
}
func registerForPushNotifications(application: UIApplication)
{
let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil)
application.registerUserNotificationSettings(notificationSettings)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
//send Device Id
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)
{
print("Failed to register:", error)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
self.showingAlert("notification arived 3: \(userInfo)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment