I’m implementing Firebase Cloud Messaging (FCM) in my Flutter app to deal with push notifications. Nevertheless, I’ve encountered the next concern:
- Foreground: Notifications are obtained and processed efficiently.
- Background or Terminated: Notifications usually are not obtained, and I can’t deal with them.
I’ve appeared all the different questions and solutions however I could not clear up my drawback even I attempt every part
Variations
Flutter 3.24.5 • channel secure
Xcode Model 16.1
firebase_messaging: ^15.1.6
flutter_local_notifications: ^18.0.1
IOS 18
fundamental.dart
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print("Dealing with a background message: ${message.messageId}");
// Firebase'i başlatın
// Burada bildirimi işleyebilirsiniz
}
void fundamental() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
choices: DefaultFirebaseOptions.currentPlatform, // Firebase config dosyasını doğru şekilde eklediğinizden emin olun.
);
NotificationSettings settings = await FirebaseMessaging.occasion.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false, // Zorunlu bildirim yerine geçici izni aktive eder
sound: true,
);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(MyApp());
}
AppDelegate.swift
import UIKit
import Flutter
import Firebase
import FirebaseCore
import flutter_local_notifications
@fundamental
@objc class AppDelegate: FlutterAppDelegate {
override func software(
_ software: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// That is required to make any communication accessible within the motion isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
if #accessible(iOS 10.0, *) {
UNUserNotificationCenter.present().delegate = self as UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return tremendous.software(software, didFinishLaunchingWithOptions: launchOptions)
}
}
knowledge
{
"message": {
"token": "",
"knowledge": {
"receiver-id": "HBJq0SpqsrtoWjwIaH7kky14g4VZl53",
},
"notification": {
"title": "Take a look at Notification",
"physique": "This can be a take a look at message",
},
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"content-available": 1
}
}
}
}
}
information.plist
<?xml model="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Snapstory</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>snapstory</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent...</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Picture Picker</string>
<key>NSMicrophoneUsageDescription</key>
<string>Picture Picker</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Picture Picker</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Fotoğraf kütüphanesine fotoğraf kaydetmek için izin gerekiyor.</string>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>processing</string>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>dev.flutter.background.refresh</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Foremost</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
I attempt
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
however not work