Skip to content

Commit

Permalink
update push
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Jan 26, 2019
1 parent 72d9238 commit 4e1b318
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 48 deletions.
9 changes: 7 additions & 2 deletions chat/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Expand Down Expand Up @@ -177,7 +177,12 @@
<activity android:name="cn.wildfire.chat.channel.ChannelInfoActivity" />
<activity
android:name="cn.wildfire.chat.main.MainActivity"
android:label="火信" />
android:label="火信">
<intent-filter>
<action android:name="cn.wildfirechat.chat.main" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<provider
android:name="cn.wildfire.chat.third.utils.FilePickerProvider"
Expand Down
1 change: 1 addition & 0 deletions chat/src/main/java/cn/wildfire/chat/app/MyApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void onCreate() {
ProcessLifecycleOwner.get().getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onForeground() {
PushService.clearNotification(MyApp.this);
isBackground = false;
}

Expand Down
24 changes: 24 additions & 0 deletions push/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#推送说明
1. 目前集成了小米、华为、魅族推送,开发者可以自行集成其他推送。小米、华为、魅族手机上,分别走各家自己的推送;其他手机走小米推送。
2. 项目中的key等,只供测试使用,开发者需要自行申请相关key等。

##小米推送
1. 小米支持透传和通知栏推送,目前voip相关消息,走透传推送,其他消息,走通知栏推送。透传和通知栏的差别如下表:

| | 透传推送 | 通知栏推送 |
| ---------- | ------------------------------ | ---------------------------- |
| 允许自启动 | 通知栏不弹出通知,但拉活应用 | 通知栏弹出通知,并拉活应用 |
| 禁止自启动 | 通知栏不弹出通知,也不拉活应用 | 通知栏弹出通知,但不拉活应用 |

2. 当允许自启动,并采用通知栏推送时,通知栏会重复

## 华为推送

todo

## 魅族推送

todo



21 changes: 0 additions & 21 deletions push/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,3 @@ dependencies {
implementation project(':client')
implementation 'com.meizu.flyme.internet:push-internal:3.4.2@aar'
}

//apply plugin: 'com.novoda.bintray-release'
////设置所有工程编码为UTF-8编码,防止出现编码GBK的不可映射字符
//allprojects {
// tasks.withType(Javadoc) {
// options {
// encoding "UTF-8"
// charSet 'UTF-8'
// links "http://docs.oracle.com/javase/7/docs/api"
// }
// }
//}
//
//publish {
// userOrg = 'wfchat'
// groupId = 'cn.wildfirechat'
// artifactId = 'push'
// publishVersion = android.defaultConfig.versionName
// desc = 'Oh hi, this is a nice description for a project, right?'
// website = 'https://github.com/novoda/bintray-release'
//}
16 changes: 3 additions & 13 deletions push/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- the following 2 com.xiaomi.mipushdemo should be changed to your package name -->
<permission
android:name="${APP_ID}.permission.MIPUSH_RECEIVE"
android:protectionLevel="signature" />
android:protectionLevel="signatureOrSystem" />

<uses-permission android:name="${APP_ID}.permission.MIPUSH_RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
Expand All @@ -31,21 +31,10 @@
<uses-permission android:name="com.meizu.c2dm.permission.RECEIVE" />
<permission
android:name="${APP_ID}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
android:protectionLevel="signature" />
<uses-permission android:name="${APP_ID}.permission.C2D_MESSAGE" />

<application>
<!--getui -->
<!-- 用户自定义服务继承自GTIntentService,作为SDK与APP桥梁服务,用来接收各种消息和命令回复-->
<!-- 主进程-->
<service android:name="cn.wildfirechat.push.getui.GetuiIntentService" />

<!-- 配置SDK核心服务 -->
<service
android:name="cn.wildfirechat.push.getui.GetuiPushService"
android:exported="true"
android:label="PushService"
android:process=":pushservice" />

<!--huawei-->
<!-- value的值“xxx”用实际申请的应用ID替换,来源于开发者联盟网站应用的服务详情。-->
Expand Down Expand Up @@ -153,6 +142,7 @@
</intent-filter>
</receiver>

<!--meizu-->
<receiver android:name=".meizu.MeizuPushReceiver">
<intent-filter>
<!-- 接收push消息 -->
Expand Down
17 changes: 16 additions & 1 deletion push/src/main/java/cn/wildfirechat/push/PushService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
Expand Down Expand Up @@ -43,7 +44,7 @@ public enum PushServiceType {

public static void init(Context gContext) {
String sys = getSystem();
if(SYS_EMUI.equals(sys) &&INST.isHMSConfigured(gContext)) {
if (SYS_EMUI.equals(sys) && INST.isHMSConfigured(gContext)) {
INST.pushServiceType = PushServiceType.HMS;
INST.initHMS(gContext);
} else if (/*SYS_FLYME.equals(sys) && INST.isMZConfigured(gContext)*/MzSystemUtils.isBrandMeizu()) {
Expand All @@ -54,7 +55,21 @@ public static void init(Context gContext) {
INST.pushServiceType = PushServiceType.Xiaomi;
INST.initXiaomi(gContext);
}
}

public static void clearNotification(Context context) {
if (INST.pushServiceType == PushServiceType.Xiaomi) {
MiPushClient.clearNotification(context);
} else {
// TODO
}
}

public static void showMainActivity(Context context) {
String action = "cn.wildfirechat.chat.main";
Intent intent = new Intent(action);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}

public static void didReceiveIMPushMessage(Context context, AndroidPushMessage pushMessage, PushServiceType pushServiceType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class HuaweiPushRevicer extends PushReceiver {
private final static String TAG = "HuaweiPushRevicer";

@Override
public void onToken(Context context, String s, Bundle bundle) {
try {
Expand All @@ -38,4 +39,13 @@ public void onPushMsg(Context context, byte[] payload, String s) {
PushService.didReceivePushMessageData(context, data);
}
}

@Override
public void onEvent(Context context, Event event, Bundle extras) {
if (event == Event.NOTIFICATION_OPENED || event == Event.NOTIFICATION_CLICK_BTN) {
PushService.showMainActivity(context);
} else {
super.onEvent(context, event, extras);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public void onSubAliasStatus(Context context, SubAliasStatus subAliasStatus) {

@Override
public void onNotificationClicked(Context context, String title, String content, String selfDefineContentString) {
super.onNotificationClicked(context, title, content, selfDefineContentString);
Log.e(TAG, "onNC");
// do nothing, will start app
PushService.showMainActivity(context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@ public void onReceivePassThroughMessage(Context context, MiPushMessage message)

@Override
public void onNotificationMessageClicked(Context context, MiPushMessage message) {
mMessage = message.getContent();
if (!TextUtils.isEmpty(message.getTopic())) {
mTopic = message.getTopic();
} else if (!TextUtils.isEmpty(message.getAlias())) {
mAlias = message.getAlias();
} else if (!TextUtils.isEmpty(message.getUserAccount())) {
mUserAccount = message.getUserAccount();
}
PushService.showMainActivity(context);
}

@Override
Expand Down

0 comments on commit 4e1b318

Please sign in to comment.