Skip to content

Commit 3bae639

Browse files
committed
use specific vibration pattern instead repeat
use repeat will cause infinite loop in some cases. ex: network interrupted, did not receive hangup signal, ...etc
1 parent 7116c24 commit 3bae639

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class InCallManager {
6565
_InCallManager.setMicrophoneMute(enable);
6666
}
6767

68-
startRingtone(ringtone, vibrate, ios_category, seconds) {
68+
startRingtone(ringtone, vibrate_pattern, ios_category, seconds) {
6969
ringtone = (typeof ringtone === 'string') ? ringtone : "_DEFAULT_";
70-
vibrate = (vibrate === true) ? true : false;
70+
this.vibrate = (Array.isArray(vibrate_pattern)) ? true : false;
7171
ios_category = (ios_category === 'playback') ? 'playback' : "default";
7272
seconds = (typeof seconds === 'number' && seconds > 0) ? parseInt(seconds) : -1; // --- android only, default looping
7373

@@ -77,13 +77,9 @@ class InCallManager {
7777
_InCallManager.startRingtone(ringtone, ios_category);
7878
}
7979

80-
this.vibrate = vibrate;
80+
// --- should not use repeat, it may cause infinite loop in some cases.
8181
if (this.vibrate) {
82-
if (Platform.OS === 'android') {
83-
Vibration.vibrate([0, 1000, 3000], true);
84-
} else {
85-
Vibration.vibrate([0, 3000], true); // --- should enable this after RN merged our PR
86-
}
82+
Vibration.vibrate(vibrate_pattern, false); // --- ios needs RN 0.34 to support vibration pattern
8783
}
8884
}
8985

0 commit comments

Comments
 (0)