Skip to content

Commit

Permalink
Merge pull request #3 from xuexiangjys/dev/1.0.1
Browse files Browse the repository at this point in the history
Dev/1.0.1
  • Loading branch information
xuexiangjys authored Sep 21, 2019
2 parents 0462647 + 60e49f9 commit 9e64c04
Show file tree
Hide file tree
Showing 83 changed files with 4,898 additions and 203 deletions.
67 changes: 52 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![I](https://img.shields.io/github/issues/xuexiangjys/XPush.svg)](https://github.com/xuexiangjys/XPush/issues)
[![Star](https://img.shields.io/github/stars/xuexiangjys/XPush.svg)](https://github.com/xuexiangjys/XPush)

一个轻量级、可插拔的Android消息推送框架。一键集成推送(极光推送、友盟推送、华为、小米推送等),提供有效的保活机制,支持推送的拓展,充分解耦推送和业务逻辑,解放你的双手!
一个轻量级、可插拔的Android消息推送框架。一键集成推送(极光推送、友盟推送、信鸽推送、华为、小米推送等),提供有效的保活机制,支持推送的拓展,充分解耦推送和业务逻辑,解放你的双手!

在提issue前,请先阅读[【提问的智慧】](https://xuexiangjys.blog.csdn.net/article/details/83344235),并严格按照[issue模板](https://github.com/xuexiangjys/XPush/issues/new/choose)进行填写,节约大家的时间。

Expand Down Expand Up @@ -68,8 +68,9 @@

可是我们也不能将希望全都寄托在这个完全没有定数的事件上,代码终归要写,功能终归要上,与其受制于人,不如自己革命,搞一个自己能控制的消息推送全平台解决方案来得靠谱。

之前在QQ交流群里一直有人希望我开源一个消息推送框架,其实我在上一家公司的时候就写了一个推送框架,只不过捆绑业务太深,加之避开泄密之嫌,也就没有开源的必要。此次的推送框架完全是重新写了一个,加之全新的设计,会使框架更加通用,灵活
可能有人又会说,现在友盟和信鸽都支持厂商推送的集成,为何你自己还要搞一套呢?如果你对推送的及时性和到达率都没什么要求的话,其实也是无所谓的(实践证明,友盟并不好用,信鸽还可以)。在这里我需要说明的是,你不可能把自己的命运交到别人的手里,推送有别于其他的业务,相对来说比较复杂,需要处理大批量的事件消息,对服务器的要求比较大,你愿意把你的推送消息交给第三方推送平台去处理?再说了,你能强制你们后台接入指定第三方的推送平台?如果都不能,与其受制于人,何不把这些命运把握在自己的手上,那么写出来的功能自己心安啊

之前在QQ交流群里一直有人希望我开源一个消息推送框架,其实我在上一家公司的时候就写了一个推送框架,只不过捆绑业务太深,加之避开泄密之嫌,也就没有开源的必要。此次的推送框架完全是重新写了一个,加之全新的设计,会使框架更加通用,灵活。

----

Expand All @@ -93,9 +94,9 @@ allprojects {
dependencies {
...
//推送核心库
implementation 'com.github.xuexiangjys.XPush:xpush-core:1.0.0'
implementation 'com.github.xuexiangjys.XPush:xpush-core:1.0.1'
//推送保活库
implementation 'com.github.xuexiangjys.XPush:keeplive:1.0.0'
implementation 'com.github.xuexiangjys.XPush:keeplive:1.0.1'
}
```

Expand All @@ -105,10 +106,11 @@ dependencies {
dependencies {
...
//选择你想要集成的推送库
implementation 'com.github.xuexiangjys.XPush:xpush-jpush:1.0.0'
implementation 'com.github.xuexiangjys.XPush:xpush-umeng:1.0.0'
implementation 'com.github.xuexiangjys.XPush:xpush-huawei:1.0.0'
implementation 'com.github.xuexiangjys.XPush:xpush-xiaomi:1.0.0'
implementation 'com.github.xuexiangjys.XPush:xpush-jpush:1.0.1'
implementation 'com.github.xuexiangjys.XPush:xpush-umeng:1.0.1'
implementation 'com.github.xuexiangjys.XPush:xpush-huawei:1.0.1'
implementation 'com.github.xuexiangjys.XPush:xpush-xiaomi:1.0.1'
implementation 'com.github.xuexiangjys.XPush:xpush-xg:1.0.1'
}
```

Expand Down Expand Up @@ -191,7 +193,11 @@ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
<meta-data
android:name="XPush_MIPush_1003"
android:value="com.xuexiang.xpush.xiaomi.XiaoMiPushClient" />
<!--如果引入了xpush-xg库-->
<meta-data
android:name="XPush_XGPush_1004"
android:value="@string/xpush_xg_client_name" />
```

3.添加第三方AppKey和AppSecret.
Expand Down Expand Up @@ -228,6 +234,14 @@ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
<meta-data
android:name="MIPUSH_APPKEY"
android:value="\ 5371813415164"/>
<!--信鸽推送静态注册-->
<meta-data
android:name="XGPUSH_ACCESS_ID"
android:value="2100343759" />
<meta-data
android:name="XGPUSH_ACCESS_KEY"
android:value="A7Q26I8SH7LV" />
```

4.在Application中初始化XPush
Expand Down Expand Up @@ -296,7 +310,7 @@ private void initPush() {

* 通过调用`XPush.getTags()`,即可获取当前设备所有的标签。

需要注意的是,友盟推送目前暂不支持标签的获取,华为推送不支持标签的所有操作,小米推送每次只支持一个标签的操作。
需要注意的是,友盟推送和信鸽推送目前暂不支持标签的获取,华为推送不支持标签的所有操作,小米推送每次只支持一个标签的操作。

### 3、推送的别名(alias)处理

Expand All @@ -306,7 +320,7 @@ private void initPush() {

* 通过调用`XPush.getAlias()`,即可获取当前设备所绑定的别名。

需要注意的是,友盟推送目前暂不支持别名的获取,华为推送不支持别名的所有操作。
需要注意的是,友盟推送和信鸽推送目前暂不支持别名的获取,华为推送不支持别名的所有操作。

### 4、推送消息的接收

Expand Down Expand Up @@ -435,10 +449,11 @@ xpush://com.xuexiang.xpush/notification?title=这是一个通知&content=这是

推送平台 | 平台名 | 平台码 | 模块名 | 客户端类
:-|:-:|:-:|:-:|:-
极光推送 | JPush | 1000 | xpush-jpush | com.xuexiang.xpush.jpush.JPushClient
友盟推送 | UMengPush | 1001 | xpush-umeng | com.xuexiang.xpush.umeng.UMengPushClient
华为推送 | HuaweiPush | 1002 | xpush-huawei | com.xuexiang.xpush.huawei.HuaweiPushClient
小米推送 | MIPush | 1003 | xpush-xiaomi | com.xuexiang.xpush.xiaomi.XiaoMiPushClient
[极光推送](https://www.jiguang.cn/) | JPush | 1000 | xpush-jpush | com.xuexiang.xpush.jpush.JPushClient
[友盟推送](https://www.umeng.com/push) | UMengPush | 1001 | xpush-umeng | com.xuexiang.xpush.umeng.UMengPushClient
[华为推送](https://developer.huawei.com/consumer/cn/service/hms/pushservice.html) | HuaweiPush | 1002 | xpush-huawei | com.xuexiang.xpush.huawei.HuaweiPushClient
[小米推送](https://dev.mi.com/console/appservice/push.html) | MIPush | 1003 | xpush-xiaomi | com.xuexiang.xpush.xiaomi.XiaoMiPushClient
[信鸽推送](https://xg.qq.com/) | XGPush | 1004 | xpush-xg | com.xuexiang.xpush.xg.XGPushClient

### 推送平台的注意事项

Expand All @@ -452,6 +467,12 @@ xpush://com.xuexiang.xpush/notification?title=这是一个通知&content=这是

* 友盟推送不支持监听推送的连接状态。

#### 信鸽推送

* 信鸽推送不支持Tag和alias的获取

* 信鸽推送不支持监听推送的连接状态。

#### 华为推送

* 华为推送在注册之前需要安装最新的推送服务,否则将无法注册成功(库会自动弹出升级或者安装提示)
Expand Down Expand Up @@ -564,6 +585,13 @@ public interface IPushClient {

以上即完成了推送平台的集成。剩下的就是在初始化XPush的时候对推送平台进行选择了.如果你看完了还是不会的话,你可以参考项目中的[xpush-xiaomi](https://github.com/xuexiangjys/XPush/tree/master/xpush-xiaomi)[xpush-huawei](https://github.com/xuexiangjys/XPush/tree/master/xpush-huawei).


## 保活机制说明

> 这里提供的应用保活机制也是借鉴了前人终结出来的各种方案的混合处理。目前在9.0及以下版本都能有很好的保活效果(只要你不主动杀死程序),如果你的应用希望能够一直在后台运行(比如推送服务)而不被系统自动杀死的话,可以尝试一下。需要注意的是,程序保活并不代表能做到程序杀不死,除非你把你的应用做成系统应用或者加入到系统的白名单内,否则也只是提高了程序的优先级权重,减少程序被系统回收杀死的概率而已。
关于保活机制的使用可以参考[保活机制使用](https://github.com/xuexiangjys/XPush/wiki/%E4%BF%9D%E6%B4%BB%E6%9C%BA%E5%88%B6%E4%BD%BF%E7%94%A8)

---

## 实体介绍
Expand Down Expand Up @@ -693,6 +721,12 @@ CONNECTED | 12 | 已连接
-keep class com.ut.**{*;}
-keep class com.ta.**{*;}
# 信鸽推送
-keep class com.tencent.android.tpush.** {*;}
-keep class com.tencent.mid.** {*;}
-keep class com.qq.taf.jce.** {*;}
-keep class com.tencent.bigdata.** {*;}
# 华为推送
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.android.hms.agent.**{*;}
Expand All @@ -706,9 +740,12 @@ CONNECTED | 12 | 已连接

* [OnePush](https://github.com/pengyuantao/OnePush)
* [keeplive](https://github.com/fanqieVip/keeplive)
* [HelloDaemon](https://github.com/xingda920813/HelloDaemon)

## 如果觉得项目还不错,可以考虑打赏一波

> 你的打赏是我维护的动力,我将会列出所有打赏人员的清单在下方作为凭证,打赏前请留下打赏项目的备注!
![](https://github.com/xuexiangjys/Resource/blob/master/img/pay/alipay.jpeg) &emsp; ![](https://github.com/xuexiangjys/Resource/blob/master/img/pay/weixinpay.jpeg)

## 联系方式
Expand Down
1 change: 1 addition & 0 deletions app-xgdemo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
132 changes: 132 additions & 0 deletions app-xgdemo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (C) 2019 xuexiangjys([email protected])
*
* 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.
*
*/

apply plugin: 'com.android.application'
apply plugin: 'com.xuexiang.xaop' //引用xaop插件

android {
compileSdkVersion build_versions.target_sdk
buildToolsVersion build_versions.build_tools

defaultConfig {
applicationId "com.xuexiang.xgdemo"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

ndk {
// 设置支持的SO库
abiFilters 'armeabi', 'x86'
//,'armeabi-v7a', 'x86', 'x86_64', 'arm64-v8a','mips','mips64'

manifestPlaceholders = [
XG_ACCESS_ID : "2100343749",
XG_ACCESS_KEY: "AM1AL86JK12B",
HW_APPID : "101139333",
PACKAGE_NAME : "com.xuexiang.xgdemo"
]
}
}

signingConfigs {
if (isNeedPackage.toBoolean()) {
release {
storeFile file(app_release.storeFile)
storePassword app_release.storePassword
keyAlias app_release.keyAlias
keyPassword app_release.keyPassword
}
}
debug {
storeFile file("./debug.jks")
storePassword "123456"
keyAlias "debug"
keyPassword "123456"
}
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (isNeedPackage.toBoolean()) {
signingConfig signingConfigs.release
}
}

debug {
debuggable true
minifyEnabled false
signingConfig signingConfigs.debug
}
}

if (isNeedPackage.toBoolean()) {
applicationVariants.all { variant ->
variant.outputs.all {
if (variant.buildType.name.equals('release')) {
outputFileName = "xgdemo_${defaultConfig.versionName}.apk"
}
}
}
}

lintOptions {
abortOnError false
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation deps.support.app_compat
testImplementation deps.junit
androidTestImplementation deps.runner
androidTestImplementation deps.espresso.core

//工具类
implementation 'com.github.xuexiangjys.XUtil:xutil-core:1.1.6'
implementation 'com.github.xuexiangjys.XUtil:xutil-sub:1.1.6'
//切片
implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:1.0.5' //添加依赖

//XPage
implementation 'com.github.xuexiangjys.XPage:xpage-lib:2.2.6'
annotationProcessor 'com.github.xuexiangjys.XPage:xpage-compiler:2.2.6'
//ButterKnife的sdk
implementation deps.butterknife.runtime
annotationProcessor deps.butterknife.compiler
//如果开启了内存泄漏监测leak,就需要加上这个依赖
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'

implementation project(path: ':xpush-core')
implementation project(path: ':xpush-xg')

//信鸽华为推送
implementation 'com.tencent.xinge:xghw:4.3.2-huawei-release'
//信鸽小米推送
implementation 'com.tencent.xinge:mipush:4.3.2-xiaomi-release'
//信鸽SDK
implementation 'com.tencent.xinge:xinge:4.3.5-release'


}
Binary file added app-xgdemo/debug.jks
Binary file not shown.
Loading

0 comments on commit 9e64c04

Please sign in to comment.