-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
39 lines (31 loc) · 1.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var React = require('react-native');
var NativeModules = React.NativeModules;
var Platform = React.Platform;
var invariant = require('invariant');
var SinchVerificationIOS = NativeModules.RNSinch;
var SinchVerificationAndroid = NativeModules.RNSinchAndroid;
var RNSinch;
if (Platform.OS === 'ios') {
invariant(SinchVerificationIOS, 'Import libraries to iOS "react-native link react-native-sinch"');
RNSinch = SinchVerificationIOS;
} else if (Platform.OS === 'android') {
invariant(SinchVerificationAndroid, 'Import libraries to android "react-native link react-native-sinch"');
RNSinch = SinchVerificationAndroid;
} else {
invariant(RNSinch, "Invalid platform");
}
var applicationKey = null;
module.exports = {
init: function(appKey) {
applicationKey = appKey;
},
sms: function(phoneNumber, custom, callback) {
invariant(applicationKey, 'Call init() to setup the Sinch application key.');
RNSinch.sms(applicationKey, phoneNumber, custom, callback);
},
flashCall: function(phoneNumber, custom, callback) {
invariant(applicationKey, 'Call init() to setup the Sinch application key.');
RNSinch.flashCall(applicationKey, phoneNumber, custom, callback);
},
verify: RNSinch.verify,
}