[SOLVED] Firebase APNS Token not set Flutter iOS

 If you're facing issue with Firebase initialization in Flutter in spite of doing everything right.
You may be missing setting the APNS token in app delegate file in xCode. You may use the following code which sets it for you and fixes Firebase init error.

import UIKit

import Flutter

import Firebase

import FirebaseMessaging


@objc class AppDelegate: FlutterAppDelegate {

  override func application(

    _ application: UIApplication,

    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?

  ) -> Bool {


      print("fb tokennnnnn: ")


    GeneratedPluginRegistrant.register(with: self)

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)


  override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {


   Messaging.messaging().apnsToken = deviceToken

   print("X__APNS: \(String(describing: deviceToken))")

      print("apns tokennnnnn: ")


      let firebaseAuth = Auth.auth()

        firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)

   super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)



Next Post Previous Post
No Comment
Add Comment
comment url