I am new to the Swift and Push notification is not popping up in iOS 10, I did all configuration things. Notification show in iOS 8 and 9 devices with (same code) but not showing in iOS 10 devices. code is like(Only notification part code added).
private let brandFullery : String = "some token key"
var pushNotify : NSDictionary!
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
UIApplication.sharedApplication().cancelAllLocalNotifications()
MyCacheManager.sharedInstance.deviceId = UIDevice.currentDevice().identifierForVendor!.UUIDString
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Sound, .Alert, .Badge], categories: nil))
application.registerForRemoteNotifications()
MyCacheManager.sharedInstance.deleteAllFileInDocument("LiveUserProfile")
if let payload = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary, metData = payload["data"] as? NSDictionary {
pushNotify = metData
let aps = pushNotify["eventType"] as! NSString
if aps != "INVITE_POINTS" && aps != "UPDATE_BEACON" && aps != "CREATE_REWARD" {
MyCacheManager.sharedInstance.isFromNotification = aps as String
} else {
if aps == "UPDATE_BEACON" {
MyCacheManager.sharedInstance.isBeaconUpdate = true
}
MyCacheManager.sharedInstance.isFromNotification = ""
}
self.createMenuView()
} else {
MyCacheManager.sharedInstance.isFromNotification = ""
self.createMenuView()
}
#if BRANDAPP
Twitter.sharedInstance().startWithConsumerKey(brandTwitterAuthKey, consumerSecret: brandSecuriteKey)
Flurry.startSession(brandFullery)
#else
Twitter.sharedInstance().startWithConsumerKey(userTwitterAuthKey, consumerSecret: userSecuriteKey)
Flurry.startSession(userFullery)
#endif
Fabric.with([Twitter.self])
UIApplication.sharedApplication().statusBarStyle = .LightContent
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
//MARK: Push notification
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
var deviceTokenString : NSString = deviceToken.description;
deviceTokenString = deviceTokenString.stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: "<>"))
deviceTokenString = deviceTokenString.stringByReplacingOccurrencesOfString(" ", withString: "")
MyCacheManager.sharedInstance.deviceToken = deviceTokenString as String
MyCacheManager.sharedInstance.putDeviceToken(deviceTokenString)
NSLog("device %@", deviceTokenString)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
MyCacheManager.sharedInstance.isFromNotification = "MSG"
print(userInfo)
}
Please anyone help me to work this. Many thanks in advance.