@os1-platform/dispatch-mobile 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/android/.gradle/7.5/fileHashes/fileHashes.lock +0 -0
  2. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  3. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  4. package/android/src/main/AndroidManifest.xml +0 -1
  5. package/android/src/main/java/com/dispatchsdk/permissions/PermissionModule.kt +107 -62
  6. package/android/src/main/java/com/dispatchsdk/sync/SyncManagerService.kt +31 -23
  7. package/lib/commonjs/components/executiontasks/forms/FormGenerator.js +15 -11
  8. package/lib/commonjs/components/executiontasks/forms/FormGenerator.js.map +1 -1
  9. package/lib/commonjs/manager/syncmanager/AppSyncManager.js +4 -1
  10. package/lib/commonjs/manager/syncmanager/AppSyncManager.js.map +1 -1
  11. package/lib/commonjs/manager/syncmanager/document/DocumentHttpClient.js +2 -0
  12. package/lib/commonjs/manager/syncmanager/document/DocumentHttpClient.js.map +1 -1
  13. package/lib/commonjs/native/PermissionModule.js +5 -1
  14. package/lib/commonjs/native/PermissionModule.js.map +1 -1
  15. package/lib/commonjs/utils/SdkUtils.js +1 -19
  16. package/lib/commonjs/utils/SdkUtils.js.map +1 -1
  17. package/lib/module/components/executiontasks/forms/FormGenerator.js +15 -11
  18. package/lib/module/components/executiontasks/forms/FormGenerator.js.map +1 -1
  19. package/lib/module/manager/syncmanager/AppSyncManager.js +4 -1
  20. package/lib/module/manager/syncmanager/AppSyncManager.js.map +1 -1
  21. package/lib/module/manager/syncmanager/document/DocumentHttpClient.js +2 -0
  22. package/lib/module/manager/syncmanager/document/DocumentHttpClient.js.map +1 -1
  23. package/lib/module/native/PermissionModule.js +5 -1
  24. package/lib/module/native/PermissionModule.js.map +1 -1
  25. package/lib/module/utils/SdkUtils.js +1 -19
  26. package/lib/module/utils/SdkUtils.js.map +1 -1
  27. package/lib/typescript/native/PermissionModule.d.ts +1 -0
  28. package/lib/typescript/utils/SdkUtils.d.ts +0 -8
  29. package/package.json +43 -41
  30. package/src/components/executiontasks/forms/FormGenerator.tsx +12 -6
  31. package/src/manager/syncmanager/AppSyncManager.ts +7 -4
  32. package/src/manager/syncmanager/document/DocumentHttpClient.ts +3 -0
  33. package/src/native/PermissionModule.ts +6 -0
  34. package/src/utils/SdkUtils.ts +2 -31
@@ -45,25 +45,6 @@ export default class SdkUtils {
45
45
  });
46
46
  }
47
47
 
48
- /**
49
- * Function to download apk file from a public URL
50
- * @param apkURL - URL where apk is hosted
51
- * @param version - expected version of apk (used for naming the file)
52
- * @param callback - callback for getting progress of download
53
- */
54
- static async downloadAPK(apkURL, version, callback) {
55
- const fileUri = FileSystem.cacheDirectory + `${version}.apk`;
56
- const fileInfo = await FileSystem.getInfoAsync(fileUri);
57
- const currentDate = new Date().toLocaleDateString();
58
- const fileDate = new Date(fileInfo.modificationTime ? fileInfo.modificationTime * 1000 : 0).toLocaleDateString();
59
- if (fileInfo.exists && currentDate === fileDate) {
60
- return fileInfo.uri;
61
- }
62
- const downloadResumable = FileSystem.createDownloadResumable(apkURL, FileSystem.cacheDirectory + `${version}.apk`, {}, callback);
63
- const downloadResult = await downloadResumable.downloadAsync();
64
- return downloadResult === null || downloadResult === void 0 ? void 0 : downloadResult.uri;
65
- }
66
-
67
48
  /**
68
49
  * Opens & Install an APK file
69
50
  * @param uri - source of apk file
@@ -92,6 +73,7 @@ export default class SdkUtils {
92
73
  throw new BaseError(ErrorCodes.SYSTEM_TIME_CHECK_FAILED, 'Automatic date/time not enabled!');
93
74
  }
94
75
  if (Platform.OS === 'android') {
76
+ await PermissionModule.requestWakeLockPermissions();
95
77
  await Location.enableNetworkProviderAsync();
96
78
  let locationServicesCheck = await Location.hasServicesEnabledAsync();
97
79
  const foregroundLocation = await PermissionModule.requestForegroundPermissions();
@@ -1 +1 @@
1
- {"version":3,"names":["remoteConfig","Logger","LOG_TYPE","FileSystem","NativeModules","Platform","Location","NetworkUtil","BaseError","ErrorCodes","PermissionModule","DispatchSdkUtils","DispatchUtilsInterface","SdkUtils","getRemoteConfig","expiration","Promise","resolve","reject","fetch","setDefaults","cxRumDevApiKey","cxRumProdApiKey","isMandatoryUpdate","isMandatoryUpdateiOS","toggleInAppUpdateiOS","toggleInAppUpdate","then","fetchAndActivate","fetchedRemotely","config","getAll","getInstance","logEvent","SDK_INFO","catch","err","error","downloadAPK","apkURL","version","callback","fileUri","cacheDirectory","fileInfo","getInfoAsync","currentDate","Date","toLocaleDateString","fileDate","modificationTime","exists","uri","downloadResumable","createDownloadResumable","downloadResult","downloadAsync","deleteApk","deleteAsync","openAPKFile","openAndInstallApk","openAppSettings","openSettings","message","SDK_ERROR","checkMandatory","OS","foregroundLocation","requestForegroundPermissions","LOCATION_OR_GPS_NOT_ENABLED","dateTimeCheck","isAutomaticDateTimeEnabled","SYSTEM_TIME_CHECK_FAILED","enableNetworkProviderAsync","locationServicesCheck","hasServicesEnabledAsync","bgLocation","requestBackgroundPermissions","internet","isAvailableAsync","INTERNET_NOT_ENABLED"],"sources":["SdkUtils.ts"],"sourcesContent":["import remoteConfig from '@react-native-firebase/remote-config';\nimport Logger, { LOG_TYPE } from './Logger';\nimport type { DownloadProgressData } from 'expo-file-system';\nimport * as FileSystem from 'expo-file-system';\nimport { NativeModules, Platform } from 'react-native';\nimport * as Location from 'expo-location';\nimport NetworkUtil from './NetworkUtil';\nimport { BaseError } from '../errors/BaseError';\nimport ErrorCodes from '../errors/ErrorCodes';\nimport PermissionModule from '../native/PermissionModule';\n\nconst { DispatchSdkUtils } = NativeModules;\n\ninterface DispatchUtilsInterface {\n openAndInstallApk(apkUri: String): Promise<boolean>;\n openSettings(): Promise<boolean>;\n showAndroidDialog(\n title: string,\n message: string,\n positiveText: string,\n negativeText: string | null,\n cancelable: boolean\n ): Promise<boolean>;\n isAutomaticDateTimeEnabled(): Promise<boolean>;\n}\n\nexport { DispatchSdkUtils as DispatchUtilsInterface };\n\nexport default class SdkUtils {\n /**\n * number of seconds to cache the firebase config\n * @param expiration\n */\n static async getRemoteConfig(expiration: number): Promise<any> {\n return new Promise(async (resolve, reject) => {\n try {\n await remoteConfig().fetch(expiration);\n remoteConfig()\n .setDefaults({\n cxRumDevApiKey: 'NA',\n cxRumProdApiKey: 'NA',\n isMandatoryUpdate: 'false',\n isMandatoryUpdateiOS: 'false',\n toggleInAppUpdateiOS: 'false',\n toggleInAppUpdate: 'false',\n })\n .then(() => remoteConfig().fetchAndActivate())\n .then((fetchedRemotely) => {\n let config = remoteConfig().getAll();\n if (fetchedRemotely) {\n Logger.getInstance().logEvent(\n 'Remote Config',\n 'Configs were retrieved from the backend and activated.',\n LOG_TYPE.SDK_INFO\n );\n resolve(config);\n } else {\n Logger.getInstance().logEvent(\n 'Remote Config',\n 'No configs were fetched from the backend, and the local configs were already activated',\n LOG_TYPE.SDK_INFO\n );\n resolve(config);\n }\n })\n .catch((err) => {\n reject(err);\n });\n } catch (error: any) {\n reject(error);\n }\n });\n }\n\n /**\n * Function to download apk file from a public URL\n * @param apkURL - URL where apk is hosted\n * @param version - expected version of apk (used for naming the file)\n * @param callback - callback for getting progress of download\n */\n public static async downloadAPK(\n apkURL: string,\n version: string,\n callback: (progress: DownloadProgressData) => any\n ): Promise<string | undefined> {\n const fileUri = FileSystem.cacheDirectory + `${version}.apk`;\n const fileInfo = await FileSystem.getInfoAsync(fileUri);\n const currentDate = new Date().toLocaleDateString();\n const fileDate = new Date(\n fileInfo.modificationTime ? fileInfo.modificationTime * 1000 : 0\n ).toLocaleDateString();\n if (fileInfo.exists && currentDate === fileDate) {\n return fileInfo.uri;\n }\n const downloadResumable = FileSystem.createDownloadResumable(\n apkURL,\n FileSystem.cacheDirectory + `${version}.apk`,\n {},\n callback\n );\n const downloadResult = await downloadResumable.downloadAsync();\n return downloadResult?.uri;\n }\n\n /**\n * Opens & Install an APK file\n * @param uri - source of apk file\n */\n public static async deleteApk(version: string) {\n await FileSystem.deleteAsync(FileSystem.cacheDirectory + `${version}.apk`);\n }\n\n public static async openAPKFile(uri: string) {\n return await (DispatchSdkUtils as DispatchUtilsInterface).openAndInstallApk(\n uri\n );\n }\n\n public static openAppSettings() {\n (DispatchSdkUtils as DispatchUtilsInterface)\n .openSettings()\n .then()\n .catch((error) => {\n Logger.getInstance().logEvent(\n 'Intent error',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n });\n }\n\n public static async checkMandatory() {\n if (Platform.OS === 'ios'){\n const foregroundLocation = await PermissionModule.requestForegroundPermissions();\n if (!(foregroundLocation)) {\n throw new BaseError(\n ErrorCodes.LOCATION_OR_GPS_NOT_ENABLED,\n 'Location or GPS not enabled'\n );\n }\n return;\n }\n const dateTimeCheck = await (\n DispatchSdkUtils as DispatchUtilsInterface\n ).isAutomaticDateTimeEnabled();\n if (!dateTimeCheck) {\n throw new BaseError(\n ErrorCodes.SYSTEM_TIME_CHECK_FAILED,\n 'Automatic date/time not enabled!'\n );\n }\n if (Platform.OS === 'android') {\n await Location.enableNetworkProviderAsync();\n let locationServicesCheck = await Location.hasServicesEnabledAsync();\n const foregroundLocation = await PermissionModule.requestForegroundPermissions();\n // await Location.requestForegroundPermissionsAsync(); //permission code using expo module\n const bgLocation = await PermissionModule.requestBackgroundPermissions();\n // await Location.requestBackgroundPermissionsAsync(); //permission code using expo module\n if (!(locationServicesCheck && foregroundLocation && bgLocation)) {\n throw new BaseError(\n ErrorCodes.LOCATION_OR_GPS_NOT_ENABLED,\n 'Location or GPS not enabled'\n );\n }\n }\n let internet = await NetworkUtil.isAvailableAsync();\n if (!internet)\n throw new BaseError(\n ErrorCodes.INTERNET_NOT_ENABLED,\n 'Internet is disabled! Please enable internet and try again '\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,YAAY,MAAM,sCAAsC;AAC/D,OAAOC,MAAM,IAAIC,QAAQ,QAAQ,UAAU;AAE3C,OAAO,KAAKC,UAAU,MAAM,kBAAkB;AAC9C,SAASC,aAAa,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H,qBAAqB,IAAIP,kBAAkB,IAAIS,UAAU,CAAC,EAAE;QAChE,MAAM,IAAIpE,SAAS,CACjBC,UAAU,CAAC4D,2BAA2B,EACtC,6BACF,CAAC;MACH;IACF;IACA,IAAIS,QAAQ,GAAG,MAAMvE,WAAW,CAACwE,gBAAgB,CAAC,CAAC;IACnD,IAAI,CAACD,QAAQ,EACX,MAAM,IAAItE,SAAS,CACjBC,UAAU,CAACuE,oBAAoB,EAC/B,6DACF,CAAC;EACL;AACF","ignoreList":[]}
1
+ {"version":3,"names":["remoteConfig","Logger","LOG_TYPE","FileSystem","NativeModules","Platform","Location","NetworkUtil","BaseError","ErrorCodes","PermissionModule","DispatchSdkUtils","DispatchUtilsInterface","SdkUtils","getRemoteConfig","expiration","Promise","resolve","reject","fetch","setDefaults","cxRumDevApiKey","cxRumProdApiKey","isMandatoryUpdate","isMandatoryUpdateiOS","toggleInAppUpdateiOS","toggleInAppUpdate","then","fetchAndActivate","fetchedRemotely","config","getAll","getInstance","logEvent","SDK_INFO","catch","err","error","deleteApk","version","deleteAsync","cacheDirectory","openAPKFile","uri","openAndInstallApk","openAppSettings","openSettings","message","SDK_ERROR","checkMandatory","OS","foregroundLocation","requestForegroundPermissions","LOCATION_OR_GPS_NOT_ENABLED","dateTimeCheck","isAutomaticDateTimeEnabled","SYSTEM_TIME_CHECK_FAILED","requestWakeLockPermissions","enableNetworkProviderAsync","locationServicesCheck","hasServicesEnabledAsync","bgLocation","requestBackgroundPermissions","internet","isAvailableAsync","INTERNET_NOT_ENABLED"],"sources":["SdkUtils.ts"],"sourcesContent":["import remoteConfig from '@react-native-firebase/remote-config';\nimport Logger, { LOG_TYPE } from './Logger';\nimport type { DownloadProgressData } from 'expo-file-system';\nimport * as FileSystem from 'expo-file-system';\nimport { NativeModules, Platform } from 'react-native';\nimport * as Location from 'expo-location';\nimport NetworkUtil from './NetworkUtil';\nimport { BaseError } from '../errors/BaseError';\nimport ErrorCodes from '../errors/ErrorCodes';\nimport PermissionModule from '../native/PermissionModule';\n\nconst { DispatchSdkUtils } = NativeModules;\n\ninterface DispatchUtilsInterface {\n openAndInstallApk(apkUri: String): Promise<boolean>;\n openSettings(): Promise<boolean>;\n showAndroidDialog(\n title: string,\n message: string,\n positiveText: string,\n negativeText: string | null,\n cancelable: boolean\n ): Promise<boolean>;\n isAutomaticDateTimeEnabled(): Promise<boolean>;\n}\n\nexport { DispatchSdkUtils as DispatchUtilsInterface };\n\nexport default class SdkUtils {\n /**\n * number of seconds to cache the firebase config\n * @param expiration\n */\n static async getRemoteConfig(expiration: number): Promise<any> {\n return new Promise(async (resolve, reject) => {\n try {\n await remoteConfig().fetch(expiration);\n remoteConfig()\n .setDefaults({\n cxRumDevApiKey: 'NA',\n cxRumProdApiKey: 'NA',\n isMandatoryUpdate: 'false',\n isMandatoryUpdateiOS: 'false',\n toggleInAppUpdateiOS: 'false',\n toggleInAppUpdate: 'false',\n })\n .then(() => remoteConfig().fetchAndActivate())\n .then((fetchedRemotely) => {\n let config = remoteConfig().getAll();\n if (fetchedRemotely) {\n Logger.getInstance().logEvent(\n 'Remote Config',\n 'Configs were retrieved from the backend and activated.',\n LOG_TYPE.SDK_INFO\n );\n resolve(config);\n } else {\n Logger.getInstance().logEvent(\n 'Remote Config',\n 'No configs were fetched from the backend, and the local configs were already activated',\n LOG_TYPE.SDK_INFO\n );\n resolve(config);\n }\n })\n .catch((err) => {\n reject(err);\n });\n } catch (error: any) {\n reject(error);\n }\n });\n }\n\n /**\n * Opens & Install an APK file\n * @param uri - source of apk file\n */\n public static async deleteApk(version: string) {\n await FileSystem.deleteAsync(FileSystem.cacheDirectory + `${version}.apk`);\n }\n\n public static async openAPKFile(uri: string) {\n return await (DispatchSdkUtils as DispatchUtilsInterface).openAndInstallApk(\n uri\n );\n }\n\n public static openAppSettings() {\n (DispatchSdkUtils as DispatchUtilsInterface)\n .openSettings()\n .then()\n .catch((error) => {\n Logger.getInstance().logEvent(\n 'Intent error',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n });\n }\n\n public static async checkMandatory() {\n if (Platform.OS === 'ios') {\n const foregroundLocation = await PermissionModule.requestForegroundPermissions();\n if (!(foregroundLocation)) {\n throw new BaseError(\n ErrorCodes.LOCATION_OR_GPS_NOT_ENABLED,\n 'Location or GPS not enabled'\n );\n }\n return;\n }\n const dateTimeCheck = await (\n DispatchSdkUtils as DispatchUtilsInterface\n ).isAutomaticDateTimeEnabled();\n if (!dateTimeCheck) {\n throw new BaseError(\n ErrorCodes.SYSTEM_TIME_CHECK_FAILED,\n 'Automatic date/time not enabled!'\n );\n }\n if (Platform.OS === 'android') {\n await PermissionModule.requestWakeLockPermissions();\n await Location.enableNetworkProviderAsync();\n let locationServicesCheck = await Location.hasServicesEnabledAsync();\n const foregroundLocation = await PermissionModule.requestForegroundPermissions();\n // await Location.requestForegroundPermissionsAsync(); //permission code using expo module\n const bgLocation = await PermissionModule.requestBackgroundPermissions();\n // await Location.requestBackgroundPermissionsAsync(); //permission code using expo module\n if (!(locationServicesCheck && foregroundLocation && bgLocation)) {\n throw new BaseError(\n ErrorCodes.LOCATION_OR_GPS_NOT_ENABLED,\n 'Location or GPS not enabled'\n );\n }\n }\n let internet = await NetworkUtil.isAvailableAsync();\n if (!internet)\n throw new BaseError(\n ErrorCodes.INTERNET_NOT_ENABLED,\n 'Internet is disabled! Please enable internet and try again '\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,YAAY,MAAM,sCAAsC;AAC/D,OAAOC,MAAM,IAAIC,QAAQ,QAAQ,UAAU;AAE3C,OAAO,KAAKC,UAAU,MAAM,kBAAkB;AAC9C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,OAAO,KAAKC,QAAQ,MAAM,eAAe;AACzC,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,OAAOC,UAAU,MAAM,sBAAsB;AAC7C,OAAOC,gBAAgB,MAAM,4BAA4B;AAEzD,MAAM;EAAEC;AAAi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AC,CAAC;MACpE,MAAMT,kBAAkB,GAAG,MAAMzC,gBAAgB,CAAC0C,4BAA4B,CAAC,CAAC;MAChF;MACA,MAAMS,UAAU,GAAG,MAAMnD,gBAAgB,CAACoD,4BAA4B,CAAC,CAAC;MACxE;MACA,IAAI,EAAEH,qBAAqB,IAAIR,kBAAkB,IAAIU,UAAU,CAAC,EAAE;QAChE,MAAM,IAAIrD,SAAS,CACjBC,UAAU,CAAC4C,2BAA2B,EACtC,6BACF,CAAC;MACH;IACF;IACA,IAAIU,QAAQ,GAAG,MAAMxD,WAAW,CAACyD,gBAAgB,CAAC,CAAC;IACnD,IAAI,CAACD,QAAQ,EACX,MAAM,IAAIvD,SAAS,CACjBC,UAAU,CAACwD,oBAAoB,EAC/B,6DACF,CAAC;EACL;AACF","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  interface PermissionsModuleType {
2
2
  requestForegroundPermissions: () => Promise<boolean>;
3
3
  requestBackgroundPermissions: () => Promise<boolean>;
4
+ requestWakeLockPermissions: () => Promise<boolean>;
4
5
  }
5
6
  declare const _default: PermissionsModuleType;
6
7
  export default _default;
@@ -1,4 +1,3 @@
1
- import type { DownloadProgressData } from 'expo-file-system';
2
1
  declare const DispatchSdkUtils: any;
3
2
  export { DispatchSdkUtils as DispatchUtilsInterface };
4
3
  export default class SdkUtils {
@@ -7,13 +6,6 @@ export default class SdkUtils {
7
6
  * @param expiration
8
7
  */
9
8
  static getRemoteConfig(expiration: number): Promise<any>;
10
- /**
11
- * Function to download apk file from a public URL
12
- * @param apkURL - URL where apk is hosted
13
- * @param version - expected version of apk (used for naming the file)
14
- * @param callback - callback for getting progress of download
15
- */
16
- static downloadAPK(apkURL: string, version: string, callback: (progress: DownloadProgressData) => any): Promise<string | undefined>;
17
9
  /**
18
10
  * Opens & Install an APK file
19
11
  * @param uri - source of apk file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os1-platform/dispatch-mobile",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Dispatch SDK React Native Package",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -52,7 +52,7 @@
52
52
  "homepage": "https://github.com/FoxtrotPlatform/platform-coreos-dispatch-sdk/#readme",
53
53
  "devDependencies": {
54
54
  "@apollo/client": "^3.5.6",
55
- "@babel/core": "^7.12.9",
55
+ "@babel/core": "^7.20.0",
56
56
  "@babel/preset-env": "^7.15.8",
57
57
  "@babel/preset-typescript": "^7.15.0",
58
58
  "@babel/runtime": "^7.12.5",
@@ -94,15 +94,16 @@
94
94
  "eslint": "^7.32.0",
95
95
  "eslint-config-prettier": "^7.0.0",
96
96
  "eslint-plugin-prettier": "^3.1.3",
97
- "expo": "~47.0.13",
98
- "expo-barcode-scanner": "~11.2.1",
99
- "expo-blur": "~11.0.0",
100
- "expo-camera": "~12.1.2",
101
- "expo-file-system": "~13.0.3",
102
- "expo-font": "~10.0.3",
103
- "expo-image-picker": "~11.0.3",
104
- "expo-location": "~13.0.4",
105
- "expo-sqlite": "~11.0.0",
97
+ "expo": "~48.0.21",
98
+ "expo-barcode-scanner": "~12.3.2",
99
+ "expo-blur": "~12.2.2",
100
+ "expo-camera": "~13.2.1",
101
+ "expo-file-system": "~15.2.2",
102
+ "expo-font": "~11.1.1",
103
+ "expo-image-picker": "~14.1.1",
104
+ "expo-location": "~15.1.1",
105
+ "expo-sqlite": "~11.1.1",
106
+ "expo-image-manipulator": "~11.1.1",
106
107
  "graphql": "^16.2.0",
107
108
  "husky": "^4.2.5",
108
109
  "jest": "^26.6.3",
@@ -112,13 +113,13 @@
112
113
  "pod-install": "^0.1.0",
113
114
  "prettier": "^2.0.5",
114
115
  "react": "18.2.0",
115
- "react-dom": "^17.0.2",
116
+ "react-dom": "18.2.0",
116
117
  "react-native": "0.71.19",
117
118
  "react-native-builder-bob": "^0.18.0",
118
119
  "react-native-compressor": "^1.8.24",
119
120
  "react-native-dropdown-picker": "^5.4.0",
120
121
  "react-native-get-random-values": "^1.8.0",
121
- "react-native-image-picker": "^7.0.2",
122
+ "react-native-image-picker": "7.0.2",
122
123
  "react-native-paper": "^4.9.2",
123
124
  "react-native-safe-area-context": "^3.3.2",
124
125
  "react-native-screens": "^3.9.0",
@@ -143,15 +144,16 @@
143
144
  "@react-navigation/native-stack": "^6.2.5",
144
145
  "@sentry/react-native": "^5.13.0",
145
146
  "axios": "^0.24.0",
146
- "expo": "~47.0.13",
147
- "expo-barcode-scanner": "~11.4.0",
148
- "expo-blur": "~11.0.0",
149
- "expo-camera": "~13.1.0",
150
- "expo-file-system": "~15.1.1",
151
- "expo-font": "~11.0.1",
152
- "expo-image-picker": "~14.1.0",
153
- "expo-location": "~15.0.1",
154
- "expo-sqlite": "~11.0.0",
147
+ "expo": "~48.0.21",
148
+ "expo-barcode-scanner": "~12.3.2",
149
+ "expo-blur": "~12.2.2",
150
+ "expo-camera": "~13.2.1",
151
+ "expo-file-system": "~15.2.2",
152
+ "expo-font": "~11.1.1",
153
+ "expo-image-picker": "~14.1.1",
154
+ "expo-location": "~15.1.1",
155
+ "expo-sqlite": "~11.1.1",
156
+ "expo-image-manipulator": "~11.1.1",
155
157
  "graphql": "^16.2.0",
156
158
  "react": "^18.2.0",
157
159
  "react-native": "^0.71.19",
@@ -163,6 +165,25 @@
163
165
  "react-native-screens": "^3.9.0",
164
166
  "react-native-vector-icons": "^9.0.0"
165
167
  },
168
+ "dependencies": {
169
+ "@os1-platform/platform-coreos-execution-engine-sdk": "1.0.18",
170
+ "@rjsf/core": "^2.0.0",
171
+ "apollo-link-timeout": "^4.0.0",
172
+ "decompress": "^4.2.1",
173
+ "i18n-js": "^4.3.2",
174
+ "json-logic-js": "^2.0.1",
175
+ "jsonpath-plus": "^6.0.1",
176
+ "jwt-decode": "^3.1.2",
177
+ "latlng-to-dms": "^1.0.2",
178
+ "lodash": "^4.17.21",
179
+ "react-native-fs": "^2.20.0",
180
+ "react-native-image-marker": "1.1.15",
181
+ "react-native-otp-textinput": "0.0.8",
182
+ "react-native-svg": "^13.6.0",
183
+ "recyclerlistview": "^4.2.0",
184
+ "rjsf-native": "^1.0.14",
185
+ "toggle-switch-react-native": "^3.3.0"
186
+ },
166
187
  "jest": {
167
188
  "moduleFileExtensions": [
168
189
  "ts",
@@ -255,24 +276,5 @@
255
276
  }
256
277
  ]
257
278
  ]
258
- },
259
- "dependencies": {
260
- "@os1-platform/platform-coreos-execution-engine-sdk": "1.0.17",
261
- "@rjsf/core": "^2.0.0",
262
- "apollo-link-timeout": "^4.0.0",
263
- "decompress": "^4.2.1",
264
- "i18n-js": "^4.3.2",
265
- "json-logic-js": "^2.0.1",
266
- "jsonpath-plus": "^6.0.1",
267
- "jwt-decode": "^3.1.2",
268
- "latlng-to-dms": "^1.0.2",
269
- "lodash": "^4.17.21",
270
- "react-native-fs": "^2.20.0",
271
- "react-native-image-marker": "1.1.15",
272
- "react-native-otp-textinput": "0.0.8",
273
- "react-native-svg": "^13.6.0",
274
- "recyclerlistview": "^4.2.0",
275
- "rjsf-native": "^1.0.14",
276
- "toggle-switch-react-native": "^3.3.0"
277
279
  }
278
280
  }
@@ -223,9 +223,8 @@ const FormGenerator = (props: FormInputSchema) => {
223
223
  </View>
224
224
  </ScrollView>
225
225
  <View style={styles.bottomView}>
226
- <View>
227
226
  <Button
228
- style={[CommonStyles.nextButton, { width: 165, marginStart: 10 }]}
227
+ style={[styles.mainBtnStyles, CommonStyles.nextButton]}
229
228
  labelStyle={CommonStyles.nextButtonLabel}
230
229
  mode={'contained'}
231
230
  onPress={() => {
@@ -241,10 +240,8 @@ const FormGenerator = (props: FormInputSchema) => {
241
240
  >
242
241
  Proceed
243
242
  </Button>
244
- </View>
245
- <View>
246
243
  {(props.isSelfLoop == false) && <Button
247
- style={[CommonStyles.cancelButton, { width: 165, marginEnd: 10 }]}
244
+ style={[styles.mainBtnStyles, CommonStyles.cancelButton]}
248
245
  labelStyle={CommonStyles.cancelButtonLabel}
249
246
  mode={'outlined'}
250
247
  onPress={() => {
@@ -261,7 +258,6 @@ const FormGenerator = (props: FormInputSchema) => {
261
258
  Cancel
262
259
  </Button>
263
260
  }
264
- </View>
265
261
  </View>
266
262
  </KeyboardAvoidingView>
267
263
  </Provider>
@@ -290,5 +286,15 @@ const styles = StyleSheet.create({
290
286
  justifyContent: 'space-evenly',
291
287
  padding: 16,
292
288
  backgroundColor: 'white',
289
+ gap: 16,
290
+ },
291
+ mainBtnStyles: {
292
+ display: 'flex',
293
+ flexDirection: 'row',
294
+ justifyContent: 'center',
295
+ alignItems: 'center',
296
+ flex: 1,
297
+ width: '100%',
298
+ backgroundColor: 'white',
293
299
  },
294
300
  });
@@ -120,10 +120,13 @@ export default class AppSyncManager {
120
120
  * Call this method from index file of the app
121
121
  */
122
122
  public static registerSyncTask() {
123
- AppRegistry.registerHeadlessTask(
124
- 'SYNC_MANAGER',
125
- () => AppSyncManager.startAppSyncManager
126
- );
123
+ // We will not register headless js task for api level 31 and above
124
+ if (Platform.OS == 'android' && Platform.Version > 30) {
125
+ AppRegistry.registerHeadlessTask(
126
+ 'SYNC_MANAGER',
127
+ () => AppSyncManager.startAppSyncManager
128
+ );
129
+ }
127
130
  }
128
131
 
129
132
  public async getAllEvents(dispatchID?: string): Promise<EventRow[]> {
@@ -201,10 +201,13 @@ export default class DocumentHttpClient extends HttpClient {
201
201
  if (processedFileExist) {
202
202
  filePathToUpload = document.processed_file_path;
203
203
  }
204
+ const fileStat = await RNFS.stat(filePathToUpload);
205
+
204
206
  const url =
205
207
  sdkConfig.tenantBaseURL + `/api/folders/${document.fms_folder_id}/files`;
206
208
 
207
209
  let extraParameters = {
210
+ fSize: fileStat.size + " b",
208
211
  fName: document.file_name && document.file_name.length != 0 ? document.file_name.substring(4): '',
209
212
  dName: document.fms_folder_id && document.fms_folder_id.length != 0 ? document.fms_folder_id.substring(4): '',
210
213
  dispId: document.dispatch_id && document.dispatch_id.length != 0 ? document.dispatch_id.substring(9): ''
@@ -5,6 +5,7 @@ const { PermissionsModule } = NativeModules;
5
5
  interface PermissionsModuleType {
6
6
  requestForegroundPermissions: () => Promise<boolean>;
7
7
  requestBackgroundPermissions: () => Promise<boolean>;
8
+ requestWakeLockPermissions: () => Promise<boolean>;
8
9
  }
9
10
 
10
11
  const requestForegroundPermissions = async (): Promise<boolean> => {
@@ -15,7 +16,12 @@ const requestBackgroundPermissions = async (): Promise<boolean> => {
15
16
  return PermissionsModule.requestBackgroundPermissions();
16
17
  };
17
18
 
19
+ const requestWakeLockPermissions = async (): Promise<boolean> => {
20
+ return PermissionsModule.requestWakeLockPermissions();
21
+ };
22
+
18
23
  export default {
19
24
  requestForegroundPermissions,
20
25
  requestBackgroundPermissions,
26
+ requestWakeLockPermissions
21
27
  } as PermissionsModuleType;
@@ -72,36 +72,6 @@ export default class SdkUtils {
72
72
  });
73
73
  }
74
74
 
75
- /**
76
- * Function to download apk file from a public URL
77
- * @param apkURL - URL where apk is hosted
78
- * @param version - expected version of apk (used for naming the file)
79
- * @param callback - callback for getting progress of download
80
- */
81
- public static async downloadAPK(
82
- apkURL: string,
83
- version: string,
84
- callback: (progress: DownloadProgressData) => any
85
- ): Promise<string | undefined> {
86
- const fileUri = FileSystem.cacheDirectory + `${version}.apk`;
87
- const fileInfo = await FileSystem.getInfoAsync(fileUri);
88
- const currentDate = new Date().toLocaleDateString();
89
- const fileDate = new Date(
90
- fileInfo.modificationTime ? fileInfo.modificationTime * 1000 : 0
91
- ).toLocaleDateString();
92
- if (fileInfo.exists && currentDate === fileDate) {
93
- return fileInfo.uri;
94
- }
95
- const downloadResumable = FileSystem.createDownloadResumable(
96
- apkURL,
97
- FileSystem.cacheDirectory + `${version}.apk`,
98
- {},
99
- callback
100
- );
101
- const downloadResult = await downloadResumable.downloadAsync();
102
- return downloadResult?.uri;
103
- }
104
-
105
75
  /**
106
76
  * Opens & Install an APK file
107
77
  * @param uri - source of apk file
@@ -130,7 +100,7 @@ export default class SdkUtils {
130
100
  }
131
101
 
132
102
  public static async checkMandatory() {
133
- if (Platform.OS === 'ios'){
103
+ if (Platform.OS === 'ios') {
134
104
  const foregroundLocation = await PermissionModule.requestForegroundPermissions();
135
105
  if (!(foregroundLocation)) {
136
106
  throw new BaseError(
@@ -150,6 +120,7 @@ export default class SdkUtils {
150
120
  );
151
121
  }
152
122
  if (Platform.OS === 'android') {
123
+ await PermissionModule.requestWakeLockPermissions();
153
124
  await Location.enableNetworkProviderAsync();
154
125
  let locationServicesCheck = await Location.hasServicesEnabledAsync();
155
126
  const foregroundLocation = await PermissionModule.requestForegroundPermissions();