Swift version (based on @HeadOnn answer ):
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Messaging.messaging().setAPNSToken(deviceToken, type: .prod) // may be excess guard let plistPath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist"), let options = FirebaseOptions(contentsOfFile: plistPath) else { return } InstanceID.instanceID().token(withAuthorizedEntity: options.gcmSenderID, scope: InstanceIDScopeFirebaseMessaging, options: ["apns_token": deviceToken]) { (token, error) in // handle token and error } }
source share