1
1
'use strict' ;
2
2
var _InCallManager = require ( 'react-native' ) . NativeModules . InCallManager ;
3
+ import {
4
+ Platform ,
5
+ Vibration ,
6
+ } from 'react-native' ;
3
7
4
8
class InCallManager {
5
9
constructor ( ) {
10
+ this . vibrate = false ;
6
11
this . recordPermission = 'unknow' ;
7
12
this . caeraPermission = 'unknow' ;
8
13
this . checkRecordPermission = this . checkRecordPermission . bind ( this ) ;
@@ -55,12 +60,23 @@ class InCallManager {
55
60
_InCallManager . setMicrophoneMute ( enable ) ;
56
61
}
57
62
58
- startRingtone ( ringtone ) {
63
+ startRingtone ( ringtone , vibrate = false ) {
59
64
ringtone = ( typeof ringtone === 'string' ) ? ringtone : "_DEFAULT_" ;
60
65
_InCallManager . startRingtone ( ringtone ) ;
66
+ this . vibrate = vibrate ;
67
+ if ( this . vibrate ) {
68
+ if ( Platform . OS === 'android' ) {
69
+ Vibration . vibrate ( [ 0 , 1000 , 3000 ] , true ) ;
70
+ } else {
71
+ this . vibrate = false ;
72
+ }
73
+ }
61
74
}
62
75
63
76
stopRingtone ( ) {
77
+ if ( this . vibrate ) {
78
+ Vibration . cancel ( ) ;
79
+ }
64
80
_InCallManager . stopRingtone ( ) ;
65
81
}
66
82
@@ -69,28 +85,28 @@ class InCallManager {
69
85
}
70
86
71
87
async checkRecordPermission ( ) {
72
- // --- on android which api < 23, it will always be "granted"
88
+ // --- on android which api < 23, it will always be "granted"
73
89
let result = await _InCallManager . checkRecordPermission ( ) ;
74
90
this . recordPermission = result ;
75
91
return result ;
76
92
}
77
93
78
94
async requestRecordPermission ( ) {
79
- // --- on android which api < 23, it will always be "granted"
95
+ // --- on android which api < 23, it will always be "granted"
80
96
let result = await _InCallManager . requestRecordPermission ( ) ;
81
97
this . recordPermission = result ;
82
98
return result ;
83
99
}
84
100
85
101
async checkCameraPermission ( ) {
86
- // --- on android which api < 23, it will always be "granted"
102
+ // --- on android which api < 23, it will always be "granted"
87
103
let result = await _InCallManager . checkCameraPermission ( ) ;
88
104
this . cameraPermission = result ;
89
105
return result ;
90
106
}
91
107
92
108
async requestCameraPermission ( ) {
93
- // --- on android which api < 23, it will always be "granted"
109
+ // --- on android which api < 23, it will always be "granted"
94
110
let result = await _InCallManager . requestCameraPermission ( ) ;
95
111
this . cameraPermission = result ;
96
112
return result ;
0 commit comments