react-native-incall-manager
react-native-incall-manager copied to clipboard
How to vibrate when ringing?
I don't see any examples for this and the readme is unclear how to use it.
in android part of codestartRingtone method I modified part of
if (audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) {
like below;
if (audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) {
Log.d(TAG, "startRingtone(): ringer is silent. leave without play.");
if(audioManager.getStreamVolume(AudioManager.RINGER_MODE_VIBRATE)==0){
v = (Vibrator) Application.getAppContext().getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = {1000, 1000, 1000, 1000, 1000,1000, 1000, 1000, 1000, 1000,1000, 1000, 1000, 1000, 1000};
if(android.os.Build.VERSION.SDK_INT >=android.os.Build.VERSION_CODES.O){
v.vibrate( VibrationEffect.createWaveform(pattern,-1),
new AudioAttributes.Builder()
.setUsage(USAGE_NOTIFICATION_RINGTONE)
// .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build());
}else{
v.vibrate(pattern, -1);
}
isVibrating = true;
}
return;
}