Я работаю с обменом облачными сообщениями Firebase в проекте Flutter, и у меня есть проблема, где FireBasemessaging.onmessageopendapp не запускается на Android 15, и FireBaseMessaging.Instance.getInitialMessage () return null Когда приложение открыто через уведомление. /> Вот класс, который я использую для обработки уведомлений. < /p>
// notification_controller.dart
import 'package:firebase_messaging/firebase_messaging.dart';
class NotificationController {
final FirebaseMessaging \_firebaseMessaging = FirebaseMessaging.instance;
// Initialize Firebase Messaging
void initialize() {
// Request for permission on iOS
_firebaseMessaging.requestPermission();
// Get the token to identify the device
_firebaseMessaging.getToken().then((token) {
print("Firebase Messaging Token: $token");
});
// Handle the background message
FirebaseMessaging.onBackgroundMessage(_backgroundMessageHandler);
// Handle foreground messages
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Message received: ${message.notification?.title}');
// You can add custom behavior for foreground messages here
});
// Handle when the app is opened via a notification
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print('Opened from onMessageOpenedApp: ${message.toMap()}');
_handleNavigation(message);
});
// Handle initial message when the app is launched
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage? message) {
print('Opened from getInitialMessage: ${message?.notification?.title}');
if (message != null) {
_handleNavigation(message);
}
});
}
// Background message handler (optional)
static Future _backgroundMessageHandler(message) async {
print("Background message received: ${message.notification?.title}");
}
// Handle navigation based on the notification payload
void _handleNavigation(message) {}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... nitialmess
FireBaseMessaging.onmessageopenedApp не запускается на Android 15, GetInitialMessage возвращает NULL ⇐ Android
Форум для тех, кто программирует под Android
1741932039
Anonymous
Я работаю с обменом облачными сообщениями Firebase в проекте Flutter, и у меня есть проблема, где FireBasemessaging.onmessageopendapp не запускается на Android 15, и FireBaseMessaging.Instance.getInitialMessage () return null Когда приложение открыто через уведомление. /> Вот класс, который я использую для обработки уведомлений. < /p>
// notification_controller.dart
import 'package:firebase_messaging/firebase_messaging.dart';
class NotificationController {
final FirebaseMessaging \_firebaseMessaging = FirebaseMessaging.instance;
// Initialize Firebase Messaging
void initialize() {
// Request for permission on iOS
_firebaseMessaging.requestPermission();
// Get the token to identify the device
_firebaseMessaging.getToken().then((token) {
print("Firebase Messaging Token: $token");
});
// Handle the background message
FirebaseMessaging.onBackgroundMessage(_backgroundMessageHandler);
// Handle foreground messages
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Message received: ${message.notification?.title}');
// You can add custom behavior for foreground messages here
});
// Handle when the app is opened via a notification
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print('Opened from onMessageOpenedApp: ${message.toMap()}');
_handleNavigation(message);
});
// Handle initial message when the app is launched
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage? message) {
print('Opened from getInitialMessage: ${message?.notification?.title}');
if (message != null) {
_handleNavigation(message);
}
});
}
// Background message handler (optional)
static Future _backgroundMessageHandler(message) async {
print("Background message received: ${message.notification?.title}");
}
// Handle navigation based on the notification payload
void _handleNavigation(message) {}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79507625/firebasemessaging-onmessageopenedapp-not-triggered-on-android-15-getinitialmess[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия