# AndroidPush **Repository Path**: gttdlm/AndroidPush ## Basic Information - **Project Name**: AndroidPush - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-07-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 更方便的将各个rom厂商自己的推送服务进行集成,并统一管理,使用前还是需要熟悉各个平台的相关文档 ### 各个平台的说明 >1. MIUI系统将使用[小米推送](http://dev.xiaomi.com/doc/?page_id=1670) >2. Flyme系统将使用[魅族推送](https://open.flyme.cn/open-web/views/push.html?t=1476262864945) >3. EMUI系统将使用[华为推送](http://developer.huawei.com/push) >4. 其他系统将使用[JPush推送](https://www.jiguang.cn) ### 集成 >1. 将如下4个SDK集成到项目中 >* 华为SDK 请自行去[官网](http://developer.huawei.com/push)下载(推荐)或者[点击这里](https://raw.githubusercontent.com/jiang111/AndroidPush/master/push/libs/HwPush_SDK_V2705.jar) 并添加依赖 >* 小米SDK 请自行去[官网](http://dev.xiaomi.com/doc/?page_id=1670)下载(推荐)或者[点击这里](https://raw.githubusercontent.com/jiang111/AndroidPush/master/push/libs/MiPush_SDK_Client_3_1_2.jar) 并添加依赖 >* 魅族SDK 在app模块下依赖:compile 'com.meizu.flyme.internet:push-internal-publish:3.3.+@aar' >* JPushSDK 在app模块下依赖:compile 'cn.jiguang:jpush:2.1.8' >* 注意资源文件的配置,目前只有华为的需要,请去官网查看最新版是否需要这些资源 [华为推送官网](http://developer.huawei.com/push) [点我查看资源配置](https://github.com/jiang111/AndroidPush/tree/master/push/src/main) >2. 在app模块下新建包,包名为push(也可以叫其他名字),然后把如下代码全部拷贝进push包里 [点我查看代码](https://raw.githubusercontent.com/jiang111/AndroidPush/master/code.zip) 源码在[这里](https://github.com/jiang111/AndroidPush/tree/master/push/src/main/java/com/jiang/android/push) >3. 配置APP下的Manifest.xml文件 [注意:如出现推送不成功请仔细检查manifest里对该平台集成是否正确!!!] ``` //权限通用配置 //小米的权限 //华为的权限 //魅族的权限 //极光的配置 //下面的配置需要复制到 application 节点下面 //小米 //魅族 //华为 //极光 ``` >4. 在app下的gradle文件加上如下这几句话 ``` //app下的gradle android { ... defaultConfig { ndk { abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a' } //如果有多渠道,请将下面的代码同样放一份到多渠道里面 manifestPlaceholders = [ JPUSH_APPKEY : "替换成自己的appkey", JPUSH_CHANNEL : " 替换成自己的channel", PNAME : applicationId ] } } ``` 至此,集成已经全部搞定。 ### 使用 * 在使用推送之前,请在gradle中配置JPUSH_APPKEY字段为jpush平台的key,华为不需要配置key,他会在注册的时候自动生成key,在小米和魅族开放平台申请的id和key进行配置,小米和魅族的配置方法: ``` Const.setMiUI_APP("APP_MIUI_ID", "APP_MIUI_KEY"); Const.setFlyme_APP("APP_FLYME_ID", "APP_FLYME_KEY"); ``` * 创建PushInterface接口的子类,并在相关的方法里实现自己的业务逻辑,并在Push类中进行配置。 ``` Push.setPushInterface(pushInterface); ``` * 注册推送服务,这里会根据自己的rom型号自动配置相关的推送服务: ``` Push.register(this, BuildConfig.DEBUG); //BuildConfig.DEBUG代表是否开启各个推送服务的debug功能. ``` * 获取当前rom平台: ``` RomUtil.rom(); ``` ### 混淆 请参考 https://github.com/jiang111/AndroidPush/blob/master/push/proguard-rules.pro ### 注意项 不要直接将库引用到自己的项目,而是要将代码拷贝到项目里,如果推送不成功,请仔细查看官网的说明文档 ### 各个推送平台的特点 1. 小米和极光推送做的都差不多,通知栏和透传消息都可以自己控制,没什么可说的. 2. flyme推送 无法对通知栏做任何的控制(除了改改样式),一切都由后台控制 透传消息的话,在Receiver的onMessage()的回调中使用. 3. 华为推送 如果推送的消息类型为透传消息的话,则无法使用extra字段,只可以用onPushMsg()回调中的 byte[] msg 参数. 通知栏的话,由于点击动作和魅族一样,都是由后台控制. ### 常见rom的区分 参考自: http://www.jianshu.com/p/6e6828755667 ### 其他不错的库 >* android开发不得不收集的小知识点 https://github.com/jiang111/awesome-android-tips >* 仿iOS下载按钮 https://github.com/jiang111/CProgressButton >* 可指定任意位置的指向性对话框 https://github.com/jiang111/IndicatorDialog >* 通过RecyclerView实现的联系人 https://github.com/jiang111/IndexRecyclerView >* 学习RxJava操作符的APP https://github.com/jiang111/RxJavaApp ### 捐赠 如果您觉得本项目对您有帮助,欢迎请作者一杯咖啡

![](https://raw.githubusercontent.com/jiang111/RxJavaApp/master/qrcode/wechat_alipay.png) ### License Copyright 2016 NewTab Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.