react-native-incall-manager icon indicating copy to clipboard operation
react-native-incall-manager copied to clipboard

How to vibrate when ringing?

Open tgreco opened this issue 4 years ago • 1 comments

I don't see any examples for this and the readme is unclear how to use it.

tgreco avatar Jan 05 '21 01:01 tgreco

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;
           }

xyzbilal avatar Jun 23 '21 12:06 xyzbilal