【发布时间】:2021-08-10 16:15:03
【问题描述】:
我正在按照这些步骤使用 firebase 消息向我的应用添加推送通知,但在所有这些步骤之后它不起作用
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
void firebaseTrigger(BuildContext ctx) async {
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onLaunch: $message");
Fluttertoast.showToast(
msg: message['notification']['title'],
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.TOP,
timeInSecForIosWeb: 6,
);
},
onLaunch: (Map<String, dynamic> message) async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => NotificationScreen(),
),
);
},
onResume: (Map<String, dynamic> message) async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => NotificationScreen(),
),
);
},
);
}
@override
void initState() {
super.initState();
firebaseTrigger(context);
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true, provisional: true));
_firebaseMessaging.onIosSettingsRegistered
.listen((IosNotificationSettings settings) {
print("Settings registered: $settings");
});
}
但推送通知仅适用于 ios,但适用于 android 任何人都可以帮助我解决我的问题
编辑:我的 appDelegate
【问题讨论】:
-
你在模拟器上运行吗?
-
查看我不熟悉 ios 的文档,但也可以查看 firebase.flutter.dev/docs/messaging/apple-integration
-
@GbengaBAyannuga 在真实设备中没有
-
@Assassin 我正在关注这份文件,但同样的问题
-
让我看看你的有效载荷
标签: flutter dart push-notification firebase-cloud-messaging