forked from kingstinct/react-native-device-activity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReactNativeDeviceActivityModule.ts
58 lines (50 loc) · 1.39 KB
/
ReactNativeDeviceActivityModule.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { ProxyNativeModule } from "expo-modules-core";
import type { ReactNativeDeviceActivityNativeModule } from "./ReactNativeDeviceActivity.types";
const warnText = "[react-native-device-activity] Only available on iOS";
const warnFn = () => {
console.warn(warnText);
};
const warnFnArray = () => {
console.warn(warnText);
return [];
};
const warnFnNumber = <T extends number>() => {
console.warn(warnText);
return 0 as T;
};
const warnFnBoolean = () => {
console.warn(warnText);
return false;
};
const mockModule:
| (ReactNativeDeviceActivityNativeModule & ProxyNativeModule)
| null = {
isAvailable: () => false,
requestAuthorization: warnFn,
blockAppsWithSelectionId: warnFn,
userDefaultsAll: warnFn,
userDefaultsGet: warnFn,
userDefaultsRemove: warnFn,
userDefaultsSet: warnFn,
userDefaultsClear: warnFn,
revokeAuthorization: warnFn,
isShieldActive: warnFnBoolean,
getAppGroupFileDirectory: warnFn,
isShieldActiveWithSelection: warnFnBoolean,
doesSelectionHaveOverlap: warnFnBoolean,
updateShieldConfiguration: warnFn,
unblockApps: warnFn,
blockApps: warnFn,
activities: warnFnArray,
authorizationStatus: warnFnNumber,
reloadDeviceActivityCenter: warnFn,
getEvents: () => {
console.warn(warnText);
return {};
},
startMonitoring: warnFn,
stopMonitoring: warnFn,
addListener: warnFn,
removeListeners: warnFn,
};
export default mockModule;