Flutter在Ios中实现极光推送

发布于 17 天前 作者 phonegap100 198 次浏览 最后一次编辑是 17 天前 来自 分享

Flutter在Ios中实现极光推送完整视频教程地址: https://www.itying.com/goods-1120.html

一、Flutter Ios中极光推送步骤

1、创建flutter项目 配置应用Bundle ID(应用包名)

2、在极光推送官网注册账户、创建应用、配置证书

3、配置证书参考 https://docs.jiguang.cn/jpush/client/iOS/ios_cer_guide/ (具体看教程演示)

4、参考极光官方提供的jpush-flutter sdk集成极光推送 https://github.com/jpush/jpush-flutter-plugin https://pub.dev/packages/jpush_flutter

二、Flutter ios推送在Xcode中的一些配置

1、在 xcode8 之后需要点开推送选项: TARGETS -> Capabilities -> Push Notification 设为 on 状态 2.png

2、配置允许 Xcode 支持 Http 传输 http://bbs.itying.com/topic/5d6f42e52a95ee138cf28d2b

三、Flutter ios中监听极光消息推送代码

 @override
  void initState() {
    // TODO: implement initState
    super.initState();

    this.initPlatformState();
  }
  Future<void> initPlatformState() async {

    JPush jpush = new JPush();

    jpush.setAlias("jg123456").then((map) {

      print('--------别名设置成功-----');
    });

   
    jpush.getRegistrationID().then((rid) {
      print("rid--------$rid");
    });

    jpush.setup(
      appKey: "b0be128225f92e481f048384",
      channel: "developer-default",
      production: false,
      debug: true,
    );

    jpush.applyPushAuthority(
        new NotificationSettingsIOS(sound: true, alert: true, badge: true));
    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 {      
	print("Failed to get platform version");
    }
  }
1 回复
回到顶部