Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Support QQ-Notfiy-Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLuo0 committed Apr 18, 2019
1 parent 08bacfc commit 1c0acc3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
applicationId "com.RichardLuo.notificationpush"
minSdkVersion 22
targetSdkVersion 28
versionCode 8
versionCode 9
versionName "1.0.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":8,"versionName":"1.0.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"1.0.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
20 changes: 12 additions & 8 deletions app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.service.notification.StatusBarNotification;
Expand Down Expand Up @@ -42,14 +41,14 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
String title = data.get("title");
String body = data.get("body");
int id = Integer.valueOf(data.get("id"));
String senderName = "";
String senderName = null;
if (data.containsKey("senderName"))
senderName = data.get("senderName");
String packageName = remoteMessage.getData().get("package");
PendingIntent intent = null;

setChannel(packageName);
PendingIntent intent = getIntent(packageName);
setSummary(packageName, intent);
setSummary(packageName);

switch (packageName) {
case "com.tencent.minihd.qq":
Expand All @@ -59,12 +58,18 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
case "com.tencent.mobileqq":
case "com.jinhaihan.qqnotfandshare":
String QQpackageName = getSharedPreferences("MainActivity", MODE_PRIVATE).getString("installedQQ", null);
if (senderName.equals(""))
intent = getIntent(QQpackageName);
if (senderName == null)
break;
MessagingStyle(packageName, title, senderName, body, getIntent(QQpackageName), notificationManagerCompat, id);
if (senderName.equals(""))
senderName = "无名氏";
MessagingStyle(packageName, title, senderName, body, intent, notificationManagerCompat, id);
return;
default:
intent = getIntent(packageName);
}


Notification notification = new NotificationCompat.Builder(this, packageName)
.setSmallIcon(R.drawable.ic_notification)
.setColor(color)
Expand Down Expand Up @@ -145,15 +150,14 @@ private Notification getCurrentNotification(String packageName, int id) {
return null;
}

public void setSummary(String packageName, PendingIntent intent) {
public void setSummary(String packageName) {
Notification summary = new NotificationCompat.Builder(this, packageName)
.setSmallIcon(R.drawable.ic_notification)
.setColor(color)
.setStyle(new NotificationCompat.BigTextStyle()
.setSummaryText(packageName))
.setGroup(packageName)
.setGroupSummary(true)
.setContentIntent(intent)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.build();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<string name="about">about</string>

<string name="HowToUse">
此应用可以通过fcm通道从一台手机向另一台手机转发通知\n
此应用可以通过fcm通道从一台手机向另一台手机转发通知
\n
如果显示fail,请检查Google框架并尝试翻墙重启应用\n
如果显示fail,请检查Google框架并尝试翻墙重启应用
\n
你只需要将token(就是那堆乱码)复制到服务端的输入框,点击start即可开始推送
</string>
Expand Down

0 comments on commit 1c0acc3

Please sign in to comment.