Skip to content

Commit

Permalink
[flutter_local_notifications] fix: handle exception while loading res…
Browse files Browse the repository at this point in the history
…ource name (#2406)

* fix: handle exception while loading resource name

* chore: apply google-java-format

Signed-off-by: Goddchen <[email protected]>

---------

Signed-off-by: Goddchen <[email protected]>
  • Loading branch information
Goddchen authored and MaikuB committed Sep 21, 2024
1 parent 3e6df00 commit 9515a4f
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2130,11 +2130,16 @@ private HashMap<String, Object> getMappedNotificationChannel(NotificationChannel
channelPayload.put("sound", resource);
} else {
// Kept for backwards compatibility when the source resource used to be based on id
String resourceName =
applicationContext.getResources().getResourceEntryName(resourceId);
if (resourceName != null) {
channelPayload.put("soundSource", soundSources.indexOf(SoundSource.RawResource));
channelPayload.put("sound", resourceName);
try {
String resourceName =
applicationContext.getResources().getResourceEntryName(resourceId);
if (resourceName != null) {
channelPayload.put("soundSource", soundSources.indexOf(SoundSource.RawResource));
channelPayload.put("sound", resourceName);
}
} catch (Exception e) {
channelPayload.put("sound", null);
channelPayload.put("playSound", false);
}
}
} else {
Expand Down

0 comments on commit 9515a4f

Please sign in to comment.