is there any needed additional codes to be performed? i cannot receive notification anymore unlike before…
//
// AppDelegate.swift
// TestPushNotify
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let APP_ID = “***********”
let SECRET_KEY = “***********”
let VERSION_NUM = “v1”
var backendless = Backendless.sharedInstance()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)
backendless.messaging.registerForRemoteNotifications()
if let remoteDict = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary {
self.application(application, didReceiveRemoteNotification: remoteDict as [NSObject : AnyObject])
}
//backendless.messaging.notificationTypes = UIUserNotificationType.Alert.rawValue | UIUserNotificationType.Sound.rawValue | UIUserNotificationType.Badge.rawValue
backendless.messaging.notificationTypes = UIUserNotificationType.Alert.rawValue | UIUserNotificationType.Sound.rawValue | UIUserNotificationType.Badge.rawValue
//NEEDED TO DO THE FOLLOWING TWO LINES
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
return true
}
func applicationWillTerminate(application: UIApplication) {
backendless.messaging.applicationWillTerminate()
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
print(“did register> (deviceToken)”)
backendless.messaging.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(“the error is (error)”)
backendless.messaging.didFailToRegisterForRemoteNotificationsWithError(error)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
print(“receiving data>>> (userInfo)”)
backendless.messaging.didReceiveRemoteNotification(userInfo)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
backendless.messaging.didReceiveRemoteNotification(userInfo)
completionHandler(.NewData)
}
}