华为推送只有在签名发布包环境下才可以收到推送消息
华为手机中的移动推送服务,必须升级到 2.5.3 以上版本
访问 华为开放平台。
注册/登录开发者账号。(如果您是新注册账号,需进行实名认证).
在华为推送平台中新建应用。注意:应用包名需跟您在GIO集成的包名保持一致
allprojects {repositories {google()jcenter()mavenLocal()// 华为仓库maven { url 'http://developer.huawei.com/repo/' }}}
dependencies {...//由于推送底层网络库依赖OkHttp3网络库,请添加OkHttp3依赖implementation 'com.squareup.okhttp3:okhttp:3.12.1'//推送SDK依赖implementation 'com.growingio.android:gtouch:$gtouch_version'//华为推送SDK依赖implementation 'com.growingio.android.gpush:gpush-huawei-adapter:$gtouch_version'}
$gtouch_version 为最新SDK版本号,现最新的版本号为请参考SDK更新日志。
android {......defaultConfig {manifestPlaceholders = [PACKAGE_NAME : "您的APP包名",GPUSH_HUAWEI_APP_ID : "华为推送的AppId(华为推送不需要AppKey)",]......}......}
-ignorewarning-keepattributes *Annotation*-keepattributes Exceptions-keepattributes InnerClasses-keepattributes Signature-keepattributes SourceFile,LineNumberTable-keep class com.hianalytics.android.**{*;}-keep class com.huawei.updatesdk.**{*;}-keep class com.huawei.hms.**{*;}-keep class com.huawei.android.hms.agent.**{*;}
在华为推送APP编辑界面配置回执,以便于我们GrowingIO更好的统计推送数据
目前单击【测试回执】,会提示“https,error",请忽略并直接单击【提交】。
其中回调地址
https://messages.growingio.com/v1/callback/huawei
HTTPS证书
-----BEGIN CERTIFICATE-----MIIGeDCCBWCgAwIBAgIQHjNQWZ7wMj3+VB9p4KLDpTANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQDEy5TZWN0aWdvIFJTQSBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMB4XDTE5MDkwMjAwMDAwMFoXDTI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SCAW0EggFpAWcAdQD2XJQv0XcwIhRUGAgwlFaO400TGTO/3wwvIAvMTvFk4wAAAWzw+80wAAAEAwBGMEQCIGa+uxrn7YC1pHF1e8ajPOSffMhJoEhupvQxBQdeLEr6AiA6xE7pgIygEdLyI4zI/CF0H9M911aDZoPYERBHrmQL9QB3AESUZS6w7s6vxEAH2Kj+KMDa5oK+2MsxtT/TM5a1toGoAAABbPD7zUsAAAQDAEgwRgIhAKWEZ0RAxmqqM3bqPQmwNt02RTN7dEFB1xKZVmbP+CtAAiEAp+TfxTUlIxw3UinKhEjdAZw7WDz/wiDZvR7y4vFGWXIAdQBVgdTCFpA2AUrqC5tXPFPwwOQ4eHAlCBcvo6odBxPTDAAAAWzw+80nAAAEAwBGMEQCIE3arRcTs+XLCj5HDiDZhV1QkOMCqwnTp3NVqkLXdecXAiA3xzd97tQnMIj6BIuYbfE+sONRUe4klZiFhwstlx4LTDANBgkqhkiG9w0BAQsFAAOCAQEARChCUxNikK3PpBPy3vGbKeVra4TlbGKygI+8eaKrR5ShM3EdehQuZKxtX0wrklRbWRdRXpBqXOz2NCWa8yFq1Z2Nu/14bUe/vXmxcF/1xTRvanPlgD4bDlupkXK6asspDvy1lr+N4cYf63Q/UxkEbGFHbXdqsylZZNxrvy7Ax4cofMRNCSF6KduF9Er34duYBCBUYlEXI0UvuuecQ1BWIebjaruDj4vDtYN1wOEUoAWine0aBcFs6n04ii1vhi+4mtB5G9XnbakaNan/8iujJ8djRa9Pxs8lwIAhNayYnjUWqO+XImV7pBXFMpwSdsW0X1cqHsNFvpf/5MHiNpuBuw==-----END CERTIFICATE-----
将集成好的App(测试版本)安装在一台华为测试机上,并且运行App
保持App在前台运行,尝试扫码测试推送消息
如果应用收到消息,将App退到后台,并且杀掉所有App进程
再次进行测试推送消息,如果能够收到推送,则表明厂商通道集成成功
最好能根据官方推荐方式,先测通华为官方推送
如果您的app已经集成了个推VIP或极光VIP版本等其他包含了华为推送sdk的第三方推送平台SDK,我们的android sdk也能兼容。
为了和个推兼容,我们将厂商通道独立打包。以华为推送通道为例,我们打包两个SDK:gpush-hms-agent和gpush-huawei-adapter。如果是从未接过个推、极光等VIP版本的用户可以直接添加华为推送通道依赖
implementation 'com.growingio.android.gpush:gpush-huawei-adapter:$gtouch_version'
如果是个推、极光等VIP版本的用户可以将华为官方SDK包gpush-hms-agent 排除出去。
implementation ('com.growingio.android.gpush:gpush-huawei-adapter:$gtouch_version'){exclude(group: 'com.growingio.android.gpush' , module: 'gpush-hms-agent')}