@@ -226,7 +226,7 @@ public IterableNotificationBuilder createNotification(Context context, Bundle ex
226
226
notificationBuilder .setDefaults (notifPermissions .defaults );
227
227
228
228
removeAllInactiveChannels (context );
229
- registerChannelIfEmpty (context , channelId , channelName , channelDescription , soundName , soundUrl );
229
+ registerChannelIfEmpty (context , channelId , channelName , channelDescription , soundName , soundId , soundUrl );
230
230
231
231
return notificationBuilder ;
232
232
}
@@ -260,7 +260,7 @@ public void postNotificationOnDevice(Context context, IterableNotificationBuilde
260
260
* @param channelName Sets the channel name that is shown to the user.
261
261
* @param channelDescription Sets the channel description that is shown to the user.
262
262
*/
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 ) {
264
264
NotificationManager mNotificationManager = (NotificationManager )
265
265
context .getApplicationContext ().getSystemService (Context .NOTIFICATION_SERVICE );
266
266
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
269
269
if (existingChannel == null || !existingChannel .getName ().equals (channelName )) {
270
270
IterableLogger .d (IterableNotificationBuilder .TAG , "Creating notification: channelId = " + channelId + " channelName = "
271
271
+ channelName + " channelDescription = " + channelDescription );
272
- mNotificationManager .createNotificationChannel (createNotificationChannel (channelId , channelName , channelDescription , context , soundName , soundUrl ));
272
+ mNotificationManager .createNotificationChannel (createNotificationChannel (channelId , channelName , channelDescription , context , soundName , soundId , soundUrl ));
273
273
}
274
274
}
275
275
}
@@ -319,11 +319,11 @@ void removeAllInactiveChannels(Context context) {
319
319
}
320
320
}
321
321
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 ) {
323
323
NotificationChannel notificationChannel = null ;
324
324
Uri soundUri = null ;
325
325
if (soundURL == null ) {
326
- soundUri = getSoundUri (context , soundName );
326
+ soundUri = getSoundUri (context , soundName , soundId );
327
327
} else {
328
328
soundUri = Uri .parse (soundURL );
329
329
}
@@ -469,13 +469,12 @@ private static AudioAttributes getAudioAttributes() {
469
469
return audioAttributes ;
470
470
}
471
471
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 ) {
474
473
475
- if (soundID == 0 || soundName == null ) {
474
+ if (soundId == 0 || soundName == null ) {
476
475
return Settings .System .DEFAULT_NOTIFICATION_URI ;
477
476
}
478
477
479
- return Uri .parse (IterableConstants .ANDROID_RESOURCE_PATH + context .getPackageName () + "/" + soundID );
478
+ return Uri .parse (IterableConstants .ANDROID_RESOURCE_PATH + context .getPackageName () + "/" + soundId );
480
479
}
481
480
}
0 commit comments