I am trying to build a call application using webrtc and socket.io. I am using firebase messaging to wake up the user. I am trying to find a way to notify user with playing a ringtone like when you get call on whatsapp they play default incoming call ringtone. I tried solutions like -
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
another is -
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), notification);
mp.start();
but it does not respect user's sound setting i.e sound plays even when phone is put on vibrate or dnd.