我目前正在使用 FCM 进行推送通知。当我的应用程序打开时,我会收到通知,但是当应用程序关闭或在后台时 - 在我重新打开应用程序之前我不会收到任何消息。在 XCode 上,我启用了后台提取和远程通知。接下来我应该检查什么?谢谢你。
我在用 firebase_messaging: ^5.1.6
用代码
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('message is $message');
setState(
() {
showOverlayNotification((context) {
return GestureDetector(
onTap: () {},
child: Platform.isIOS
? MessageNotification(
title: message['notification']['title'],
body: message['notification']['body'],
)
: MessageNotification(
title: message['notification']['title'],
body: message['notification']['body'],
),
);
// }
}, duration: Duration(milliseconds: 4000));
},
);
},
onLaunch: (Map<String, dynamic> message) async {
print('launching');
},
onResume: (Map<String, dynamic> message) async {
print('resuming');
print("onResume: $message");
},
);
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, …Run Code Online (Sandbox Code Playgroud)