![](/img/trans.png)
[英]flutter notification is not coming in ios when app is on kill state but when we open the app notification is coming
[英]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
我正在开发一个具有推送通知属性的颤振应用程序,当应用程序处于前台或后台通知连续发出时一切正常,但是当应用程序处于终止状态时意味着当应用程序不在后台时,通知不会出现,为什么?
并且在 android 通知中在所有状态下都能正常工作(前台、后台、应用程序终止时的终止状态)
这是我在 IOS 中发送通知的有效负载
{"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"}]}
您可以在发布模式下进行测试;
在你的主要
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.