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,15 +150,19 @@ public class FIRLocalMessagingHelper { ...@@ -151,15 +150,19 @@ public class FIRLocalMessagingHelper {
} }
//sound //sound
String soundName = bundle.getString("sound", "default"); String soundName = bundle.getString("sound");
if (!soundName.equalsIgnoreCase("default")) { if (soundName != null) {
if (soundName.equalsIgnoreCase("default")) {
notification.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
} else {
int soundResourceId = res.getIdentifier(soundName, "raw", packageName); int soundResourceId = res.getIdentifier(soundName, "raw", packageName);
if(soundResourceId == 0){ if (soundResourceId == 0) {
soundName = soundName.substring(0, soundName.lastIndexOf('.')); soundName = soundName.substring(0, soundName.lastIndexOf('.'));
soundResourceId = res.getIdentifier(soundName, "raw", packageName); soundResourceId = res.getIdentifier(soundName, "raw", packageName);
} }
notification.setSound(Uri.parse("android.resource://" + packageName + "/" + soundResourceId)); notification.setSound(Uri.parse("android.resource://" + packageName + "/" + soundResourceId));
} }
}
//color //color
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
......
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