Visitar URL original
fix(messaging,ios): register for APNs when UIScene plugins miss launc… · firebase/flutterfire@2fd8aa8 · GitHub
Skip to content

Commit 2fd8aa8

Browse files
authored
fix(messaging,ios): register for APNs when UIScene plugins miss launch callbacks (#18620)
UIScene can register the plugin after didFinishLaunching and scene:willConnect have already fired, so setup never ran and getAPNSToken stayed null.
1 parent 5cb3564 commit 2fd8aa8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
135135
if ([registrar respondsToSelector:@selector(addSceneDelegate:)]) {
136136
[registrar performSelector:@selector(addSceneDelegate:) withObject:instance];
137137
}
138+
// UIScene registers plugins after didFinishLaunching / scene:willConnect.
139+
// If a scene is already connected those callbacks were missed, so run
140+
// setup now. setupNotificationHandling is idempotent if a callback still
141+
// arrives later. iOS re-delivers the APNs token when we register again.
142+
if ([UIApplication sharedApplication].connectedScenes.count > 0) {
143+
instance->_sceneDidConnect = YES;
144+
[instance setupNotificationHandlingWithRemoteNotification:nil];
145+
}
138146
}
139147
#endif
140148
}

0 commit comments

Comments
 (0)