I am using Firebase push notifications in my application. In one tutorial, I find that I get a token from Messaging.messaging().fcmToken and this SO question, which I find this way: FIRInstanceID.instanceID().token()
What is the difference between the two? My only goal is to be able to send my third-party guys to the token so that they can recognize me in the database for push notifications. Currently, my code that generates the token is this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.current().delegate = self let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization( options: authOptions, completionHandler: {_, _ in }) // For iOS 10 data message (sent via FCM Messaging.messaging().delegate = self } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) application.registerUserNotificationSettings(settings) } application.registerForRemoteNotifications() FirebaseApp.configure() let token = Messaging.messaging().fcmToken setFCM(token: token ?? "UNDEFINED") //a function that saves it in user defaults. print("FCM token: \(token ?? "")") return true }
source share