react-native-okhi 1.2.4 → 1.2.5-beta.2

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 (44) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/gradle.properties +2 -2
  3. package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +2 -0
  4. package/ios/Okhi.m +4 -0
  5. package/ios/Okhi.swift +29 -0
  6. package/lib/commonjs/OkCollect/OkHiLocationManager.js +100 -7
  7. package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +1 -1
  8. package/lib/commonjs/OkCollect/Util.js +29 -25
  9. package/lib/commonjs/OkCollect/Util.js.map +1 -1
  10. package/lib/commonjs/OkCollect/app.json +1 -1
  11. package/lib/commonjs/OkCollect/types.js.map +1 -1
  12. package/lib/commonjs/OkCore/Helpers.js +3 -1
  13. package/lib/commonjs/OkCore/Helpers.js.map +1 -1
  14. package/lib/commonjs/OkCore/index.js +1 -0
  15. package/lib/commonjs/OkCore/index.js.map +1 -1
  16. package/lib/commonjs/OkCore/types.js +4 -0
  17. package/lib/commonjs/OkCore/types.js.map +1 -1
  18. package/lib/commonjs/OkHiNativeModule/index.js.map +1 -1
  19. package/lib/module/OkCollect/OkHiLocationManager.js +101 -8
  20. package/lib/module/OkCollect/OkHiLocationManager.js.map +1 -1
  21. package/lib/module/OkCollect/Util.js +29 -25
  22. package/lib/module/OkCollect/Util.js.map +1 -1
  23. package/lib/module/OkCollect/app.json +1 -1
  24. package/lib/module/OkCollect/types.js.map +1 -1
  25. package/lib/module/OkCore/Helpers.js +3 -1
  26. package/lib/module/OkCore/Helpers.js.map +1 -1
  27. package/lib/module/OkCore/index.js +1 -0
  28. package/lib/module/OkCore/index.js.map +1 -1
  29. package/lib/module/OkCore/types.js +1 -1
  30. package/lib/module/OkCore/types.js.map +1 -1
  31. package/lib/module/OkHiNativeModule/index.js.map +1 -1
  32. package/lib/typescript/OkCollect/types.d.ts +3 -5
  33. package/lib/typescript/OkCore/types.d.ts +2 -1
  34. package/lib/typescript/OkHiNativeModule/index.d.ts +3 -0
  35. package/package.json +1 -1
  36. package/react-native-okhi.podspec +1 -1
  37. package/src/OkCollect/OkHiLocationManager.tsx +127 -5
  38. package/src/OkCollect/Util.ts +37 -29
  39. package/src/OkCollect/app.json +1 -1
  40. package/src/OkCollect/types.ts +4 -2
  41. package/src/OkCore/Helpers.ts +7 -1
  42. package/src/OkCore/index.ts +1 -0
  43. package/src/OkCore/types.ts +3 -1
  44. package/src/OkHiNativeModule/index.ts +7 -1
@@ -1 +1 @@
1
- {"version":3,"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiException","OkHiMode","manifest","Platform","OkHiNativeModule","fetchCurrentLocation","result","generateStartDataPayload","props","authToken","applicationConfiguration","_props$theme","_props$theme2","_applicationConfigura","_applicationConfigura2","_applicationConfigura3","_props$config","_props$theme3","_props$config2","_props$config3","_props$config4","_props$config5","_props$config6","payload","style","theme","undefined","base","color","colors","primary","logo","appBar","name","app","user","phone","firstName","lastName","email","auth","context","container","version","developer","library","platform","config","streetView","backgroundColor","visible","addressTypes","home","work","protectedApps","OS","status","fetchIOSLocationPermissionStatus","permissions","location","coordinates","currentLocation","lat","lng","accuracy","hasLocationPermission","error","console","log","hasBackgroundLocationPermission","manufacturer","model","retrieveDeviceInfo","device","code","UNSUPPORTED_PLATFORM_CODE","message","UNAUTHORIZED_MESSAGE","getFrameUrl","DEV_FRAME_URL","PROD_FRAME_URL","SANDBOX_FRAME_URL","LEGACY_DEV_FRAME_URL","LEGACY_PROD_FRAME_URL","LEGACY_SANDBOX_FRAME_URL","Version","mode","PROD","generateJavaScriptStartScript","startPayload","jsBeforeLoad","JSON","stringify","jsAfterLoad","parseOkHiLocation","_location$geo_point","_location$geo_point2","_location$street_view","_location$street_view2","id","geo_point","lon","placeId","place_id","plusCode","plus_code","propertyName","property_name","streetName","street_name","title","subtitle","directions","otherInformation","other_information","url","streetViewPanoId","street_view","pano_id","streetViewPanoUrl","userId","user_id","propertyNumber","photo","displayTitle","display_title","country","state","city","countryCode","country_code"],"sources":["Util.ts"],"sourcesContent":["import type { OkHiLocationManagerProps } from './types';\nimport {\n canOpenProtectedAppsSettings,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\n OkHiException,\n OkHiLocation,\n} from '../OkCore';\nimport { OkHiMode } from '../OkCore';\nimport type {\n OkHiLocationManagerStartDataPayload,\n OkHiLocationManagerStartMessage,\n} from './types';\nimport manifest from './app.json'; //TODO: fix this\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { Platform } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\nconst fetchCurrentLocation = async (): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n}> => {\n const result = await OkHiNativeModule.fetchCurrentLocation();\n return result;\n};\n\n/**\n * @ignore\n */\nexport const generateStartDataPayload = async (\n props: OkHiLocationManagerProps,\n authToken: string,\n applicationConfiguration: AuthApplicationConfig\n): Promise<OkHiLocationManagerStartDataPayload> => {\n const payload: any = {};\n payload.style = !props.theme\n ? undefined\n : {\n base: {\n color: props.theme?.colors?.primary,\n logo: props.theme?.appBar?.logo,\n name: applicationConfiguration.app?.name,\n },\n };\n payload.user = {\n phone: props.user.phone,\n firstName: props.user.firstName,\n lastName: props.user.lastName,\n email: props.user.email,\n };\n payload.auth = {\n authToken,\n };\n payload.context = {\n container: {\n name: applicationConfiguration.app?.name,\n version: applicationConfiguration.app?.version,\n },\n developer: {\n name: applicationConfiguration.context.developer,\n },\n library: {\n name: manifest.name,\n version: manifest.version,\n },\n platform: {\n name: 'react-native',\n },\n };\n payload.config = {\n streetView:\n typeof props.config?.streetView === 'boolean'\n ? props.config.streetView\n : true,\n appBar: {\n color: props.theme?.appBar?.backgroundColor,\n visible: props.config?.appBar?.visible,\n },\n addressTypes: {\n home:\n typeof props.config?.addressTypes?.home === 'boolean'\n ? props.config?.addressTypes?.home\n : true,\n work:\n typeof props.config?.addressTypes?.work === 'boolean'\n ? props.config?.addressTypes?.work\n : true,\n },\n protectedApps:\n Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),\n };\n\n if (Platform.OS === 'ios') {\n const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();\n if (status !== 'notDetermined') {\n payload.context.permissions = {\n location:\n status === 'authorizedWhenInUse'\n ? 'whenInUse'\n : status === 'authorizedAlways' || status === 'authorized'\n ? 'always'\n : 'denided',\n };\n if (\n status === 'authorized' ||\n status === 'authorizedWhenInUse' ||\n status === 'authorizedAlways'\n ) {\n const location = await fetchCurrentLocation();\n if (location) {\n payload.context.coordinates = {\n currentLocation: {\n lat: location.lat,\n lng: location.lng,\n accuracy: location.accuracy,\n },\n };\n }\n }\n }\n } else if (Platform.OS === 'android') {\n let hasLocationPermission: boolean | undefined;\n try {\n hasLocationPermission = await isLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n let hasBackgroundLocationPermission: boolean | undefined;\n try {\n hasBackgroundLocationPermission =\n await isBackgroundLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n if (\n typeof hasLocationPermission === 'boolean' &&\n typeof hasBackgroundLocationPermission === 'boolean'\n ) {\n payload.context.permissions = {\n location: hasBackgroundLocationPermission\n ? 'always'\n : hasLocationPermission\n ? 'whenInUse'\n : 'denied',\n };\n }\n const { manufacturer, model } = await OkHiNativeModule.retrieveDeviceInfo();\n payload.context.device = {\n manufacturer,\n model,\n };\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n }\n return payload;\n};\n\n/**\n * @ignore\n */\nexport const getFrameUrl = (\n applicationConfiguration: AuthApplicationConfig\n): string => {\n const DEV_FRAME_URL = 'https://dev-manager-v5.okhi.io';\n const PROD_FRAME_URL = 'https://manager-v5.okhi.io';\n const SANDBOX_FRAME_URL = 'https://sandbox-manager-v5.okhi.io';\n\n const LEGACY_DEV_FRAME_URL = 'https://dev-legacy-manager-v5.okhi.io';\n const LEGACY_PROD_FRAME_URL = 'https://legacy-manager-v5.okhi.io';\n const LEGACY_SANDBOX_FRAME_URL = 'https://sandbox-legacy-manager-v5.okhi.io';\n\n if (Platform.OS === 'android' && Platform.Version < 24) {\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return LEGACY_PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return LEGACY_DEV_FRAME_URL;\n }\n return LEGACY_SANDBOX_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return DEV_FRAME_URL;\n }\n return SANDBOX_FRAME_URL;\n};\n\n/**\n * @ignore\n */\nexport const generateJavaScriptStartScript = (startPayload: {\n message: OkHiLocationManagerStartMessage;\n payload: OkHiLocationManagerStartDataPayload;\n}) => {\n const jsBeforeLoad = `\n window.isNativeApp = true;\n window.NativeApp = {\n bridge: {\n receiveMessage: window.ReactNativeWebView.postMessage\n },\n data: ${JSON.stringify(startPayload)}\n }\n true;\n `;\n const jsAfterLoad = `window.startOkHiLocationManager({ receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, ${JSON.stringify(\n startPayload\n )})`;\n return { jsBeforeLoad, jsAfterLoad };\n};\n\n/**\n * @ignore\n */\nexport const parseOkHiLocation = (location: any): OkHiLocation => {\n return {\n id: location?.id,\n lat: location?.geo_point?.lat,\n lon: location?.geo_point?.lon,\n placeId: location?.place_id,\n plusCode: location?.plus_code,\n propertyName: location?.property_name,\n streetName: location?.street_name,\n title: location?.title,\n subtitle: location?.subtitle,\n directions: location?.directions,\n otherInformation: location?.other_information,\n url: location?.url,\n streetViewPanoId: location?.street_view?.pano_id,\n streetViewPanoUrl: location?.street_view?.url,\n userId: location?.user_id,\n propertyNumber: location?.propertyNumber,\n photo: location?.photo,\n displayTitle: location?.display_title,\n country: location?.country,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G;IAClBC,gBAAgB,EAAEzD,QAAQ,aAARA,QAAQ,gBAAAsC,qBAAA,GAARtC,QAAQ,CAAE0D,WAAW,cAAApB,qBAAA,uBAArBA,qBAAA,CAAuBqB,OAAO;IAChDC,iBAAiB,EAAE5D,QAAQ,aAARA,QAAQ,gBAAAuC,sBAAA,GAARvC,QAAQ,CAAE0D,WAAW,cAAAnB,sBAAA,uBAArBA,sBAAA,CAAuBiB,GAAG;IAC7CK,MAAM,EAAE7D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE8D,OAAO;IACzBC,cAAc,EAAE/D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE+D,cAAc;IACxCC,KAAK,EAAEhE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEgE,KAAK;IACtBC,YAAY,EAAEjE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEkE,aAAa;IACrCC,OAAO,EAAEnE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEmE,OAAO;IAC1BC,KAAK,EAAEpE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEoE,KAAK;IACtBC,IAAI,EAAErE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEqE,IAAI;IACpBC,WAAW,EAAEtE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEuE;EACzB,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiException","OkHiMode","manifest","Platform","OkHiNativeModule","fetchCurrentLocation","result","generateStartDataPayload","props","authToken","applicationConfiguration","_props$theme","_props$theme2","_applicationConfigura","_applicationConfigura2","_applicationConfigura3","_props$config","_props$theme3","_props$config2","_props$config3","_props$config4","_props$config5","_props$config6","_props$config7","payload","manufacturer","model","osVersion","platform","retrieveDeviceInfo","style","theme","undefined","base","color","colors","primary","logo","appBar","name","app","user","phone","firstName","lastName","email","auth","context","container","version","developer","library","device","config","streetView","backgroundColor","visible","addressTypes","home","work","protectedApps","OS","permissionsOnboarding","status","fetchIOSLocationPermissionStatus","locationPermission","permissions","location","coordinates","currentLocation","lat","lng","accuracy","hasLocationPermission","error","console","log","hasBackgroundLocationPermission","code","UNSUPPORTED_PLATFORM_CODE","message","UNAUTHORIZED_MESSAGE","getFrameUrl","DEV_FRAME_URL","PROD_FRAME_URL","SANDBOX_FRAME_URL","LEGACY_DEV_FRAME_URL","LEGACY_PROD_FRAME_URL","LEGACY_SANDBOX_FRAME_URL","Version","mode","PROD","generateJavaScriptStartScript","startPayload","jsBeforeLoad","JSON","stringify","jsAfterLoad","parseOkHiLocation","_location$geo_point","_location$geo_point2","_location$street_view","_location$street_view2","id","geo_point","lon","placeId","place_id","plusCode","plus_code","propertyName","property_name","streetName","street_name","title","subtitle","directions","otherInformation","other_information","url","streetViewPanoId","street_view","pano_id","streetViewPanoUrl","userId","user_id","propertyNumber","photo","displayTitle","display_title","country","state","city","countryCode","country_code"],"sources":["Util.ts"],"sourcesContent":["import type { OkHiLocationManagerProps } from './types';\nimport {\n canOpenProtectedAppsSettings,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\n OkHiException,\n OkHiLocation,\n} from '../OkCore';\nimport { OkHiMode } from '../OkCore';\nimport type {\n OkHiLocationManagerStartDataPayload,\n OkHiLocationManagerStartMessage,\n} from './types';\nimport manifest from './app.json'; //TODO: fix this\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { Platform } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\nconst fetchCurrentLocation = async (): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n}> => {\n const result = await OkHiNativeModule.fetchCurrentLocation();\n return result;\n};\n\n/**\n * @ignore\n */\nexport const generateStartDataPayload = async (\n props: OkHiLocationManagerProps,\n authToken: string,\n applicationConfiguration: AuthApplicationConfig\n): Promise<OkHiLocationManagerStartDataPayload> => {\n const payload: any = {};\n const { manufacturer, model, osVersion, platform } =\n await OkHiNativeModule.retrieveDeviceInfo();\n payload.style = !props.theme\n ? undefined\n : {\n base: {\n color: props.theme?.colors?.primary,\n logo: props.theme?.appBar?.logo,\n name: applicationConfiguration.app?.name,\n },\n };\n payload.user = {\n phone: props.user.phone,\n firstName: props.user.firstName,\n lastName: props.user.lastName,\n email: props.user.email,\n };\n payload.auth = {\n authToken,\n };\n payload.context = {\n container: {\n name: applicationConfiguration.app?.name,\n version: applicationConfiguration.app?.version,\n },\n developer: {\n name: applicationConfiguration.context.developer,\n },\n library: {\n name: manifest.name,\n version: manifest.version,\n },\n platform: {\n name: 'react-native',\n },\n device: {\n manufacturer,\n model,\n platform,\n osVersion,\n },\n };\n payload.config = {\n streetView:\n typeof props.config?.streetView === 'boolean'\n ? props.config.streetView\n : true,\n appBar: {\n color: props.theme?.appBar?.backgroundColor,\n visible: props.config?.appBar?.visible,\n },\n addressTypes: {\n home:\n typeof props.config?.addressTypes?.home === 'boolean'\n ? props.config?.addressTypes?.home\n : true,\n work:\n typeof props.config?.addressTypes?.work === 'boolean'\n ? props.config?.addressTypes?.work\n : true,\n },\n protectedApps:\n Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),\n permissionsOnboarding:\n typeof props.config?.permissionsOnboarding === 'boolean'\n ? props.config.permissionsOnboarding\n : true,\n };\n\n if (Platform.OS === 'ios') {\n const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();\n const locationPermission =\n status === 'notDetermined'\n ? 'notDetermined'\n : status === 'authorizedWhenInUse'\n ? 'whenInUse'\n : status === 'authorizedAlways'\n ? 'always'\n : 'denied';\n payload.context.permissions = {\n location: locationPermission,\n };\n if (\n status === 'authorized' ||\n status === 'authorizedWhenInUse' ||\n status === 'authorizedAlways'\n ) {\n const location = await fetchCurrentLocation();\n if (location) {\n payload.context.coordinates = {\n currentLocation: {\n lat: location.lat,\n lng: location.lng,\n accuracy: location.accuracy,\n },\n };\n }\n }\n } else if (Platform.OS === 'android') {\n let hasLocationPermission: boolean | undefined;\n try {\n hasLocationPermission = await isLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n let hasBackgroundLocationPermission: boolean | undefined;\n try {\n hasBackgroundLocationPermission =\n await isBackgroundLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n if (\n typeof hasLocationPermission === 'boolean' &&\n typeof hasBackgroundLocationPermission === 'boolean'\n ) {\n payload.context.permissions = {\n location: hasBackgroundLocationPermission\n ? 'always'\n : hasLocationPermission\n ? 'whenInUse'\n : 'denied',\n };\n }\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n }\n return payload;\n};\n\n/**\n * @ignore\n */\nexport const getFrameUrl = (\n applicationConfiguration: AuthApplicationConfig\n): string => {\n const DEV_FRAME_URL = 'https://dev-manager-v5.okhi.io';\n const PROD_FRAME_URL = 'https://manager-v5.okhi.io';\n const SANDBOX_FRAME_URL = 'https://sandbox-manager-v5.okhi.io';\n\n const LEGACY_DEV_FRAME_URL = 'https://dev-legacy-manager-v5.okhi.io';\n const LEGACY_PROD_FRAME_URL = 'https://legacy-manager-v5.okhi.io';\n const LEGACY_SANDBOX_FRAME_URL = 'https://sandbox-legacy-manager-v5.okhi.io';\n\n if (Platform.OS === 'android' && Platform.Version < 24) {\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return LEGACY_PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return LEGACY_DEV_FRAME_URL;\n }\n return LEGACY_SANDBOX_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return DEV_FRAME_URL;\n }\n return SANDBOX_FRAME_URL;\n};\n\n/**\n * @ignore\n */\nexport const generateJavaScriptStartScript = (startPayload: {\n message: OkHiLocationManagerStartMessage;\n payload: OkHiLocationManagerStartDataPayload;\n}) => {\n const jsBeforeLoad = `\n window.isNativeApp = true;\n window.NativeApp = {\n bridge: {\n receiveMessage: window.ReactNativeWebView.postMessage\n },\n data: ${JSON.stringify(startPayload)}\n }\n true;\n `;\n const jsAfterLoad = `window.startOkHiLocationManager({ receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, ${JSON.stringify(\n startPayload\n )})`;\n return { jsBeforeLoad, jsAfterLoad };\n};\n\n/**\n * @ignore\n */\nexport const parseOkHiLocation = (location: any): OkHiLocation => {\n return {\n id: location?.id,\n lat: location?.geo_point?.lat,\n lon: location?.geo_point?.lon,\n placeId: location?.place_id,\n plusCode: location?.plus_code,\n propertyName: location?.property_name,\n streetName: location?.street_name,\n title: location?.title,\n subtitle: location?.subtitle,\n directions: location?.directions,\n otherInformation: location?.other_information,\n url: location?.url,\n streetViewPanoId: location?.street_view?.pano_id,\n streetViewPanoUrl: location?.street_view?.url,\n userId: location?.user_id,\n propertyNumber: location?.propertyNumber,\n photo: location?.photo,\n displayTitle: location?.display_title,\n country: location?.country,\n state: location?.state,\n city: location?.city,\n countryCode: location?.country_code,\n };\n};\n"],"mappings":"AACA,SACEA,4BAA4B,EAC5BC,qCAAqC,EACrCC,2BAA2B,EAC3BC,aAAa,QAER,WAAW;AAClB,SAASC,QAAQ,QAAQ,WAAW;AAKpC,OAAOC,QAAQ,MAAM,YAAY,CAAC,CAAC;;AAEnC,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,MAAMC,oBAAoB,GAAG,MAAAA,CAAA,KAIvB;EACJ,MAAMC,MAAM,GAAG,MAAMF,gBAAgB,CAACC,oBAAoB,CAAC,CAAC;EAC5D,OAAOC,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CACtCC,KAA+B,EAC/BC,SAAiB,EACjBC,wBAA+C,KACE;EAAA,IAAAC,YAAA,EAAAC,aAAA,EAAAC,qBAAA,E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BC,cAAc,EAAE3D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE2D,cAAc;IACxCC,KAAK,EAAE5D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE4D,KAAK;IACtBC,YAAY,EAAE7D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE8D,aAAa;IACrCC,OAAO,EAAE/D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE+D,OAAO;IAC1BC,KAAK,EAAEhE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEgE,KAAK;IACtBC,IAAI,EAAEjE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEiE,IAAI;IACpBC,WAAW,EAAElE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEmE;EACzB,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "okhiWebReactNative",
3
- "version": "1.2.4"
3
+ "version": "1.2.5-beta.2"
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewStyle } from 'react-native';\nimport type { OkHiException } from '../OkCore/OkHiException';\nimport type { OkHiUser, OkHiLocation } from '../OkCore/types';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\n/**\n * The OkCollect Success Response object contains information about the newly created user and location once an address has been successfully created.\n * It can be used to extract information about the address and/or start address verification process.\n */\nexport interface OkCollectSuccessResponse {\n /**\n * The [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object containing information about the newly created user.\n */\n user: OkHiUser;\n /**\n * The [OkHiLocation](https://okhi.github.io/react-native-core/interfaces/okhilocation.html) object containing information about the newly created user.\n */\n location: OkHiLocation;\n\n /**\n * Starts address verification\n */\n startVerification: (config?: OkVerifyStartConfiguration) => Promise<string>;\n}\n\n/**\n * The OkHiLocationManager exposes props that you can use to customise it's functionality and appearance.\n */\nexport interface OkHiLocationManagerProps {\n /**\n * **Required:** A boolean flag that determines whether or not to show the Location Manager.\n */\n launch: boolean;\n /**\n * **Required:** A defined [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object, with a mandatory \"phone\" key property.\n */\n user: OkHiUser;\n /**\n * **Optional:** A custom JSX.Element that'll be used as a loading indicator.\n */\n loader?: JSX.Element;\n /**\n * **Optional:** Used to customise the appearance of the Container that wraps the location manager.\n */\n style?: ViewStyle;\n /**\n * **Required:** A callback that'll be invoked with an {@link OkCollectSuccessResponse} once an accurate OkHi address has been successfully created.\n */\n onSuccess: (response: OkCollectSuccessResponse) => any;\n /**\n * **Required:** A callback that'll be invoked whenever an error occurs during the address creation process.\n */\n onError: (error: OkHiException) => any;\n /**\n * **Required:** A callback that'll be invoked whenever a user taps on the close button.\n */\n onCloseRequest: () => any;\n /**\n * **Optional:** An object that'll be used to customise the appearance of the Location Manager to better match your branding requirements.\n */\n theme?: {\n appBar?: {\n backgroundColor?: string;\n logo?: string;\n };\n colors?: {\n primary?: string;\n };\n };\n /**\n * **Optional:** An object that'll be used to customise the functionality of the Location Manager. This object dictates whether you want some features on or off.\n */\n config?: {\n streetView?: boolean;\n appBar?: {\n visible?: boolean;\n };\n addressTypes?: {\n home?: boolean;\n work?: boolean;\n };\n };\n\n /**\n * **Optional:** Enable a user to either select an existing address, or force to create a new one\n */\n mode?: 'create' | 'select';\n}\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerStartDataPayload {\n style?: {\n base?: {\n color?: string;\n logo?: string;\n name?: string;\n };\n };\n auth: {\n authToken: string;\n };\n context: {\n container?: {\n name?: string;\n version?: string;\n };\n developer: {\n name: string;\n };\n library: {\n name: string;\n version: string;\n };\n platform: {\n name: 'react-native';\n };\n };\n config?: {\n streetView?: boolean;\n appBar?: {\n color?: string;\n visible?: boolean;\n };\n };\n user: OkHiUser;\n}\n\n/**\n * @ignore\n */\nexport type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerResponse {\n message:\n | 'location_selected'\n | 'location_created'\n | 'location_updated'\n | 'exit_app'\n | 'request_enable_protected_apps'\n | 'fatal_exit';\n payload: { user: any; location: any };\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewStyle } from 'react-native';\nimport type { OkHiException } from '../OkCore/OkHiException';\nimport type { OkHiUser, OkHiLocation } from '../OkCore/types';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\n/**\n * The OkCollect Success Response object contains information about the newly created user and location once an address has been successfully created.\n * It can be used to extract information about the address and/or start address verification process.\n */\nexport interface OkCollectSuccessResponse {\n /**\n * The [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object containing information about the newly created user.\n */\n user: OkHiUser;\n /**\n * The [OkHiLocation](https://okhi.github.io/react-native-core/interfaces/okhilocation.html) object containing information about the newly created user.\n */\n location: OkHiLocation;\n\n /**\n * Starts address verification\n */\n startVerification: (config?: OkVerifyStartConfiguration) => Promise<string>;\n}\n\n/**\n * The OkHiLocationManager exposes props that you can use to customise it's functionality and appearance.\n */\nexport interface OkHiLocationManagerProps {\n /**\n * **Required:** A boolean flag that determines whether or not to show the Location Manager.\n */\n launch: boolean;\n /**\n * **Required:** A defined [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object, with a mandatory \"phone\" key property.\n */\n user: OkHiUser;\n /**\n * **Optional:** A custom JSX.Element that'll be used as a loading indicator.\n */\n loader?: JSX.Element;\n /**\n * **Optional:** Used to customise the appearance of the Container that wraps the location manager.\n */\n style?: ViewStyle;\n /**\n * **Required:** A callback that'll be invoked with an {@link OkCollectSuccessResponse} once an accurate OkHi address has been successfully created.\n */\n onSuccess: (response: OkCollectSuccessResponse) => any;\n /**\n * **Required:** A callback that'll be invoked whenever an error occurs during the address creation process.\n */\n onError: (error: OkHiException) => any;\n /**\n * **Required:** A callback that'll be invoked whenever a user taps on the close button.\n */\n onCloseRequest: () => any;\n /**\n * **Optional:** An object that'll be used to customise the appearance of the Location Manager to better match your branding requirements.\n */\n theme?: {\n appBar?: {\n backgroundColor?: string;\n logo?: string;\n };\n colors?: {\n primary?: string;\n };\n };\n /**\n * **Optional:** An object that'll be used to customise the functionality of the Location Manager. This object dictates whether you want some features on or off.\n */\n config?: {\n streetView?: boolean;\n appBar?: {\n visible?: boolean;\n };\n addressTypes?: {\n home?: boolean;\n work?: boolean;\n };\n permissionsOnboarding?: boolean;\n };\n\n /**\n * **Optional:** Enable a user to either select an existing address, or force to create a new one\n */\n mode?: 'create' | 'select';\n}\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerStartDataPayload {\n style?: {\n base?: {\n color?: string;\n logo?: string;\n name?: string;\n };\n };\n auth: {\n authToken: string;\n };\n context: {\n container?: {\n name?: string;\n version?: string;\n };\n developer: {\n name: string;\n };\n library: {\n name: string;\n version: string;\n };\n platform: {\n name: 'react-native';\n };\n };\n config?: {\n streetView?: boolean;\n appBar?: {\n color?: string;\n visible?: boolean;\n };\n };\n user: OkHiUser;\n}\n\n/**\n * @ignore\n */\nexport type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerResponse {\n message:\n | 'location_selected'\n | 'location_created'\n | 'location_updated'\n | 'exit_app'\n | 'request_enable_protected_apps'\n | 'fatal_exit'\n | 'request_location_permission';\n payload: any;\n}\n"],"mappings":""}
@@ -290,7 +290,9 @@ const isAndroidNotificationGranted = async () => {
290
290
  if (Number(sdkVersion) < 33) {
291
291
  return true;
292
292
  }
293
- const hasPermission = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
293
+ const permission = PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS || PermissionsAndroid.PERMISSIONS.POST_NOTIFICATION;
294
+ if (!permission) throw new Error('Unable to request notification permission');
295
+ const hasPermission = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS || PermissionsAndroid.PERMISSIONS.POST_NOTIFICATION);
294
296
  return hasPermission;
295
297
  }, 'android');
296
298
  };
@@ -1 +1 @@
1
- {"version":3,"names":["OkHiNativeModule","OkHiNativeEvents","Alert","PermissionsAndroid","Platform","errorHandler","isValidPlatform","OkHiException","isLocationServicesEnabled","isLocationPermissionGranted","isBackgroundLocationPermissionGrantedAndroid","sdkVersion","getSystemVersion","Number","PERMISSIONS","ACCESS_BACKGROUND_LOCATION","hasPermission","check","console","warn","isBackgroundLocationPermissionGrantedIOS","isBackgroundLocationPermissionGranted","fn","OS","requestLocationPermissionAndroid","status","requestMultiple","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","requestLocationPermissionIOS","requestLocationPermission","isGranted","requestBackgroundLocationPermissionAndroid","permissions","requestBackgroundLocationPermissionIOS","requestBackgroundLocationPermission","requestEnableLocationServices","isGooglePlayServicesAvailable","requestEnableGooglePlayServices","request","locationPermissionType","rationale","callback","serviceError","code","SERVICE_UNAVAILABLE_CODE","message","googlePlayError","handleError","error","handleGooglePlayServiceRequest","then","googlePlayStatus","handleRationaleRequest","handleRationaleAlert","alertRationale","Promise","resolve","_","alert","title","text","grantButton","label","onPress","denyButton","style","onDismiss","handlePermissionRequest","removeAllListeners","addListener","permissionUpdate","whenInUseResult","initialWhenInUseResult","alwaysResult","currentStatus","retriveLocationPermissionStatus","showRationale","result","serviceStatus","enableResult","catch","openAppSettings","alwaysPerm","whenInUsePerm","requestTrackingAuthorization","canOpenProtectedAppsSettings","openProtectedAppsSettings","isAndroidNotificationGranted","POST_NOTIFICATIONS","requestAndroidNotificationPermission","existingPermissionStatus","isIOSNotificationGranted","isNotificationPermissionGranted","requestIOSNotificationPermission","requestNotificationPermission","UNSUPPORTED_PLATFORM_CODE","UNSUPPORTED_PLATFORM_MESSAGE"],"sources":["Helpers.ts"],"sourcesContent":["import { OkHiNativeModule, OkHiNativeEvents } from '../OkHiNativeModule';\nimport { Alert, Permission, PermissionsAndroid, Platform } from 'react-native';\nimport { errorHandler, isValidPlatform } from './_helpers';\nimport type {\n LocationPermissionCallback,\n LocationPermissionStatus,\n LocationRequestPermissionType,\n} from './types';\nimport { OkHiException } from './OkHiException';\n\n/**\n * Checks whether location services are enabled\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the service is available\n */\nexport const isLocationServicesEnabled = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationServicesEnabled);\n};\n\n/**\n * Checks whether when in use location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isLocationPermissionGranted = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationPermissionGranted);\n};\n\nconst isBackgroundLocationPermissionGrantedAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (Number(sdkVersion) < 23) {\n return true;\n }\n if (Number(sdkVersion) < 29) {\n return await isLocationPermissionGranted();\n }\n if (\n typeof PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION !==\n 'undefined'\n ) {\n const hasPermission = await PermissionsAndroid.check(\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION as Permission\n );\n return hasPermission;\n }\n console.warn(\n `PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION is undefined, this is an issue with the current version of RN you are running. Please consider upgrading`\n );\n return false;\n };\n\nconst isBackgroundLocationPermissionGrantedIOS = (): Promise<boolean> => {\n return OkHiNativeModule.isBackgroundLocationPermissionGranted();\n};\n\n/**\n * Checks whether background location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isBackgroundLocationPermissionGranted = (): Promise<boolean> => {\n const fn =\n Platform.OS === 'android'\n ? isBackgroundLocationPermissionGrantedAndroid\n : isBackgroundLocationPermissionGrantedIOS;\n return isValidPlatform(fn);\n};\n\nconst requestLocationPermissionAndroid = async (): Promise<boolean> => {\n const status: any = await PermissionsAndroid.requestMultiple([\n PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION as Permission,\n PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION as Permission,\n ]);\n return status['android.permission.ACCESS_FINE_LOCATION'] === 'granted';\n};\n\nconst requestLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestLocationPermission();\n};\n\n/**\n * Requests for when in use location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestLocationPermission = async (): Promise<boolean> => {\n const isGranted = await isLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestLocationPermissionAndroid\n : requestLocationPermissionIOS\n );\n};\n\nconst requestBackgroundLocationPermissionAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (Number(sdkVersion) < 23) return true;\n if (Number(sdkVersion) >= 29) {\n const permissions: any = [\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,\n ];\n const status: any = await PermissionsAndroid.requestMultiple(permissions);\n return (\n status['android.permission.ACCESS_BACKGROUND_LOCATION'] === 'granted'\n );\n } else {\n return await requestLocationPermissionAndroid();\n }\n };\n\nconst requestBackgroundLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestBackgroundLocationPermission();\n};\n\n/**\n * Requests for background location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestBackgroundLocationPermission =\n async (): Promise<boolean> => {\n const isGranted = await isBackgroundLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestBackgroundLocationPermissionAndroid\n : requestBackgroundLocationPermissionIOS\n );\n };\n\n/**\n * Requests the user to enable location services by showing an in app modal on android and opening location settings on iOS\n * @returns {Promise<boolean>} A promise that resolves to either a boolean value on android or null on iOS\n */\nexport const requestEnableLocationServices = (): Promise<boolean | null> => {\n return isValidPlatform(OkHiNativeModule.requestEnableLocationServices);\n};\n\n/**\n * Android Only - Checks if Google Play Services is available\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const isGooglePlayServicesAvailable = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.isGooglePlayServicesAvailable,\n 'android'\n );\n};\n\n/**\n * Android Only - Requests user to enable Google Play Services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const requestEnableGooglePlayServices = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.requestEnableGooglePlayServices,\n 'android'\n );\n};\n\n/**\n * Returns the system version of the current platform\n * @returns {Promise<boolean>} A promise that resolves either a string on iOS or number on Android\n */\nexport const getSystemVersion = (): Promise<string | number> =>\n isValidPlatform(OkHiNativeModule.getSystemVersion);\n\n/**\n * Requests location permission from the user. It'll also attempt to activate any disbaled services (Android Only)\n */\nexport const request = (\n locationPermissionType: LocationRequestPermissionType,\n rationale: {\n title: string;\n text: string;\n successButton?: { label: string };\n denyButton?: { label: string };\n } | null,\n callback: LocationPermissionCallback\n) => {\n const serviceError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Location service is currently not available. Please enable in app settings',\n });\n\n const googlePlayError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Google Play Services is currently unavailable. Please enable in settings',\n });\n\n const handleError = (error: OkHiException) => {\n callback(null, error);\n };\n\n const handleGooglePlayServiceRequest = () => {\n requestEnableGooglePlayServices().then((googlePlayStatus) => {\n if (!googlePlayStatus) {\n handleError(googlePlayError);\n } else {\n handleRationaleRequest();\n }\n });\n };\n\n const handleRationaleAlert = (alertRationale: {\n title: string;\n text: string;\n grantButton?: { label: string };\n denyButton?: { label: string };\n }) => {\n return new Promise((resolve, _) => {\n Alert.alert(\n alertRationale.title,\n alertRationale.text,\n [\n {\n text: alertRationale.grantButton\n ? alertRationale.grantButton.label\n : 'Grant',\n onPress: () => {\n resolve(true);\n },\n },\n {\n text: alertRationale.denyButton\n ? alertRationale.denyButton.label\n : 'Deny',\n onPress: () => {\n resolve(false);\n },\n style: 'cancel',\n },\n ],\n {\n onDismiss: () => {\n resolve(false);\n },\n }\n );\n });\n };\n\n const handlePermissionRequest = () => {\n if (Platform.OS === 'ios') {\n OkHiNativeEvents.removeAllListeners('onLocationPermissionStatusUpdate');\n OkHiNativeEvents.addListener(\n 'onLocationPermissionStatusUpdate',\n (permissionUpdate) => {\n callback(permissionUpdate, null);\n }\n );\n if (locationPermissionType === 'whenInUse') {\n OkHiNativeModule.requestLocationPermission();\n } else {\n OkHiNativeModule.requestBackgroundLocationPermission();\n }\n } else {\n if (locationPermissionType === 'whenInUse') {\n requestLocationPermissionAndroid().then((whenInUseResult) =>\n callback(whenInUseResult ? 'authorizedWhenInUse' : 'denied', null)\n );\n } else {\n requestLocationPermissionAndroid().then((initialWhenInUseResult) => {\n if (!initialWhenInUseResult) {\n callback('denied', null);\n } else {\n callback('authorizedWhenInUse', null);\n requestBackgroundLocationPermission().then((alwaysResult) => {\n callback(\n alwaysResult ? 'authorizedAlways' : 'authorizedWhenInUse',\n null\n );\n });\n }\n });\n }\n }\n };\n\n const handleRationaleRequest = async () => {\n const currentStatus = await retriveLocationPermissionStatus();\n let showRationale = true;\n if (\n locationPermissionType === 'whenInUse' &&\n (currentStatus === 'authorizedWhenInUse' ||\n currentStatus === 'authorizedAlways')\n ) {\n showRationale = false;\n }\n if (\n locationPermissionType === 'always' &&\n currentStatus === 'authorizedAlways'\n ) {\n showRationale = false;\n }\n if (rationale && showRationale) {\n const result = await handleRationaleAlert(rationale);\n if (!result) {\n callback('rationaleDissmissed', null);\n } else {\n handlePermissionRequest();\n }\n } else {\n handlePermissionRequest();\n }\n };\n\n isLocationServicesEnabled()\n .then((serviceStatus) => {\n if (!serviceStatus && Platform.OS === 'ios') {\n handleError(serviceError);\n } else if (!serviceStatus && Platform.OS === 'android') {\n requestEnableLocationServices()\n .then((enableResult) => {\n if (!enableResult) {\n handleError(serviceError);\n } else {\n handleGooglePlayServiceRequest();\n }\n })\n .catch(handleError);\n } else {\n if (Platform.OS === 'ios') {\n handleRationaleRequest();\n } else {\n handleGooglePlayServiceRequest();\n }\n }\n })\n .catch(handleError);\n};\n\n/**\n * Open the device's app settings.\n */\nexport const openAppSettings = () => {\n OkHiNativeModule.openAppSettings();\n};\n\n/**\n * Retrives the location permission status from the device\n */\nexport const retriveLocationPermissionStatus =\n async (): Promise<LocationPermissionStatus> => {\n if (Platform.OS === 'ios') {\n return OkHiNativeModule.retriveLocationPermissionStatus() as Promise<LocationPermissionStatus>;\n }\n const alwaysPerm = await isBackgroundLocationPermissionGranted();\n if (alwaysPerm) {\n return 'authorizedAlways';\n }\n const whenInUsePerm = await isLocationPermissionGranted();\n return whenInUsePerm ? 'authorizedWhenInUse' : 'denied';\n };\n\n/**\n * Requests tracking authorization from the user. iOS only, iOS version >= 14\n * Read more: https://developer.apple.com/app-store/user-privacy-and-data-use/\n */\nexport const requestTrackingAuthorization = async (): Promise<\n string | null\n> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.requestTrackingAuthorization();\n return result;\n }, 'ios');\n};\n\n/**\n * Checks whether current device can open \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const canOpenProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.canOpenProtectedAppsSettings();\n return result;\n }, 'android');\n};\n\n/**\n * Opens \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const openProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.openProtectedAppsSettings();\n return result;\n }, 'android');\n};\n\nconst isAndroidNotificationGranted = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (Number(sdkVersion) < 33) {\n return true;\n }\n const hasPermission = await PermissionsAndroid.check(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS as Permission\n );\n return hasPermission;\n }, 'android');\n};\n\nconst requestAndroidNotificationPermission = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const existingPermissionStatus = await isAndroidNotificationGranted();\n if (existingPermissionStatus) {\n return true;\n }\n const status: any = await PermissionsAndroid.request(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS as Permission\n );\n return status === 'granted';\n }, 'android');\n};\n\nconst isIOSNotificationGranted = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n return OkHiNativeModule.isNotificationPermissionGranted();\n }, 'ios');\n};\n\nconst requestIOSNotificationPermission = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const existingPermissionStatus = await isIOSNotificationGranted();\n if (existingPermissionStatus) {\n return true;\n }\n return OkHiNativeModule.requestNotificationPermission();\n }, 'ios');\n};\n\n/**\n * Checks whether notification permission is granted on both android and ios devices\n */\nexport const isNotificationPermissionGranted = async (): Promise<boolean> => {\n if (Platform.OS === 'android') {\n return isAndroidNotificationGranted();\n } else if (Platform.OS === 'ios') {\n return isIOSNotificationGranted();\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n });\n }\n};\n\n/**\n * Requests notification permission from both android and ios devices\n */\nexport const requestNotificationPermission = async (): Promise<boolean> => {\n if (Platform.OS === 'android') {\n return requestAndroidNotificationPermission();\n } else if (Platform.OS === 'ios') {\n return requestIOSNotificationPermission();\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n });\n }\n};\n"],"mappings":"AAAA,SAASA,gBAAgB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,wBAAwB,CAAC,CAAC;EACnC,CAAC,MAAM;IACL,MAAM,IAAIrF,aAAa,CAAC;MACtBqC,IAAI,EAAErC,aAAa,CAACyF,yBAAyB;MAC7ClD,OAAO,EAAEvC,aAAa,CAAC0F;IACzB,CAAC,CAAC;EACJ;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMF,6BAA6B,GAAG,MAAAA,CAAA,KAA8B;EACzE,IAAI3F,QAAQ,CAACmB,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAOmE,oCAAoC,CAAC,CAAC;EAC/C,CAAC,MAAM,IAAItF,QAAQ,CAACmB,EAAE,KAAK,KAAK,EAAE;IAChC,OAAOuE,gCAAgC,CAAC,CAAC;EAC3C,CAAC,MAAM;IACL,MAAM,IAAIvF,aAAa,CAAC;MACtBqC,IAAI,EAAErC,aAAa,CAACyF,yBAAyB;MAC7ClD,OAAO,EAAEvC,aAAa,CAAC0F;IACzB,CAAC,CAAC;EACJ;AACF,CAAC"}
1
+ {"version":3,"names":["OkHiNativeModule","OkHiNativeEvents","Alert","PermissionsAndroid","Platform","errorHandler","isValidPlatform","OkHiException","isLocationServicesEnabled","isLocationPermissionGranted","isBackgroundLocationPermissionGrantedAndroid","sdkVersion","getSystemVersion","Number","PERMISSIONS","ACCESS_BACKGROUND_LOCATION","hasPermission","check","console","warn","isBackgroundLocationPermissionGrantedIOS","isBackgroundLocationPermissionGranted","fn","OS","requestLocationPermissionAndroid","status","requestMultiple","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","requestLocationPermissionIOS","requestLocationPermission","isGranted","requestBackgroundLocationPermissionAndroid","permissions","requestBackgroundLocationPermissionIOS","requestBackgroundLocationPermission","requestEnableLocationServices","isGooglePlayServicesAvailable","requestEnableGooglePlayServices","request","locationPermissionType","rationale","callback","serviceError","code","SERVICE_UNAVAILABLE_CODE","message","googlePlayError","handleError","error","handleGooglePlayServiceRequest","then","googlePlayStatus","handleRationaleRequest","handleRationaleAlert","alertRationale","Promise","resolve","_","alert","title","text","grantButton","label","onPress","denyButton","style","onDismiss","handlePermissionRequest","removeAllListeners","addListener","permissionUpdate","whenInUseResult","initialWhenInUseResult","alwaysResult","currentStatus","retriveLocationPermissionStatus","showRationale","result","serviceStatus","enableResult","catch","openAppSettings","alwaysPerm","whenInUsePerm","requestTrackingAuthorization","canOpenProtectedAppsSettings","openProtectedAppsSettings","isAndroidNotificationGranted","permission","POST_NOTIFICATIONS","POST_NOTIFICATION","Error","requestAndroidNotificationPermission","existingPermissionStatus","isIOSNotificationGranted","isNotificationPermissionGranted","requestIOSNotificationPermission","requestNotificationPermission","UNSUPPORTED_PLATFORM_CODE","UNSUPPORTED_PLATFORM_MESSAGE"],"sources":["Helpers.ts"],"sourcesContent":["import { OkHiNativeModule, OkHiNativeEvents } from '../OkHiNativeModule';\nimport { Alert, Permission, PermissionsAndroid, Platform } from 'react-native';\nimport { errorHandler, isValidPlatform } from './_helpers';\nimport type {\n LocationPermissionCallback,\n LocationPermissionStatus,\n LocationRequestPermissionType,\n} from './types';\nimport { OkHiException } from './OkHiException';\n\n/**\n * Checks whether location services are enabled\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the service is available\n */\nexport const isLocationServicesEnabled = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationServicesEnabled);\n};\n\n/**\n * Checks whether when in use location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isLocationPermissionGranted = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationPermissionGranted);\n};\n\nconst isBackgroundLocationPermissionGrantedAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (Number(sdkVersion) < 23) {\n return true;\n }\n if (Number(sdkVersion) < 29) {\n return await isLocationPermissionGranted();\n }\n if (\n typeof PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION !==\n 'undefined'\n ) {\n const hasPermission = await PermissionsAndroid.check(\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION as Permission\n );\n return hasPermission;\n }\n console.warn(\n `PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION is undefined, this is an issue with the current version of RN you are running. Please consider upgrading`\n );\n return false;\n };\n\nconst isBackgroundLocationPermissionGrantedIOS = (): Promise<boolean> => {\n return OkHiNativeModule.isBackgroundLocationPermissionGranted();\n};\n\n/**\n * Checks whether background location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isBackgroundLocationPermissionGranted = (): Promise<boolean> => {\n const fn =\n Platform.OS === 'android'\n ? isBackgroundLocationPermissionGrantedAndroid\n : isBackgroundLocationPermissionGrantedIOS;\n return isValidPlatform(fn);\n};\n\nconst requestLocationPermissionAndroid = async (): Promise<boolean> => {\n const status: any = await PermissionsAndroid.requestMultiple([\n PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION as Permission,\n PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION as Permission,\n ]);\n return status['android.permission.ACCESS_FINE_LOCATION'] === 'granted';\n};\n\nconst requestLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestLocationPermission();\n};\n\n/**\n * Requests for when in use location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestLocationPermission = async (): Promise<boolean> => {\n const isGranted = await isLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestLocationPermissionAndroid\n : requestLocationPermissionIOS\n );\n};\n\nconst requestBackgroundLocationPermissionAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (Number(sdkVersion) < 23) return true;\n if (Number(sdkVersion) >= 29) {\n const permissions: any = [\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,\n ];\n const status: any = await PermissionsAndroid.requestMultiple(permissions);\n return (\n status['android.permission.ACCESS_BACKGROUND_LOCATION'] === 'granted'\n );\n } else {\n return await requestLocationPermissionAndroid();\n }\n };\n\nconst requestBackgroundLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestBackgroundLocationPermission();\n};\n\n/**\n * Requests for background location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestBackgroundLocationPermission =\n async (): Promise<boolean> => {\n const isGranted = await isBackgroundLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestBackgroundLocationPermissionAndroid\n : requestBackgroundLocationPermissionIOS\n );\n };\n\n/**\n * Requests the user to enable location services by showing an in app modal on android and opening location settings on iOS\n * @returns {Promise<boolean>} A promise that resolves to either a boolean value on android or null on iOS\n */\nexport const requestEnableLocationServices = (): Promise<boolean | null> => {\n return isValidPlatform(OkHiNativeModule.requestEnableLocationServices);\n};\n\n/**\n * Android Only - Checks if Google Play Services is available\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const isGooglePlayServicesAvailable = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.isGooglePlayServicesAvailable,\n 'android'\n );\n};\n\n/**\n * Android Only - Requests user to enable Google Play Services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const requestEnableGooglePlayServices = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.requestEnableGooglePlayServices,\n 'android'\n );\n};\n\n/**\n * Returns the system version of the current platform\n * @returns {Promise<boolean>} A promise that resolves either a string on iOS or number on Android\n */\nexport const getSystemVersion = (): Promise<string | number> =>\n isValidPlatform(OkHiNativeModule.getSystemVersion);\n\n/**\n * Requests location permission from the user. It'll also attempt to activate any disbaled services (Android Only)\n */\nexport const request = (\n locationPermissionType: LocationRequestPermissionType,\n rationale: {\n title: string;\n text: string;\n successButton?: { label: string };\n denyButton?: { label: string };\n } | null,\n callback: LocationPermissionCallback\n) => {\n const serviceError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Location service is currently not available. Please enable in app settings',\n });\n\n const googlePlayError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Google Play Services is currently unavailable. Please enable in settings',\n });\n\n const handleError = (error: OkHiException) => {\n callback(null, error);\n };\n\n const handleGooglePlayServiceRequest = () => {\n requestEnableGooglePlayServices().then((googlePlayStatus) => {\n if (!googlePlayStatus) {\n handleError(googlePlayError);\n } else {\n handleRationaleRequest();\n }\n });\n };\n\n const handleRationaleAlert = (alertRationale: {\n title: string;\n text: string;\n grantButton?: { label: string };\n denyButton?: { label: string };\n }) => {\n return new Promise((resolve, _) => {\n Alert.alert(\n alertRationale.title,\n alertRationale.text,\n [\n {\n text: alertRationale.grantButton\n ? alertRationale.grantButton.label\n : 'Grant',\n onPress: () => {\n resolve(true);\n },\n },\n {\n text: alertRationale.denyButton\n ? alertRationale.denyButton.label\n : 'Deny',\n onPress: () => {\n resolve(false);\n },\n style: 'cancel',\n },\n ],\n {\n onDismiss: () => {\n resolve(false);\n },\n }\n );\n });\n };\n\n const handlePermissionRequest = () => {\n if (Platform.OS === 'ios') {\n OkHiNativeEvents.removeAllListeners('onLocationPermissionStatusUpdate');\n OkHiNativeEvents.addListener(\n 'onLocationPermissionStatusUpdate',\n (permissionUpdate) => {\n callback(permissionUpdate, null);\n }\n );\n if (locationPermissionType === 'whenInUse') {\n OkHiNativeModule.requestLocationPermission();\n } else {\n OkHiNativeModule.requestBackgroundLocationPermission();\n }\n } else {\n if (locationPermissionType === 'whenInUse') {\n requestLocationPermissionAndroid().then((whenInUseResult) =>\n callback(whenInUseResult ? 'authorizedWhenInUse' : 'denied', null)\n );\n } else {\n requestLocationPermissionAndroid().then((initialWhenInUseResult) => {\n if (!initialWhenInUseResult) {\n callback('denied', null);\n } else {\n callback('authorizedWhenInUse', null);\n requestBackgroundLocationPermission().then((alwaysResult) => {\n callback(\n alwaysResult ? 'authorizedAlways' : 'authorizedWhenInUse',\n null\n );\n });\n }\n });\n }\n }\n };\n\n const handleRationaleRequest = async () => {\n const currentStatus = await retriveLocationPermissionStatus();\n let showRationale = true;\n if (\n locationPermissionType === 'whenInUse' &&\n (currentStatus === 'authorizedWhenInUse' ||\n currentStatus === 'authorizedAlways')\n ) {\n showRationale = false;\n }\n if (\n locationPermissionType === 'always' &&\n currentStatus === 'authorizedAlways'\n ) {\n showRationale = false;\n }\n if (rationale && showRationale) {\n const result = await handleRationaleAlert(rationale);\n if (!result) {\n callback('rationaleDissmissed', null);\n } else {\n handlePermissionRequest();\n }\n } else {\n handlePermissionRequest();\n }\n };\n\n isLocationServicesEnabled()\n .then((serviceStatus) => {\n if (!serviceStatus && Platform.OS === 'ios') {\n handleError(serviceError);\n } else if (!serviceStatus && Platform.OS === 'android') {\n requestEnableLocationServices()\n .then((enableResult) => {\n if (!enableResult) {\n handleError(serviceError);\n } else {\n handleGooglePlayServiceRequest();\n }\n })\n .catch(handleError);\n } else {\n if (Platform.OS === 'ios') {\n handleRationaleRequest();\n } else {\n handleGooglePlayServiceRequest();\n }\n }\n })\n .catch(handleError);\n};\n\n/**\n * Open the device's app settings.\n */\nexport const openAppSettings = () => {\n OkHiNativeModule.openAppSettings();\n};\n\n/**\n * Retrives the location permission status from the device\n */\nexport const retriveLocationPermissionStatus =\n async (): Promise<LocationPermissionStatus> => {\n if (Platform.OS === 'ios') {\n return OkHiNativeModule.retriveLocationPermissionStatus() as Promise<LocationPermissionStatus>;\n }\n const alwaysPerm = await isBackgroundLocationPermissionGranted();\n if (alwaysPerm) {\n return 'authorizedAlways';\n }\n const whenInUsePerm = await isLocationPermissionGranted();\n return whenInUsePerm ? 'authorizedWhenInUse' : 'denied';\n };\n\n/**\n * Requests tracking authorization from the user. iOS only, iOS version >= 14\n * Read more: https://developer.apple.com/app-store/user-privacy-and-data-use/\n */\nexport const requestTrackingAuthorization = async (): Promise<\n string | null\n> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.requestTrackingAuthorization();\n return result;\n }, 'ios');\n};\n\n/**\n * Checks whether current device can open \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const canOpenProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.canOpenProtectedAppsSettings();\n return result;\n }, 'android');\n};\n\n/**\n * Opens \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const openProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.openProtectedAppsSettings();\n return result;\n }, 'android');\n};\n\nconst isAndroidNotificationGranted = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (Number(sdkVersion) < 33) {\n return true;\n }\n const permission =\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS ||\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATION;\n if (!permission)\n throw new Error('Unable to request notification permission');\n const hasPermission = await PermissionsAndroid.check(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS ||\n (PermissionsAndroid.PERMISSIONS.POST_NOTIFICATION as Permission)\n );\n return hasPermission;\n }, 'android');\n};\n\nconst requestAndroidNotificationPermission = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const existingPermissionStatus = await isAndroidNotificationGranted();\n if (existingPermissionStatus) {\n return true;\n }\n const status: any = await PermissionsAndroid.request(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS as Permission\n );\n return status === 'granted';\n }, 'android');\n};\n\nconst isIOSNotificationGranted = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n return OkHiNativeModule.isNotificationPermissionGranted();\n }, 'ios');\n};\n\nconst requestIOSNotificationPermission = async (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const existingPermissionStatus = await isIOSNotificationGranted();\n if (existingPermissionStatus) {\n return true;\n }\n return OkHiNativeModule.requestNotificationPermission();\n }, 'ios');\n};\n\n/**\n * Checks whether notification permission is granted on both android and ios devices\n */\nexport const isNotificationPermissionGranted = async (): Promise<boolean> => {\n if (Platform.OS === 'android') {\n return isAndroidNotificationGranted();\n } else if (Platform.OS === 'ios') {\n return isIOSNotificationGranted();\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n });\n }\n};\n\n/**\n * Requests notification permission from both android and ios devices\n */\nexport const requestNotificationPermission = async (): Promise<boolean> => {\n if (Platform.OS === 'android') {\n return requestAndroidNotificationPermission();\n } else if (Platform.OS === 'ios') {\n return requestIOSNotificationPermission();\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n });\n }\n};\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,qBAAqB;AACxE,SAASC,KAAK,EAAcC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC9E,SAASC,YAAY,EAAEC,eAAe,QAAQ,YAAY;AAM1D,SAASC,aAAa,QAAQ,iBAAiB;;AAE/C;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAwB;EAC/D,OAAOF,eAAe,CAACN,gBAAgB,CAACQ,yBAAyB,CAAC;AACpE,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGA,CAAA,KAAwB;EACjE,OAAOH,eAAe,CAACN,gBAAgB,CAACS,2BAA2B,CAAC;AACtE,CAAC;AAED,MAAMC,4CAA4C,GAChD,MAAAA,CAAA,KAA8B;EAC5B,MAAM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CAACmB,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAOsE,oCAAoC,CAAC,CAAC;EAC/C,CAAC,MAAM,IAAIzF,QAAQ,CAACmB,EAAE,KAAK,KAAK,EAAE;IAChC,OAAO0E,gCAAgC,CAAC,CAAC;EAC3C,CAAC,MAAM;IACL,MAAM,IAAI1F,aAAa,CAAC;MACtBqC,IAAI,EAAErC,aAAa,CAAC4F,yBAAyB;MAC7CrD,OAAO,EAAEvC,aAAa,CAAC6F;IACzB,CAAC,CAAC;EACJ;AACF,CAAC"}
@@ -20,6 +20,7 @@ export function initialize(configuration) {
20
20
  await OkHiNativeModule.initialize(JSON.stringify(configuration));
21
21
  } else {
22
22
  await OkHiNativeModule.initializeIOS(configuration.credentials.branchId, configuration.credentials.clientKey, configuration.context.mode);
23
+ await OkHiNativeModule.onStart();
23
24
  }
24
25
  }
25
26
  });
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","AppState","OkHiNativeModule","errorHandler","okhiApplicationConfiguration","initialize","configuration","currentState","OS","JSON","stringify","initializeIOS","credentials","branchId","clientKey","context","mode","getApplicationConfiguration","_okhiApplicationConfi","_okhiApplicationConfi2","auth","token","getAuthToken","error"],"sources":["index.ts"],"sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n return errorHandler(async () => {\n okhiApplicationConfiguration = configuration;\n if (AppState.currentState !== 'background') {\n if (Platform.OS === 'android') {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n } else {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n }\n }\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,YAAY,QAAQ,YAAY;AAGzC,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AAEzB,IAAIC,4BAAsE;;AAE1E;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACxBC,aAA2C,EAC5B;EACf,OAAOH,YAAY,CAAC,YAAY;IAC9BC,4BAA4B,GAAGE,aAAa;IAC5C,IAAIL,QAAQ,CAACM,YAAY,KAAK,YAAY,EAAE;MAC1C,IAAIP,QAAQ,CAACQ,EAAE,KAAK,SAAS,EAAE;QAC7B,MAAMN,gBAAgB,CAACG,UAAU,CAACI,IAAI,CAACC,SAAS,CAACJ,aAAa,CAAC,CAAC;MAClE,CAAC,MAAM;QACL,MAAMJ,gBAAgB,CAACS,aAAa,CAClCL,aAAa,CAACM,WAAW,CAACC,QAAQ,EAClCP,aAAa,CAACM,WAAW,CAACE,SAAS,EACnCR,aAAa,CAACS,OAAO,CAACC,IACxB,CAAC;MACH;IACF;EACF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeC,2BAA2BA,CAAA,EAA0C;EACzF,IAAI;IACF,IAAI,OAAOb,4BAA4B,KAAK,QAAQ,EAAE;MAAA,IAAAc,qBAAA,EAAAC,sBAAA;MACpD,OAAO;QACL,GAAGf,4BAA4B;QAC/BgB,IAAI,EAAE;UACJC,KAAK,EAAE,MAAMnB,gBAAgB,CAACoB,YAAY,CACxC,EAAAJ,qBAAA,GAAAd,4BAA4B,cAAAc,qBAAA,uBAA5BA,qBAAA,CAA8BN,WAAW,CAACC,QAAQ,KAAI,EAAE,EACxD,EAAAM,sBAAA,GAAAf,4BAA4B,cAAAe,sBAAA,uBAA5BA,sBAAA,CAA8BP,WAAW,CAACE,SAAS,KAAI,EACzD;QACF;MACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOS,KAAK,EAAE;IACd,MAAMA,KAAK;EACb;AACF"}
1
+ {"version":3,"names":["Platform","AppState","OkHiNativeModule","errorHandler","okhiApplicationConfiguration","initialize","configuration","currentState","OS","JSON","stringify","initializeIOS","credentials","branchId","clientKey","context","mode","onStart","getApplicationConfiguration","_okhiApplicationConfi","_okhiApplicationConfi2","auth","token","getAuthToken","error"],"sources":["index.ts"],"sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n return errorHandler(async () => {\n okhiApplicationConfiguration = configuration;\n if (AppState.currentState !== 'background') {\n if (Platform.OS === 'android') {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n } else {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n await OkHiNativeModule.onStart();\n }\n }\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,YAAY,QAAQ,YAAY;AAGzC,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AAEzB,IAAIC,4BAAsE;;AAE1E;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACxBC,aAA2C,EAC5B;EACf,OAAOH,YAAY,CAAC,YAAY;IAC9BC,4BAA4B,GAAGE,aAAa;IAC5C,IAAIL,QAAQ,CAACM,YAAY,KAAK,YAAY,EAAE;MAC1C,IAAIP,QAAQ,CAACQ,EAAE,KAAK,SAAS,EAAE;QAC7B,MAAMN,gBAAgB,CAACG,UAAU,CAACI,IAAI,CAACC,SAAS,CAACJ,aAAa,CAAC,CAAC;MAClE,CAAC,MAAM;QACL,MAAMJ,gBAAgB,CAACS,aAAa,CAClCL,aAAa,CAACM,WAAW,CAACC,QAAQ,EAClCP,aAAa,CAACM,WAAW,CAACE,SAAS,EACnCR,aAAa,CAACS,OAAO,CAACC,IACxB,CAAC;QACD,MAAMd,gBAAgB,CAACe,OAAO,CAAC,CAAC;MAClC;IACF;EACF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeC,2BAA2BA,CAAA,EAA0C;EACzF,IAAI;IACF,IAAI,OAAOd,4BAA4B,KAAK,QAAQ,EAAE;MAAA,IAAAe,qBAAA,EAAAC,sBAAA;MACpD,OAAO;QACL,GAAGhB,4BAA4B;QAC/BiB,IAAI,EAAE;UACJC,KAAK,EAAE,MAAMpB,gBAAgB,CAACqB,YAAY,CACxC,EAAAJ,qBAAA,GAAAf,4BAA4B,cAAAe,qBAAA,uBAA5BA,qBAAA,CAA8BP,WAAW,CAACC,QAAQ,KAAI,EAAE,EACxD,EAAAO,sBAAA,GAAAhB,4BAA4B,cAAAgB,sBAAA,uBAA5BA,sBAAA,CAA8BR,WAAW,CAACE,SAAS,KAAI,EACzD;QACF;MACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOU,KAAK,EAAE;IACd,MAAMA,KAAK;EACb;AACF"}
@@ -1,2 +1,2 @@
1
-
1
+ export {};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/**\n * Defines the structure of the user object requried by OkHi services and libraries.\n */\nexport interface OkHiUser {\n /**\n * The user's phone number. Must be MSISDN standard format. e.g +254712345678.\n */\n phone: string;\n /**\n * The user's first name.\n */\n firstName?: string;\n /**\n * The user's last name.\n */\n lastName?: string;\n /**\n * The user's email address.\n */\n email?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n id?: string;\n\n /**\n * The user's device firebase push notification token.\n */\n fcmPushNotificationToken?: string;\n}\n\n/**\n * Defines the current mode you'll be using OkHi's services as well as your application's meta information.\n */\nexport interface OkHiAppContext {\n /**\n * The current mode you'll be using OkHi services.\n */\n mode: 'sandbox' | 'prod' | string;\n /**\n * Your application's meta information.\n */\n app?: {\n /**\n * Your application's name.\n */\n name: string;\n /**\n * Your application's current version.\n */\n version: string;\n /**\n * Your application's current build number.\n */\n build: number;\n };\n /**\n * Meta information about the current developer.\n */\n developer?: string;\n}\n\n/**\n * Defines the structure of the OkHi location object once an address has been successfully created by the user.\n */\nexport interface OkHiLocation {\n /**\n * The latitude of the location.\n */\n lat: number;\n /**\n * The longitude of the location.\n */\n lon: number;\n /**\n * The OkHi's locationId. Usually obtained once an address has been successfully created by the user.\n */\n id?: string;\n /**\n * The id of a common residential or geological space such as apartment building or office block.\n */\n placeId?: string;\n /**\n * Geocode system for identifying an area anywhere on the Earth.\n * See https://plus.codes/\n */\n plusCode?: string;\n /**\n * The location's property name.\n */\n propertyName?: string;\n /**\n * The location's street name.\n */\n streetName?: string;\n /**\n * A string that can be used to render information about the location.\n */\n title?: string;\n /**\n * A string that can be used to render meta information about the location.\n */\n subtitle?: string;\n /**\n * User generated directions to the location.\n */\n directions?: string;\n /**\n * User generated meta information about the location, how to access it and any other relevant notes.\n */\n otherInformation?: string;\n /**\n * A link to the user's address visible on browser or desktop.\n */\n url?: string;\n /**\n * A Google's StreetView Panorama Id, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoId?: string;\n /**\n * A Google's StreetView Panorama Url, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoUrl?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n userId?: string;\n /**\n * The location's property number.\n */\n propertyNumber?: string;\n /**\n * A link to the location's gate photo.\n */\n photo?: string;\n\n /**\n * A user's country\n */\n country?: string;\n\n /**\n * A user's city\n */\n city?: string;\n\n /**\n * A user's state\n */\n state?: string;\n\n /**\n * A formatted location information\n */\n displayTitle?: string;\n\n /**\n * A user's country code\n */\n countryCode?: string;\n}\n\n/**\n * @ignore\n */\nexport interface OkHiError {\n code: string;\n message: string;\n}\n\nexport type OkHiApplicationConfiguration = {\n credentials: {\n branchId: string;\n clientKey: string;\n };\n context: {\n mode: 'sandbox' | 'prod';\n developer?: 'okhi' | 'external';\n };\n app?: {\n name?: string;\n version?: string;\n build?: string;\n };\n notification?: {\n title: string;\n text: string;\n channelId: string;\n channelName: string;\n channelDescription: string;\n };\n};\n\nexport type LocationPermissionStatus =\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown';\n\nexport type LocationPermissionStatusCallback =\n | LocationPermissionStatus\n | 'rationaleDissmissed';\nexport type LocationRequestPermissionType = 'whenInUse' | 'always';\n\nexport type LocationPermissionCallback = (\n status: LocationPermissionStatusCallback | null,\n error: OkHiError | null\n) => any;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { OkHiException } from './OkHiException';\n\n/**\n * Defines the structure of the user object requried by OkHi services and libraries.\n */\nexport interface OkHiUser {\n /**\n * The user's phone number. Must be MSISDN standard format. e.g +254712345678.\n */\n phone: string;\n /**\n * The user's first name.\n */\n firstName?: string;\n /**\n * The user's last name.\n */\n lastName?: string;\n /**\n * The user's email address.\n */\n email?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n id?: string;\n\n /**\n * The user's device firebase push notification token.\n */\n fcmPushNotificationToken?: string;\n}\n\n/**\n * Defines the current mode you'll be using OkHi's services as well as your application's meta information.\n */\nexport interface OkHiAppContext {\n /**\n * The current mode you'll be using OkHi services.\n */\n mode: 'sandbox' | 'prod' | string;\n /**\n * Your application's meta information.\n */\n app?: {\n /**\n * Your application's name.\n */\n name: string;\n /**\n * Your application's current version.\n */\n version: string;\n /**\n * Your application's current build number.\n */\n build: number;\n };\n /**\n * Meta information about the current developer.\n */\n developer?: string;\n}\n\n/**\n * Defines the structure of the OkHi location object once an address has been successfully created by the user.\n */\nexport interface OkHiLocation {\n /**\n * The latitude of the location.\n */\n lat: number;\n /**\n * The longitude of the location.\n */\n lon: number;\n /**\n * The OkHi's locationId. Usually obtained once an address has been successfully created by the user.\n */\n id?: string;\n /**\n * The id of a common residential or geological space such as apartment building or office block.\n */\n placeId?: string;\n /**\n * Geocode system for identifying an area anywhere on the Earth.\n * See https://plus.codes/\n */\n plusCode?: string;\n /**\n * The location's property name.\n */\n propertyName?: string;\n /**\n * The location's street name.\n */\n streetName?: string;\n /**\n * A string that can be used to render information about the location.\n */\n title?: string;\n /**\n * A string that can be used to render meta information about the location.\n */\n subtitle?: string;\n /**\n * User generated directions to the location.\n */\n directions?: string;\n /**\n * User generated meta information about the location, how to access it and any other relevant notes.\n */\n otherInformation?: string;\n /**\n * A link to the user's address visible on browser or desktop.\n */\n url?: string;\n /**\n * A Google's StreetView Panorama Id, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoId?: string;\n /**\n * A Google's StreetView Panorama Url, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoUrl?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n userId?: string;\n /**\n * The location's property number.\n */\n propertyNumber?: string;\n /**\n * A link to the location's gate photo.\n */\n photo?: string;\n\n /**\n * A user's country\n */\n country?: string;\n\n /**\n * A user's city\n */\n city?: string;\n\n /**\n * A user's state\n */\n state?: string;\n\n /**\n * A formatted location information\n */\n displayTitle?: string;\n\n /**\n * A user's country code\n */\n countryCode?: string;\n}\n\n/**\n * @ignore\n */\nexport interface OkHiError {\n code: string;\n message: string;\n}\n\nexport type OkHiApplicationConfiguration = {\n credentials: {\n branchId: string;\n clientKey: string;\n };\n context: {\n mode: 'sandbox' | 'prod';\n developer?: 'okhi' | 'external';\n };\n app?: {\n name?: string;\n version?: string;\n build?: string;\n };\n notification?: {\n title: string;\n text: string;\n channelId: string;\n channelName: string;\n channelDescription: string;\n };\n};\n\nexport type LocationPermissionStatus =\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown';\n\nexport type LocationPermissionStatusCallback =\n | LocationPermissionStatus\n | 'rationaleDissmissed';\nexport type LocationRequestPermissionType = 'whenInUse' | 'always';\n\nexport type LocationPermissionCallback = (\n status: LocationPermissionStatusCallback | null,\n error: OkHiException | null\n) => any;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","OkHiNativeModule","Okhi","Proxy","get","Error","OkHiNativeEvents","addListener"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\nconst LINKING_ERROR =\n `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype OkHiNativeModuleType = {\n isLocationServicesEnabled(): Promise<boolean>;\n isLocationPermissionGranted(): Promise<boolean>;\n isBackgroundLocationPermissionGranted(): Promise<boolean>;\n requestLocationPermission(): Promise<boolean>;\n requestBackgroundLocationPermission(): Promise<boolean>;\n requestEnableLocationServices(): Promise<boolean>;\n isGooglePlayServicesAvailable(): Promise<boolean>;\n requestEnableGooglePlayServices(): Promise<boolean>;\n getSystemVersion(): Promise<number | string>;\n getAuthToken(branchId: string, clientKey: string): Promise<string>;\n initialize(configuration: string): Promise<void>;\n startAddressVerification(\n phoneNumber: string,\n locationId: string,\n lat: Number,\n lon: Number,\n configuration?: OkVerifyStartConfiguration,\n fcmPushNotificationToken?: string\n ): Promise<string>;\n stopAddressVerification(\n phoneNumber: string,\n locationId: string\n ): Promise<string>;\n startForegroundService(): Promise<boolean>;\n stopForegroundService(): Promise<boolean>;\n isForegroundServiceRunning(): Promise<boolean>;\n initializeIOS(\n branchId: string,\n clientKey: string,\n environment: string\n ): Promise<boolean>;\n openAppSettings(): Promise<void>;\n retriveLocationPermissionStatus(): Promise<string>;\n requestTrackingAuthorization(): Promise<string | null>;\n canOpenProtectedAppsSettings(): Promise<boolean>;\n openProtectedAppsSettings(): Promise<boolean>;\n retrieveDeviceInfo(): Promise<{ manufacturer: string; model: string }>;\n setItem(key: string, value: string): Promise<boolean>;\n onNewToken(fcmPushNotificationToken: string): Promise<boolean>;\n onMessageReceived(): Promise<boolean>;\n isNotificationPermissionGranted(): Promise<boolean>;\n requestNotificationPermission(): Promise<boolean>;\n fetchCurrentLocation(): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n }>;\n fetchIOSLocationPermissionStatus(): Promise<\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown'\n >;\n};\n\nexport const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi\n ? NativeModules.Okhi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);\n\nOkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GAChB,4EAA2E,GAC5ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AA6D/C,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAI,GACpER,aAAa,CAACQ,IAAI,GAClB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAkB,CAACD,aAAa,CAACQ,IAAI,CAAC;AAE1EI,gBAAgB,CAACC,WAAW,CAAC,kCAAkC,EAAE,MAAM,IAAI,CAAC"}
1
+ {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","OkHiNativeModule","Okhi","Proxy","get","Error","OkHiNativeEvents","addListener"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\nconst LINKING_ERROR =\n `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype OkHiNativeModuleType = {\n isLocationServicesEnabled(): Promise<boolean>;\n isLocationPermissionGranted(): Promise<boolean>;\n isBackgroundLocationPermissionGranted(): Promise<boolean>;\n requestLocationPermission(): Promise<boolean>;\n requestBackgroundLocationPermission(): Promise<boolean>;\n requestEnableLocationServices(): Promise<boolean>;\n isGooglePlayServicesAvailable(): Promise<boolean>;\n requestEnableGooglePlayServices(): Promise<boolean>;\n getSystemVersion(): Promise<number | string>;\n getAuthToken(branchId: string, clientKey: string): Promise<string>;\n initialize(configuration: string): Promise<void>;\n startAddressVerification(\n phoneNumber: string,\n locationId: string,\n lat: Number,\n lon: Number,\n configuration?: OkVerifyStartConfiguration,\n fcmPushNotificationToken?: string\n ): Promise<string>;\n stopAddressVerification(\n phoneNumber: string,\n locationId: string\n ): Promise<string>;\n startForegroundService(): Promise<boolean>;\n stopForegroundService(): Promise<boolean>;\n isForegroundServiceRunning(): Promise<boolean>;\n initializeIOS(\n branchId: string,\n clientKey: string,\n environment: string\n ): Promise<boolean>;\n openAppSettings(): Promise<void>;\n retriveLocationPermissionStatus(): Promise<string>;\n requestTrackingAuthorization(): Promise<string | null>;\n canOpenProtectedAppsSettings(): Promise<boolean>;\n openProtectedAppsSettings(): Promise<boolean>;\n retrieveDeviceInfo(): Promise<{\n manufacturer: string;\n model: string;\n osVersion: string;\n platform: 'android' | 'ios';\n }>;\n setItem(key: string, value: string): Promise<boolean>;\n onNewToken(fcmPushNotificationToken: string): Promise<boolean>;\n onMessageReceived(): Promise<boolean>;\n isNotificationPermissionGranted(): Promise<boolean>;\n requestNotificationPermission(): Promise<boolean>;\n fetchCurrentLocation(): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n }>;\n fetchIOSLocationPermissionStatus(): Promise<\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown'\n >;\n onStart(): Promise<boolean>;\n};\n\nexport const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi\n ? NativeModules.Okhi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);\n\nOkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GAChB,4EAA2E,GAC5ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAmE/C,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAI,GACpER,aAAa,CAACQ,IAAI,GAClB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAkB,CAACD,aAAa,CAACQ,IAAI,CAAC;AAE1EI,gBAAgB,CAACC,WAAW,CAAC,kCAAkC,EAAE,MAAM,IAAI,CAAC"}
@@ -76,6 +76,7 @@ export interface OkHiLocationManagerProps {
76
76
  home?: boolean;
77
77
  work?: boolean;
78
78
  };
79
+ permissionsOnboarding?: boolean;
79
80
  };
80
81
  /**
81
82
  * **Optional:** Enable a user to either select an existing address, or force to create a new one
@@ -129,9 +130,6 @@ export type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';
129
130
  * @ignore
130
131
  */
131
132
  export interface OkHiLocationManagerResponse {
132
- message: 'location_selected' | 'location_created' | 'location_updated' | 'exit_app' | 'request_enable_protected_apps' | 'fatal_exit';
133
- payload: {
134
- user: any;
135
- location: any;
136
- };
133
+ message: 'location_selected' | 'location_created' | 'location_updated' | 'exit_app' | 'request_enable_protected_apps' | 'fatal_exit' | 'request_location_permission';
134
+ payload: any;
137
135
  }
@@ -1,3 +1,4 @@
1
+ import type { OkHiException } from './OkHiException';
1
2
  /**
2
3
  * Defines the structure of the user object requried by OkHi services and libraries.
3
4
  */
@@ -185,4 +186,4 @@ export type OkHiApplicationConfiguration = {
185
186
  export type LocationPermissionStatus = 'notDetermined' | 'restricted' | 'denied' | 'authorizedAlways' | 'authorizedWhenInUse' | 'authorized' | 'unknown';
186
187
  export type LocationPermissionStatusCallback = LocationPermissionStatus | 'rationaleDissmissed';
187
188
  export type LocationRequestPermissionType = 'whenInUse' | 'always';
188
- export type LocationPermissionCallback = (status: LocationPermissionStatusCallback | null, error: OkHiError | null) => any;
189
+ export type LocationPermissionCallback = (status: LocationPermissionStatusCallback | null, error: OkHiException | null) => any;
@@ -26,6 +26,8 @@ type OkHiNativeModuleType = {
26
26
  retrieveDeviceInfo(): Promise<{
27
27
  manufacturer: string;
28
28
  model: string;
29
+ osVersion: string;
30
+ platform: 'android' | 'ios';
29
31
  }>;
30
32
  setItem(key: string, value: string): Promise<boolean>;
31
33
  onNewToken(fcmPushNotificationToken: string): Promise<boolean>;
@@ -38,6 +40,7 @@ type OkHiNativeModuleType = {
38
40
  accuracy: number;
39
41
  }>;
40
42
  fetchIOSLocationPermissionStatus(): Promise<'notDetermined' | 'restricted' | 'denied' | 'authorizedAlways' | 'authorizedWhenInUse' | 'authorized' | 'unknown'>;
43
+ onStart(): Promise<boolean>;
41
44
  };
42
45
  export declare const OkHiNativeModule: OkHiNativeModuleType;
43
46
  export declare const OkHiNativeEvents: NativeEventEmitter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-okhi",
3
- "version": "1.2.4",
3
+ "version": "1.2.5-beta.2",
4
4
  "description": "The OkHi React Native library enables you to collect and verify addresses from your users",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  s.dependency "React-Core"
20
- s.dependency "OkHi", "1.9.9"
20
+ s.dependency "OkHi", "1.9.17-beta"
21
21
 
22
22
  # Don't install the dependencies when we run `pod install` in the old architecture.
23
23
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
@@ -20,7 +20,13 @@ import { start as sv } from '../OkVerify';
20
20
  import type { OkVerifyStartConfiguration } from '../OkVerify/types';
21
21
  import {
22
22
  getApplicationConfiguration,
23
+ isBackgroundLocationPermissionGranted,
24
+ isLocationPermissionGranted,
25
+ isLocationServicesEnabled,
26
+ openAppSettings,
23
27
  openProtectedAppsSettings,
28
+ requestBackgroundLocationPermission,
29
+ requestLocationPermission,
24
30
  } from '../OkCore';
25
31
  import { OkHiNativeModule } from '../OkHiNativeModule';
26
32
 
@@ -38,10 +44,12 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
38
44
  ? { ...props.style, ...defaultStyle }
39
45
  : defaultStyle;
40
46
 
41
- const { user, onSuccess, onCloseRequest, onError, loader, launch } = props;
47
+ const { user, onSuccess, onCloseRequest, onError, loader, launch, config } =
48
+ props;
42
49
  const webViewRef = useRef<WebView | null>(null);
43
50
  const startMessage =
44
51
  props.mode === 'create' ? 'start_app' : 'select_location';
52
+ const [ready, setReady] = useState(false);
45
53
 
46
54
  useEffect(() => {
47
55
  if (applicationConfiguration == null && token == null && user.phone) {
@@ -92,21 +100,131 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
92
100
  }
93
101
  }, [applicationConfiguration, props, token]);
94
102
 
103
+ useEffect(() => {
104
+ if (launch) {
105
+ if (
106
+ typeof config?.permissionsOnboarding === 'boolean' &&
107
+ !config.permissionsOnboarding
108
+ ) {
109
+ isBackgroundLocationPermissionGranted().then((result) => {
110
+ if (!result) {
111
+ onError(
112
+ new OkHiException({
113
+ code: OkHiException.PERMISSION_DENIED_CODE,
114
+ message:
115
+ 'Always location permission must be granted to launch OkCollect',
116
+ })
117
+ );
118
+ } else {
119
+ setReady(true);
120
+ }
121
+ });
122
+ } else {
123
+ setReady(true);
124
+ }
125
+ } else {
126
+ setReady(false);
127
+ }
128
+ }, [launch, config?.permissionsOnboarding]);
129
+
130
+ const runWebViewCallback = (value: string) => {
131
+ if (webViewRef.current) {
132
+ const jsString = `(function (){ if (typeof runOkHiLocationManagerCallback === "function") { runOkHiLocationManagerCallback("${value}") } })()`;
133
+ webViewRef.current.injectJavaScript(jsString);
134
+ }
135
+ };
136
+
137
+ const handleAndroidRequestLocationPermission = async (
138
+ level: 'whenInUse' | 'always'
139
+ ) => {
140
+ if (level === 'whenInUse') {
141
+ const result = await requestLocationPermission();
142
+ runWebViewCallback(result ? 'whenInUse' : 'denied');
143
+ } else if (level === 'always') {
144
+ const result = await requestBackgroundLocationPermission();
145
+ if (result) {
146
+ runWebViewCallback('always');
147
+ } else {
148
+ const isWhenInUseGranted = await isLocationPermissionGranted();
149
+ runWebViewCallback(isWhenInUseGranted ? 'whenInUse' : 'denied');
150
+ }
151
+ }
152
+ };
153
+
154
+ const handleIOSRequestLocationPermission = async (
155
+ level: 'whenInUse' | 'always'
156
+ ) => {
157
+ const unknownError = new OkHiException({
158
+ code: OkHiException.UNKNOWN_ERROR_CODE,
159
+ message:
160
+ 'Something went wrong while requesting permissions. Please try again later.',
161
+ });
162
+ try {
163
+ const isServiceAvailable = await isLocationServicesEnabled();
164
+ if (!isServiceAvailable) {
165
+ openAppSettings();
166
+ } else if (level === 'whenInUse') {
167
+ const result = await requestLocationPermission();
168
+ runWebViewCallback(result ? level : 'denied');
169
+ } else if (level === 'always') {
170
+ const granted = await isBackgroundLocationPermissionGranted();
171
+ if (granted) {
172
+ runWebViewCallback(level);
173
+ } else {
174
+ openAppSettings();
175
+ }
176
+ }
177
+ } catch (error) {
178
+ onError(unknownError);
179
+ }
180
+ };
181
+
182
+ const handleRequestLocationPermission = async ({
183
+ level,
184
+ }: {
185
+ level: 'whenInUse' | 'always';
186
+ }) => {
187
+ if (Platform.OS === 'android') {
188
+ handleAndroidRequestLocationPermission(level);
189
+ } else if (Platform.OS === 'ios') {
190
+ handleIOSRequestLocationPermission(level);
191
+ }
192
+ };
193
+
194
+ const handleOpenAppSettings = async () => {
195
+ try {
196
+ const granted = await isBackgroundLocationPermissionGranted();
197
+ if (granted) {
198
+ runWebViewCallback('always');
199
+ } else {
200
+ await openAppSettings();
201
+ }
202
+ } catch (error) {
203
+ const err = error as OkHiException;
204
+ onError(err);
205
+ }
206
+ };
207
+
95
208
  const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {
96
209
  try {
97
210
  const response: OkHiLocationManagerResponse = JSON.parse(data);
211
+
98
212
  if (response.message === 'fatal_exit') {
99
213
  onError(
100
214
  new OkHiException({
101
215
  code: OkHiException.UNKNOWN_ERROR_CODE,
102
- message: response.payload.toString(),
216
+ message: 'Something went wrong, please try again later.',
103
217
  })
104
218
  );
105
219
  } else if (response.message === 'exit_app') {
106
220
  onCloseRequest();
107
221
  } else if (response.message === 'request_enable_protected_apps') {
108
222
  openProtectedAppsSettings();
109
- } else {
223
+ } else if (
224
+ response.message === 'location_created' ||
225
+ response.message === 'location_selected' ||
226
+ response.message === 'location_updated'
227
+ ) {
110
228
  onSuccess({
111
229
  user: {
112
230
  ...response.payload.user,
@@ -139,6 +257,10 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
139
257
  });
140
258
  },
141
259
  });
260
+ } else if (response.message === 'request_location_permission') {
261
+ handleRequestLocationPermission(response.payload);
262
+ } else if (response.message === 'open_app_settings') {
263
+ handleOpenAppSettings();
142
264
  }
143
265
  } catch (error) {
144
266
  let errorMessage = 'Something went wrong';
@@ -204,10 +326,10 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
204
326
  <Modal
205
327
  animationType="slide"
206
328
  transparent={false}
207
- visible={launch}
329
+ visible={ready}
208
330
  onRequestClose={handleModalRequestClose}
209
331
  >
210
- {launch ? renderContent() : null}
332
+ {ready ? renderContent() : null}
211
333
  </Modal>
212
334
  );
213
335
  };