话不多说上效果图(效果图为练手项目,不要在意)

极光推送flutter 版github 地址 https://github.com/jpush/jpush-flutter-plugin
极光后台配置此处不再一一赘述。
Android:
在 /android/app/build.gradle 中添加下列代码:

修改 main.dart
重写 initState 方法。调用下面函数。

Future<void> initPlatformState() async {
String platformVersion;
jpush.getRegistrationID().then((rid) {
print(rid);
});
jpush.setup(
appKey: "114311f50bb78a9fef2e86b1",
channel: "theChannel",
production: false,
debug: true,
);
jpush.applyPushAuthority(new NotificationSettingsIOS(
sound: false,
alert: false,
badge: false));
try {
jpush.addEventHandler(
onReceiveNotification: (Map<String, dynamic> message) async {
print("flutter onReceiveNotification: $message");
},
onOpenNotification: (Map<String, dynamic> message) async {
print("flutter onOpenNotification: $message");
},
onReceiveMessage: (Map<String, dynamic> message) async {
print("flutter onReceiveMessage: $message");
},
);
}
on Exception {
platformVersion = 'Failed to get platform version.';
}
}
可以看到,极光推送已经有相关函数监听。
极光推送Flutter版集成指南
本文详细介绍了如何在Flutter项目中集成极光推送服务,包括Android平台的配置步骤、关键代码示例以及推送消息的监听函数实现。
1181

被折叠的 条评论
为什么被折叠?



