[英]I have an issue in my flutter IOS app when i try to send notification in kill state(when App Terminated) notification is not coming
I am developing a flutter app which have push notification property , everything is working fine when app is on foreground or background notification coming continuously , but when app is on terminated state means when app not on background then notification is not coming why ?我正在开发一个具有推送通知属性的颤振应用程序,当应用程序处于前台或后台通知连续发出时一切正常,但是当应用程序处于终止状态时意味着当应用程序不在后台时,通知不会出现,为什么?
and in android notification working properly in all states (Foreground ,Background,Kill State when app terminated)并且在 android 通知中在所有状态下都能正常工作(前台、后台、应用程序终止时的终止状态)
This is my Payload for sending notification in IOS这是我在 IOS 中发送通知的有效负载
{"to":"Device-token","content_available":true,"data":{"title":"Message","body":"Lorem Ipsum is simply dummy text of the printing and typesetting industry.","date":"Tue, 12 Jul 2022","time":"11:53","click_action":"FLUTTER_NOTIFICATION_CLICK","show_title":"Test Notification Title.","id":123,"checkdate":"2022-07-12","image":"https://crm.satoshifx.com/assets/images/satoshifx-notification.jpg"}}{"multicast_id":2817247928782996095,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"1657619612508875"}]} {"to":"Device-token","content_available":true,"data":{"title":"Message","body":"Lorem Ipsum 只是印刷和排版行业的虚拟文本。", "date":"Tue, 12 Jul 2022","time":"11:53","click_action":"FLUTTER_NOTIFICATION_CLICK","show_title":"测试通知标题。","id":123,"checkdate" :"2022-07-12","image":"https://crm.satoshifx.com/assets/images/satoshifx-notification.jpg"}}{"multicast_id":2817247928782996095,"success":1,"失败":0,"canonical_ids":0,"results":[{"message_id":"1657619612508875"}]}
You can test this on release mode;您可以在发布模式下进行测试;
In your main在你的主要
void main() async {
WidgetsFlutterBinding.ensureInitialized();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
runApp(const RestartWidget(child: const MyApp()));
}
///Define this outside your main
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.