-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1.17 KB
/
index.js
File metadata and controls
38 lines (32 loc) · 1.17 KB
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
import {NativeModules,NativeEventEmitter,Platform} from 'react-native';
const EventEmitter = new NativeEventEmitter(Platform.OS=="ios" ? NativeModules.Truecaller : NativeModules.MyModule);
const RCTTruecaller =Platform.OS=="ios" ? NativeModules.Truecaller : NativeModules.MyModule;
const TRUECALLER = {};
export const TRUECALLEREvent =
{
TrueProfileResponse: 'didReceiveTrueProfileResponse',
TrueProfileResponseError: 'didReceiveTrueProfileResponseError',
};
TRUECALLER.isTruecallerInstalled = () => {
return RCTTruecaller.isTruecallerInstalled();
}
TRUECALLER.initializeClient = () =>
{
return RCTTruecaller.initializeClient();
};
TRUECALLER.initializeClientIOS = (appKey,appLink) =>
{
return RCTTruecaller.initializeClientIOS(appKey,appLink);
};
TRUECALLER.requestTrueProfile = () =>
{
return RCTTruecaller.requestTrueProfile();
};
TRUECALLER.on = (event, callback) =>
{
if (!Object.values(TRUECALLEREvent).includes(event)) {
throw new Error(`Invalid TRUECALLEREvent event subscription, use import {TRUECALLEREvent} from 'react-native-truecaller' to avoid typo`);
};
return EventEmitter.addListener(event, callback);
};
export default TRUECALLER;