diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 81669419..cf57ba7a 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -128,10 +128,7 @@ jobs: run: sudo xcode-select --switch /Applications/Xcode_16.4.app - run: brew install sqlcipher - uses: moonrepo/setup-rust@v1 - - name: Add Firebase Messaging - run: | - flutter pub add fcm_shared_isolate:0.1.0 - sed -i '' 's,//,,g' lib/utils/background_push.dart + - run: ./scripts/add-firebase-messaging.sh - run: flutter pub get - run: flutter build ios --no-codesign diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 6bea1100..6fc5538a 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -12,5 +12,7 @@ import Flutter func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) - } + + // From https://pub.dev/packages/flutter_local_notifications#-ios-setup + UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate } } diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 98f81eeb..a4265231 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -122,7 +122,7 @@ class BackgroundPush { //firebase.setListeners( // onMessage: (message) => pushHelper( // PushNotification.fromJson( - // Map.from(message['data'] ?? message), + // message.tryGetMap('data') ?? message, // ), // client: client, // l10n: l10n, @@ -351,6 +351,9 @@ class BackgroundPush { Future setupFirebase() async { Logs().v('Setup firebase'); if (_fcmToken?.isEmpty ?? true) { + if (PlatformInfos.isIOS) { + //await firebase.requestPermission(); + } try { //_fcmToken = await firebase.getToken(); if (_fcmToken == null) throw ('PushToken is null'); diff --git a/scripts/add-firebase-messaging.sh b/scripts/add-firebase-messaging.sh index fb845d71..af7ce025 100755 --- a/scripts/add-firebase-messaging.sh +++ b/scripts/add-firebase-messaging.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -flutter pub add fcm_shared_isolate:0.2.0 +flutter pub add fcm_shared_isolate flutter pub get if [[ "$OSTYPE" == "darwin"* ]]; then diff --git a/scripts/release-ios-testflight.sh b/scripts/release-ios-testflight.sh index 5eef1662..075324c6 100755 --- a/scripts/release-ios-testflight.sh +++ b/scripts/release-ios-testflight.sh @@ -1,5 +1,5 @@ #!/bin/sh -ve -flutter pub add fcm_shared_isolate:0.2.0 +flutter pub add fcm_shared_isolate sed -i '' 's,//,,g' lib/utils/background_push.dart flutter clean flutter pub get