From 355ac035bf2aa6c05afad3e999233e069d890e44 Mon Sep 17 00:00:00 2001 From: JWSametz Date: Thu, 3 Sep 2026 11:55:07 +0200 Subject: [PATCH] feat: enable APNs registration during app launch to ensure FCM token availability --- ios/Runner/AppDelegate.swift | 6 ++++++ kids/ios/Runner/AppDelegate.swift | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index f00a7f65..f667e15e 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -11,6 +11,12 @@ import UserNotifications didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() + + // Start APNs registration during native launch. With Flutter's implicit-engine + // lifecycle, Firebase Messaging plugin registration happens later, which can + // otherwise leave the APNs token unavailable when Dart first accesses FCM. + application.registerForRemoteNotifications() + let flutterResult = super.application(application, didFinishLaunchingWithOptions: launchOptions) return flutterResult } diff --git a/kids/ios/Runner/AppDelegate.swift b/kids/ios/Runner/AppDelegate.swift index 9fb13d79..f85b46dd 100644 --- a/kids/ios/Runner/AppDelegate.swift +++ b/kids/ios/Runner/AppDelegate.swift @@ -9,6 +9,12 @@ import UIKit didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { FirebaseApp.configure() + + // Start APNs registration during native launch. With Flutter's implicit-engine + // lifecycle, Firebase Messaging plugin registration happens later, which can + // otherwise leave the APNs token unavailable when Dart first accesses FCM. + application.registerForRemoteNotifications() + return super.application(application, didFinishLaunchingWithOptions: launchOptions) }