hua_wei_push_plugin 1.0.0
hua_wei_push_plugin: ^1.0.0

Flutter Android iOS

This plug-in is packaged based on the huawei Push SDK(hms push), providing common methods and listeners

hua_wei_push_plugin #

pub package

华为推送SDK Flutter插件
华为Push版本: v5.0.0.300

使用要求 #

Flutter Version >= 1.12
如果非华为手机测试,则必须在 手机上安装 华为移动服务(HMS Core),否则会报:Failed to find HMS apk错误,如果华为移动服务版本过低或权限不足(建议授予所有权限),会报:client api invalid

配置 #

Flutter #

hua_wei_push_plugin: ^[最新版本号]

Android #

  1. 生成证书 证书生成教程,并前往 华为开发者中心 [项目-应用] 中配置 SHA256证书指纹

  2. 修改 android\app\build.gradle 文件
    在末尾加入

    + apply plugin: 'com.huawei.agconnect'
    

    增加证书信息,例:

    android {
    
    +   signingConfigs {
    +       config {
    +           storeFile file('android.keystore')
    +           storePassword '123456'
    +           keyAlias 'android_test_key'
    +           keyPassword '123456'
    +           v1SigningEnabled true
    +           v2SigningEnabled true
    +       }
    +   }
    
        buildTypes {
    +       debug {
    +           signingConfig signingConfigs.config
    +       }
    +       release {
    +           // Signing with the debug keys for now, so `flutter run --release` works.
    +           signingConfig signingConfigs.config
    +       }
        }
    }
    
  3. 修改 android\build.gradle

    buildscript {
        repositories {
            google()
            jcenter()
    +       maven {url 'https://developer.huawei.com/repo/'}
        }
    
        dependencies {
    +       classpath 'com.huawei.agconnect:agcp:1.2.1.301'
        }
    }
    
  4. 前往华为开发者中心 [项目-应用]下载 agconnect-services.json

  5. agconnect-services.json放在android/app目录

使用 #

接口 #

接口说明参数
getToken获得Push Token{ appId: APP_ID }
deleteToken删除 Push Token{ appId: APP_ID }
getId获得ID-
getAAID获得AAID-
deleteAAID删除AAID-
getAppId获得AppId-
getCreationTime获得创建时间-
getValue获得agconnect-services.json文件的值,不同层级以 / 分开,例如 : client/package_nameString key
turnOnPush启用推送-
turnOffPush关闭推送-
subscribe订阅String topic
unsubscribe取消订阅String topic
setAutoInitEnabled设置自动初始化bool enabled
isAutoInitEnabled是否启用自动初始化-

监听器 #

添加监听器:HuaWeiPushPlugin.addListener,移除监听器:HuaWeiPushPlugin.removeListener
监听器方法原形: typedef ListenerValue<P> = void Function(HuaWeiPushListenerTypeEnum type, P params);

类型说明参数格式
MessageReceived接收透传消息Map
MessageSent发送上行消息成功回调方法String
MessageDelivered发送上行消息时如果使用了消息回执能力,消息到达App服务器后,App服务器的应答消息通过本方法回调给应用。MessageExceptionEntity
SendError发送上行消息失败回调方法MessageExceptionEntity
NewToken服务端更新token回调方法。String
TokenError申请token失败回调方法。ExceptionEntity

其它插件 #

我同时维护的还有以下插件,如果您感兴趣与我一起进行维护,请通过Github联系我,欢迎 issues 和 PR。
平台插件描述版本-
FlutterFlutterTencentImPlugin腾讯云IM插件pub package
FlutterFlutterTencentRtcPlugin腾讯云Rtc插件pub package
FlutterFlutterXiaoMiPushPlugin小米推送SDK插件pub package
FlutterFlutterHuaWeiPushPlugin华为推送(HMS Push)插件pub package
FlutterFlutterTextSpanField自定义文本样式输入框pub package
FlutterFlutterQiniucloudLivePluginFlutter 七牛云直播云插件暂未发布,通过 git 集成
3
likes
85
pub points
40%
popularity

This plug-in is packaged based on the huawei Push SDK(hms push), providing common methods and listeners

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

690717394@qq.com

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on hua_wei_push_plugin