Lin*_*ode 3 ios dart flutter firebase-cloud-messaging
我的通知在 android 中工作没有任何问题,但在 iOS 中我无法弄清楚似乎是什么问题。
我正在使用firebase_messaging插件,并在我的main.dart输入:
@override
void initState() {
super.initState();
if (Platform.isIOS)
this.fbaseMessaging.requestNotificationPermissions(
IosNotificationSettings(sound: true, badge: true, alert: true),
);
}
Run Code Online (Sandbox Code Playgroud)
当用户登录时,我获取令牌:
fbaseMessaging.getToken().then((token) {
// Updates the user account
});
Run Code Online (Sandbox Code Playgroud)
我已经在 Xcode Simulator、TestFlight 的 iOS 设备以及已发布的版本中进行了测试,但从未收到任何通知,也不知道如何调试问题出在哪里。
遵循了几个教程,例如:
解决了。
我所要做的就是改变这个:
if (Platform.isIOS)
{
this.fbaseMessaging.requestNotificationPermissions(
IosNotificationSettings(sound: true, badge: true, alert: true),
);
}
Run Code Online (Sandbox Code Playgroud)
对此:
if (Platform.isIOS)
{
this.fbaseMessaging.configure();
this.fbaseMessaging.requestNotificationPermissions(
IosNotificationSettings(sound: true, badge: true, alert: true),
);
}
Run Code Online (Sandbox Code Playgroud)
似乎即使我不使用onResume, onLaunch&onMessage该configure方法也必须被调用。