Flutter配置极光推送

这个文章讲述了如何生成p12文件,描述文件等https://www.jianshu.com/p/47e2a6453bbc

切记使用极光推送,需要在Identifiers中勾选push notification服务,并且点击edit配置证书,最终生成两个push服务的dev和prod的两个证书,最终上传到极光推送,关于生成证书,参考上面这个文章,是同理的。

image.png

1. 添加极光推送依赖包

jpush_flutter,添加jpush_flutter依赖

flutter pub add jpush_flutter

2.在main.dart文件中初始化jpush

 final JPush jpush = new JPush();
 jpush.setup(
    appKey: 极光推送官网配置的key,
    channel: 这个随意,
    production: true,
    debug: true,
  );

  if (Platform.isIOS) {
    jpush.applyPushAuthority(
        new NotificationSettingsIOS(sound: true, alert: true, badge: true));
  }

3.在android/app/src/build.gradle中添加配置

android{
   defaultConfig{
        .....,
        manifestPlaceholders = manifestPlaceholders + [
          JPUSH_PKGNAME: 极光推送官网配置的package name,
          JPUSH_APPKEY : 极光推送官网配置的key,
          JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
        ]
   }
}

4.使用xcode打开ios/Runner文件

双击Runner,然后再点击右上角加号,选择notification服务,并且添加。


image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容