@@ -226,7 +226,7 @@ public IterableNotificationBuilder createNotification(Context context, Bundle ex
226226 notificationBuilder .setDefaults (notifPermissions .defaults );
227227
228228 removeAllInactiveChannels (context );
229- registerChannelIfEmpty (context , channelId , channelName , channelDescription , soundName , soundUrl );
229+ registerChannelIfEmpty (context , channelId , channelName , channelDescription , soundName , soundId , soundUrl );
230230
231231 return notificationBuilder ;
232232 }
@@ -260,7 +260,7 @@ public void postNotificationOnDevice(Context context, IterableNotificationBuilde
260260 * @param channelName Sets the channel name that is shown to the user.
261261 * @param channelDescription Sets the channel description that is shown to the user.
262262 */
263- private void registerChannelIfEmpty (Context context , String channelId , String channelName , String channelDescription , String soundName , String soundUrl ) {
263+ private void registerChannelIfEmpty (Context context , String channelId , String channelName , String channelDescription , String soundName , int soundId , String soundUrl ) {
264264 NotificationManager mNotificationManager = (NotificationManager )
265265 context .getApplicationContext ().getSystemService (Context .NOTIFICATION_SERVICE );
266266 if (android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .O
@@ -269,7 +269,7 @@ private void registerChannelIfEmpty(Context context, String channelId, String ch
269269 if (existingChannel == null || !existingChannel .getName ().equals (channelName )) {
270270 IterableLogger .d (IterableNotificationBuilder .TAG , "Creating notification: channelId = " + channelId + " channelName = "
271271 + channelName + " channelDescription = " + channelDescription );
272- mNotificationManager .createNotificationChannel (createNotificationChannel (channelId , channelName , channelDescription , context , soundName , soundUrl ));
272+ mNotificationManager .createNotificationChannel (createNotificationChannel (channelId , channelName , channelDescription , context , soundName , soundId , soundUrl ));
273273 }
274274 }
275275 }
@@ -319,11 +319,11 @@ void removeAllInactiveChannels(Context context) {
319319 }
320320 }
321321
322- private NotificationChannel createNotificationChannel (String channelId , String channelName , String channelDescription , Context context , String soundName , String soundURL ) {
322+ private NotificationChannel createNotificationChannel (String channelId , String channelName , String channelDescription , Context context , String soundName , int soundId , String soundURL ) {
323323 NotificationChannel notificationChannel = null ;
324324 Uri soundUri = null ;
325325 if (soundURL == null ) {
326- soundUri = getSoundUri (context , soundName );
326+ soundUri = getSoundUri (context , soundName , soundId );
327327 } else {
328328 soundUri = Uri .parse (soundURL );
329329 }
@@ -469,13 +469,12 @@ private static AudioAttributes getAudioAttributes() {
469469 return audioAttributes ;
470470 }
471471
472- private static Uri getSoundUri (Context context , String soundName ) {
473- int soundID = context .getResources ().getIdentifier (soundName , IterableConstants .SOUND_FOLDER_IDENTIFIER , context .getPackageName ());
472+ private static Uri getSoundUri (Context context , String soundName , int soundId ) {
474473
475- if (soundID == 0 || soundName == null ) {
474+ if (soundId == 0 || soundName == null ) {
476475 return Settings .System .DEFAULT_NOTIFICATION_URI ;
477476 }
478477
479- return Uri .parse (IterableConstants .ANDROID_RESOURCE_PATH + context .getPackageName () + "/" + soundID );
478+ return Uri .parse (IterableConstants .ANDROID_RESOURCE_PATH + context .getPackageName () + "/" + soundId );
480479 }
481480}
0 commit comments