diff --git a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java index eca899afc0f6e38788bb525bf97a540aab3ce632..fe7027c2cedea627a0c5938f21ddbe43f85fa82c 100644 --- a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java +++ b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java @@ -82,7 +82,6 @@ public class FIRLocalMessagingHelper { .setSubText(bundle.getString("sub_text")) .setGroup(bundle.getString("group")) .setVibrate(new long[]{0, DEFAULT_VIBRATION}) - .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setExtras(bundle.getBundle("data")); //priority @@ -151,14 +150,18 @@ public class FIRLocalMessagingHelper { } //sound - String soundName = bundle.getString("sound", "default"); - if (!soundName.equalsIgnoreCase("default")) { - int soundResourceId = res.getIdentifier(soundName, "raw", packageName); - if(soundResourceId == 0){ - soundName = soundName.substring(0, soundName.lastIndexOf('.')); - soundResourceId = res.getIdentifier(soundName, "raw", packageName); + String soundName = bundle.getString("sound"); + if (soundName != null) { + if (soundName.equalsIgnoreCase("default")) { + notification.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); + } else { + 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 diff --git a/ios/RNFIRMessaging.m b/ios/RNFIRMessaging.m index df47395135d9ebead889ec3bd610bd2690e01e17..f4b64ad1915cb03766afc44c7541ef149dc05741 100644 --- a/ios/RNFIRMessaging.m +++ b/ios/RNFIRMessaging.m @@ -45,9 +45,11 @@ RCT_ENUM_CONVERTER(NSCalendarUnit, content.body =[RCTConvert NSString:details[@"body"]]; NSString* sound = [RCTConvert NSString:details[@"sound"]]; if(sound != nil){ - content.sound = [UNNotificationSound soundNamed:sound]; - }else{ - content.sound = [UNNotificationSound defaultSound]; + if ([sound isEqual:@"default"]) { + content.sound = [UNNotificationSound defaultSound]; + } else { + content.sound = [UNNotificationSound soundNamed:sound]; + } } content.categoryIdentifier = [RCTConvert NSString:details[@"click_action"]]; content.userInfo = details;