Allow local notification without sound for Android. #441

parent aa67cfef
...@@ -82,7 +82,6 @@ public class FIRLocalMessagingHelper { ...@@ -82,7 +82,6 @@ public class FIRLocalMessagingHelper {
.setSubText(bundle.getString("sub_text")) .setSubText(bundle.getString("sub_text"))
.setGroup(bundle.getString("group")) .setGroup(bundle.getString("group"))
.setVibrate(new long[]{0, DEFAULT_VIBRATION}) .setVibrate(new long[]{0, DEFAULT_VIBRATION})
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setExtras(bundle.getBundle("data")); .setExtras(bundle.getBundle("data"));
//priority //priority
...@@ -151,14 +150,18 @@ public class FIRLocalMessagingHelper { ...@@ -151,14 +150,18 @@ public class FIRLocalMessagingHelper {
} }
//sound //sound
String soundName = bundle.getString("sound", "default"); String soundName = bundle.getString("sound");
if (!soundName.equalsIgnoreCase("default")) { if (soundName != null) {
int soundResourceId = res.getIdentifier(soundName, "raw", packageName); if (soundName.equalsIgnoreCase("default")) {
if(soundResourceId == 0){ notification.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
soundName = soundName.substring(0, soundName.lastIndexOf('.')); } else {
soundResourceId = res.getIdentifier(soundName, "raw", packageName); int soundResourceId = res.getIdentifier(soundName, "raw", packageName);
if (soundResourceId == 0) {
soundName = soundName.substring(0, soundName.lastIndexOf('.'));
soundResourceId = res.getIdentifier(soundName, "raw", packageName);
}
notification.setSound(Uri.parse("android.resource://" + packageName + "/" + soundResourceId));
} }
notification.setSound(Uri.parse("android.resource://" + packageName + "/" + soundResourceId));
} }
//color //color
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment