0

Push notification not received in App from Firebase. pod details: These are the dependencies I use:

Firebase (6.10.0)

FirebaseAnalytics (6.1.3)

FirebaseAnalyticsInterop (1.4.0)

FirebaseAuth (6.3.0)

FirebaseAuthInterop (1.0.0)

FirebaseCore (6.3.1)

FirebaseCoreDiagnostics (1.1.1)

FirebaseCoreDiagnosticsInterop (1.0.0)

FirebaseDatabase (6.1.1)

FirebaseInstanceID (4.2.5)

FirebaseMessaging (4.1.6)

iOS 12 and below versions received push notification with swift 5.1. But iOS 13 did not receive any push notification. The cloud send success message for push notification.

func authForRemoteNotificationsIn(_ application: UIApplication) {

    // Verify the remote notification registration status
    guard !application.isRegisteredForRemoteNotifications || UserDefaults.fcmToken.isEmpty else { return }

    /**
     Specify the notification options
     * Disbled sound: Silent notifications are more helpful the user
     */
    let authOptions: UNAuthorizationOptions = [.badge]
    // Requset the authorization
    UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { (_, error) in

        // Validate the request status
        guard let error = error else { return }
        print(error.localizedDescription)
    }

    // Request device token
    application.registerForRemoteNotifications()
}


func application(_ application: UIApplication,    didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    print(#function)

    Messaging.messaging().delegate = self
    Messaging.messaging().isAutoInitEnabled = true
    Messaging.messaging().apnsToken = deviceToken
}
Kaiser
  • 606
  • 8
  • 22

1 Answers1

0

Can you check how you're receiving the device token? It changed for iOS 13, so you might be registering on API an unsupported format.

Check this approach.

Marina Aguilar
  • 1,151
  • 9
  • 26
  • I did not require to save the token. I just want to send it to firebase using the code: Messaging.messaging().apnsToken = deviceToken –  Nov 05 '19 at 12:20
  • Exactly, I mean this deviceToken that is being assigned to Messaging.messaging().apnsToken. My question is if this token is on the right format for Firebase. – Marina Aguilar Nov 05 '19 at 12:25
  • Yes. Tested with 12 version(push notification success) and 13 version(push notification failed). Both device tokens are 32 bytes. –  Nov 06 '19 at 04:54