Update: 2026-07-30 02:27:45
This commit is contained in:
@@ -19,21 +19,29 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// 1. Initialize Firebase & Notifications
|
||||
// 1. Initialize Firebase
|
||||
await Firebase.initializeApp();
|
||||
await PushNotificationService.initialize();
|
||||
|
||||
// 2. Register background handler
|
||||
// 2. Register the background handler BEFORE any listener is attached, so a
|
||||
// message arriving during startup is not lost.
|
||||
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
||||
|
||||
// 3. Security check (MUST be first)
|
||||
// 3. Notifications (permissions, Android channel, tap routing, token refresh)
|
||||
await PushNotificationService.initialize();
|
||||
|
||||
// 4. Security check (MUST be first)
|
||||
Get.put(DeviceSecurityService(), permanent: true);
|
||||
|
||||
// 4. Register global services
|
||||
// 5. Register global services
|
||||
Get.put(UploadProgressService(), permanent: true);
|
||||
Get.put(HomeWidgetService(), permanent: true);
|
||||
Get.put(ShorebirdUpdateService(), permanent: true);
|
||||
|
||||
// 6. Re-sync the push token on every launch. It can rotate while the app is
|
||||
// closed (reinstall, restore from backup, FCM rotation), and a stale token on
|
||||
// the server means the device silently stops receiving notifications.
|
||||
PushNotificationService.registerTokenWithServer();
|
||||
|
||||
runApp(const MusadaqApp());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user