我正在使用iOS的Flutter应用中的推送通知。当应用程序不在后台时,我能够收到推送通知,但是当应用程序在后台时,我在日志中收到以下警告:
警告:UNUserNotificationCenter代表收到了对-userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:的调用:但从未调用完成处理程序。
以下是我用于注册推送通知的代码:
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) {
print('on message $message');
},
onResume: (Map<String, dynamic> message) {
print('on resume $message');
if (Navigator.of(context).canPop()) {
Navigator.of(context).popUntil((route) => route.isFirst);
print("after pop");
}
Navigator.of(context)
.push(MaterialPageRoute(
builder: (_) => FeedbackDetails(
feedbackModel: pushPayloadToFeedbackModel(message),
)))
.then((val) {
_feedbackListBloc.dispatch(FetchFeedbackList());
});
},
onLaunch: (Map<String, dynamic> message) {
print('on launch $message');
AppSettings settings = AppSettings();
if (!settings.isConfigured) {
Navigator.of(context).popUntil((route) => route.isFirst);
print("after pop");
Navigator.of(context)
.push(MaterialPageRoute(
builder: (_) => FeedbackDetails(
feedbackModel: pushPayloadToFeedbackModel(message),
)))
.then((val) {
_feedbackListBloc.dispatch(FetchFeedbackList());
});
settings.isConfigured = true;
}
},
);
以上代码是屏幕的init方法。