Фоновое уведомление Flutter Firebase не работает для iOSIOS

Программируем под IOS
Ответить
Anonymous
 Фоновое уведомление Flutter Firebase не работает для iOS

Сообщение Anonymous »

Я реализую Firebase Cloud Messaging (FCM) в своем приложении Flutter для обработки push-уведомлений. Однако я столкнулся со следующей проблемой:
  • Передний план: уведомления получены и успешно обработаны.
  • Фон ​​или Прекращено: уведомления не приходят, и я не могу с ними справиться.
Я просмотрел все остальные вопросы и ответы, но не смог решить моя проблема, даже я пробую все
Версии main.dart

Код: Выделить всё

@pragma('vm:entry-point')
Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print("Handling a background message: ${message.messageId}");

// Firebase'i başlatın

// Burada bildirimi işleyebilirsiniz
}

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,  // Firebase config dosyasını doğru şekilde eklediğinizden emin olun.
);
NotificationSettings settings = await FirebaseMessaging.instance.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

@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// This is required to make any communication available in the action isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}

if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}

GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

}
данные

Код: Выделить всё

{
"message": {
"token": "",
"data": {
"receiver-id": "HBJq0SpqsrtoWjwIaH7kky14g4VZl53",
},
"notification": {
"title": "Test Notification",
"body": "This is a test message",
},
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"content-available": 1
}
}
}
}
}
info.plist

Код: Выделить всё




CADisableMinimumFrameDurationOnPhone

CFBundleDevelopmentRegion
$(DEVELOPMENT_LANGUAGE)
CFBundleDisplayName
Snapstory
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
snapstory
CFBundlePackageType
APPL
CFBundleShortVersionString
$(FLUTTER_BUILD_NAME)
CFBundleSignature
????
CFBundleURLTypes


CFBundleTypeRole
Editor
CFBundleURLSchemes

com.googleusercontent...



CFBundleVersion
$(FLUTTER_BUILD_NUMBER)
FirebaseAppDelegateProxyEnabled

LSRequiresIPhoneOS

NSCameraUsageDescription
Image Picker
NSMicrophoneUsageDescription
Image Picker
NSPhotoLibraryUsageDescription
Image Picker
UIApplicationSupportsIndirectInputEvents

NSPhotoLibraryAddUsageDescription
Fotoğraf kütüphanesine fotoğraf kaydetmek için izin gerekiyor.
UISupportsDocumentBrowser

UIBackgroundModes

processing
fetch
remote-notification

BGTaskSchedulerPermittedIdentifiers

dev.flutter.background.refresh

UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UISupportedInterfaceOrientations

UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight

UISupportedInterfaceOrientations~ipad

UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight



Я стараюсь

Код: Выделить всё

FirebaseAppDelegateProxyEnabled

но не работает

Подробнее здесь: https://stackoverflow.com/questions/792 ... ng-for-ios
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»