diff --git a/.idea/misc.xml b/.idea/misc.xml index 37a7509..7bfef59 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/build.gradle b/app/build.gradle index bd95e5c..ebcf05d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" } diff --git a/app/release/app-release.apk b/app/release/app-release.apk index e678544..e47783f 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/output.json b/app/release/output.json index dced801..cfa0c1a 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -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":{}}] \ No newline at end of file +[{"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":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java b/app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java index 6e2e655..629992c 100644 --- a/app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java +++ b/app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java @@ -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; @@ -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": @@ -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) @@ -145,7 +150,7 @@ 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) @@ -153,7 +158,6 @@ public void setSummary(String packageName, PendingIntent intent) { .setSummaryText(packageName)) .setGroup(packageName) .setGroupSummary(true) - .setContentIntent(intent) .setAutoCancel(true) .setOnlyAlertOnce(true) .build(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 822d562..140c145 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,9 +8,9 @@ about - 此应用可以通过fcm通道从一台手机向另一台手机转发通知\n + 此应用可以通过fcm通道从一台手机向另一台手机转发通知 \n - 如果显示fail,请检查Google框架并尝试翻墙重启应用\n + 如果显示fail,请检查Google框架并尝试翻墙重启应用 \n 你只需要将token(就是那堆乱码)复制到服务端的输入框,点击start即可开始推送