@pensasystems/pensa-react-native 0.1.0-beta.1

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 (35) hide show
  1. package/LICENSE +20 -0
  2. package/PensaSdkReactNative.podspec +25 -0
  3. package/README.md +279 -0
  4. package/android/build.gradle +90 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/pensasdkreactnative/PensaEventEmitterModule.kt +21 -0
  9. package/android/src/main/java/com/pensasdkreactnative/PensaListeners.kt +44 -0
  10. package/android/src/main/java/com/pensasdkreactnative/PensaSdkReactNativeModule.kt +172 -0
  11. package/android/src/main/java/com/pensasdkreactnative/PensaSdkReactNativePackage.kt +20 -0
  12. package/ios/PensaEventEmitter.swift +26 -0
  13. package/ios/PensaListeners.swift +37 -0
  14. package/ios/PensaSdkReactNative-Bridging-Header.h +43 -0
  15. package/ios/PensaSdkReactNative.mm +48 -0
  16. package/ios/PensaSdkReactNative.swift +121 -0
  17. package/ios/Podfile +35 -0
  18. package/lib/module/events.js +11 -0
  19. package/lib/module/events.js.map +1 -0
  20. package/lib/module/index.js +42 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/package.json +1 -0
  23. package/lib/module/types.js +2 -0
  24. package/lib/module/types.js.map +1 -0
  25. package/lib/typescript/package.json +1 -0
  26. package/lib/typescript/src/events.d.ts +7 -0
  27. package/lib/typescript/src/events.d.ts.map +1 -0
  28. package/lib/typescript/src/index.d.ts +16 -0
  29. package/lib/typescript/src/index.d.ts.map +1 -0
  30. package/lib/typescript/src/types.d.ts +26 -0
  31. package/lib/typescript/src/types.d.ts.map +1 -0
  32. package/package.json +154 -0
  33. package/src/events.ts +16 -0
  34. package/src/index.tsx +77 -0
  35. package/src/types.ts +29 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PensaSystems
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "PensaSdkReactNative"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => "https://github.com/Pensasystems/pensa-react-native-sdk.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+
18
+ if respond_to?(:install_modules_dependencies, true)
19
+ install_modules_dependencies(s)
20
+ else
21
+ s.dependency "React-Core"
22
+ end
23
+
24
+ s.dependency "PensaSdk", "~> 1.0.4"
25
+ end
package/README.md ADDED
@@ -0,0 +1,279 @@
1
+ # pensa-sdk-react-native
2
+
3
+ The Pensa Mobile App SDK is a developer toolkit designed to simplify adding Pensa’s capabilities to your mobile applications. It provides pre-built libraries, tools, and APIs to accelerate development and integration, offering streamlined SDK integration, easy initialization, and comprehensive functionality. With the Pensa SDK, you can enhance your app’s features or seamlessly integrate with other services for a cohesive user experience.
4
+
5
+ ## SDK Integration
6
+
7
+ Integrating the Pensa SDK into your React Native project is simple. Follow the steps below to add the SDK and enable advanced shelf recognition features in your app:
8
+
9
+ ### 1- Install the SDK Package
10
+
11
+ Add the npm package to your project:
12
+
13
+ ```bash
14
+ npm install pensa-sdk-react-native
15
+ ```
16
+
17
+ or
18
+
19
+ ```bash
20
+ yarn add pensa-sdk-react-native
21
+ ```
22
+
23
+ ### 2- Install Native Dependencies (iOS)
24
+
25
+ After installing the npm package, navigate to the iOS folder and install the native dependencies using CocoaPods:
26
+
27
+ ```bash
28
+ cd ios
29
+ pod install
30
+ ```
31
+
32
+ This step is required for iOS to link the native components of the SDK.
33
+
34
+ ---
35
+
36
+ Once installation is complete, you can proceed with SDK initialization.
37
+
38
+ ## SDK Initialization
39
+
40
+ Initializing the Pensa SDK is straightforward. Follow the steps below to set up the SDK with your credentials and start using its features.
41
+
42
+ ### 1- Import and Call initPensa
43
+
44
+ Call `initPensa()` at the startup of your app, preferably in a root file like `index.js` before calling `AppRegistry.registerComponent`.
45
+
46
+ ```tsx
47
+ import {initPensa} from 'pensa-sdk-react-native';
48
+
49
+ initPensa({
50
+ clientId: 'YOUR_CLIENT_ID',
51
+ clientSecret: 'YOUR_CLIENT_SECRET',
52
+ isLoggingEnabled: true,
53
+ })
54
+ .then(() => {
55
+ console.log('[Pensa] SDK init success');
56
+ })
57
+ .catch((error) => {
58
+ console.log('[Pensa] SDK init error:', error);
59
+ });
60
+ ```
61
+
62
+ - `clientId` and `clientSecret` are required.
63
+ - `isLoggingEnabled` is optional. When true, internal SDK logs will be printed to console.
64
+
65
+ If `clientId` or `clientSecret` is missing, initialization will fail.
66
+
67
+ ### 2- Add Listeners (Optional)
68
+
69
+ To listen to SDK events such as upload progress, success, or failure, you can create a helper hook like below:
70
+
71
+ ```tsx
72
+ // hooks/usePensaListeners.ts
73
+ import {useEffect} from 'react';
74
+ import {PensaEvents} from 'pensa-sdk-react-native';
75
+
76
+ export const usePensaListeners = () => {
77
+ useEffect(() => {
78
+ const unsubscribeProgress = PensaEvents.addListener(
79
+ 'onScanUploadProgressUpdate',
80
+ (e) => {
81
+ console.log('[Pensa] Progress', e.progress, e.tdlinxId, e.scanAreaId);
82
+ },
83
+ );
84
+
85
+ const unsubscribeCompleted = PensaEvents.addListener(
86
+ 'onScanUploadCompleted',
87
+ (e) => {
88
+ console.log('[Pensa] Completed', e.tdlinxId, e.scanAreaId);
89
+ },
90
+ );
91
+
92
+ const unsubscribeFailed = PensaEvents.addListener(
93
+ 'onScanUploadFailed',
94
+ (e) => {
95
+ console.log('[Pensa] Failed', e.error, e.tdlinxId, e.scanAreaId);
96
+ },
97
+ );
98
+
99
+ const unsubscribeCantScan = PensaEvents.addListener(
100
+ 'onCantScanReported',
101
+ (e) => {
102
+ console.log('[Pensa] CantScan', e.reason, e.tdlinxId, e.scanAreaId);
103
+ },
104
+ );
105
+
106
+ return () => {
107
+ unsubscribeProgress();
108
+ unsubscribeCompleted();
109
+ unsubscribeFailed();
110
+ unsubscribeCantScan();
111
+ };
112
+ }, []);
113
+ };
114
+ ```
115
+
116
+ Then call the hook in your component:
117
+
118
+ ```tsx
119
+ import {usePensaListeners} from './hooks/usePensaListeners';
120
+
121
+ usePensaListeners();
122
+ ```
123
+
124
+ > ✅ You should call `usePensaListeners()` **before** `initPensa()`. Calling it after may result in missing early events emitted during SDK initialization.
125
+
126
+ This will automatically register and clean up all supported event listeners.
127
+
128
+ ---
129
+
130
+ Once initialized, you can use any of the SDK methods like `showShelfScans`, `showStoresScreen`, or `showScanArea`.
131
+
132
+ ## SDK Functionality
133
+
134
+ The Pensa library is a lightweight SDK that simplifies interactions through straightforward method calls. This SDK enables you to:
135
+
136
+ - **Locate stores**: Easily find the stores you're looking for.
137
+ - **Access stores directly**: Use global store IDs to access a specific store and initiate a scan directly.
138
+ - **View store history**: Conveniently access a list of previously visited stores.
139
+ - **Monitor scan uploads**: Track the upload status of your scans.
140
+
141
+ ### Sample Imports
142
+
143
+ Before using the SDK methods below, make sure to import the required functions:
144
+
145
+ ```tsx
146
+ import {
147
+ showShelfScans,
148
+ showProductScans,
149
+ showStoreSearchView,
150
+ showStoresScreen,
151
+ showScanArea,
152
+ showStockingScreen,
153
+ showStoreChecklist,
154
+ } from 'pensa-sdk-react-native';
155
+ ```
156
+
157
+ ### Searching stores
158
+
159
+ To initiate a store search using the Pensa SDK, integrate the following code snippet:
160
+
161
+ ```tsx
162
+ showStoreSearchView()
163
+ .catch((error) => {
164
+ console.log('Error displaying search store:', error);
165
+ });
166
+ ```
167
+
168
+ This will present a search interface where you can input keywords (e.g., store name, location) to find the desired store. Upon selecting a store from the search results, the SDK will automatically redirect you to that store's details, allowing you to begin a scan.
169
+
170
+ > The entered keyword must be at least 3 characters long.
171
+
172
+ ### Accessing Stores Directly with Global Store IDs
173
+
174
+ The Pensa SDK lets you directly access a store and initiate a scan using its global store ID. To do this, use the `showStoreChecklist` method:
175
+
176
+ ```tsx
177
+ showStoreChecklist('example-id')
178
+ .catch((error) => {
179
+ console.log('Error displaying store:', error);
180
+ });
181
+ ```
182
+
183
+ ### Sending Custom Parameters with Scans
184
+
185
+ In addition to using global store IDs, the Pensa SDK allows you to send custom parameters along with your scans. This can be useful for including company-specific information or metadata.
186
+
187
+ To send custom parameters, use the `sectionKey` and `guid` parameters in the `showStoreChecklist` method.
188
+
189
+ > It's important to note that both `sectionKey` and `guid` must be used together. If either parameter is missing, the SDK will only consider the `globalStoreId`.
190
+
191
+ ```tsx
192
+ showStoreChecklist('example-id', 'example-guid', 'example-section')
193
+ .catch((error) => {
194
+ console.log('Error displaying store:', error);
195
+ });
196
+ ```
197
+
198
+ ### Recently Visited Stores
199
+
200
+ The Pensa SDK maintains a cache of recently visited stores for easy access and reuse. This allows you to quickly return to a previously scanned store without searching for it again.
201
+
202
+ #### Adding Stores to the Cache
203
+
204
+ A store is automatically added to the "Recently Visited Stores" cache when you:
205
+ - Use the `showStoreChecklist()` method to access a store.
206
+ - Select a store from the search results after using `showStoreSearchView()`.
207
+
208
+ #### Accessing Recently Visited Stores
209
+
210
+ To display the "Recently Visited Stores" screen, use the following code:
211
+
212
+ ```tsx
213
+ showStoresScreen()
214
+ .catch((error) => {
215
+ console.log('Error displaying recently visited stores:', error);
216
+ });
217
+ ```
218
+
219
+ This will present a screen listing the recently visited stores. You can select a store from this screen to access its details and initiate a new scan.
220
+
221
+ ### Monitoring Scan Uploads
222
+
223
+ The Pensa SDK provides convenient methods to monitor the progress of your scan uploads. There are two separate methods depending on the type of scan:
224
+
225
+ #### Shelf Scans
226
+
227
+ To monitor shelf scan uploads, use the following method:
228
+
229
+ ```tsx
230
+ showShelfScans()
231
+ .catch((error) => {
232
+ console.log('Error displaying shelf uploads:', error);
233
+ });
234
+ ```
235
+
236
+ #### Product Scans
237
+
238
+ ```tsx
239
+ showProductScans()
240
+ .catch((error) => {
241
+ console.log('Error displaying product uploads:', error);
242
+ });
243
+ ```
244
+
245
+ Both methods present a screen that displays the status of each scan upload. You can use these screens to:
246
+
247
+ - Track upload progress: Observe the progress of ongoing uploads.
248
+ - View completed uploads: See a history of successfully uploaded scans.
249
+ - Cancel uploads: Stop the upload of any scan that is in progress.
250
+
251
+ These features give you complete control over your scan uploads and ensure you're always informed about their status.
252
+
253
+ ### Stocking Screen
254
+
255
+ The Pensa SDK allows you to access the stocking screen. This screen is used to review and manage stock actions related to the selected store.
256
+
257
+ ```tsx
258
+ showStockingScreen()
259
+ .catch((error) => {
260
+ console.log('Error displaying stocking screen:', error);
261
+ });
262
+ ```
263
+
264
+ ### Scan Area
265
+
266
+ To directly open a scan area, you must provide a `scanId` and either a `storeId` or a `globalStoreId`.:
267
+ ```tsx
268
+ showScanArea(scanId, storeId, globalStoreId)
269
+ .catch((error) => {
270
+ console.log('Error displaying scan area:', error);
271
+ });
272
+ ```
273
+
274
+ This method allows you to navigate directly to a scan area without going through the store selection flow.
275
+
276
+ ### Example Project
277
+
278
+ For code examples and integration best practices, refer to our GitHub repository.
279
+
@@ -0,0 +1,90 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['PensaSdkReactNative_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ maven {
10
+ url = uri("https://sdk.pensasystems.net/pensa-sdk-android")
11
+ }
12
+ }
13
+
14
+ dependencies {
15
+ classpath "com.android.tools.build:gradle:8.7.2"
16
+ // noinspection DifferentKotlinGradleVersion
17
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
18
+ }
19
+ }
20
+
21
+
22
+ apply plugin: "com.android.library"
23
+ apply plugin: "kotlin-android"
24
+
25
+
26
+ def getExtOrIntegerDefault(name) {
27
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PensaSdkReactNative_" + name]).toInteger()
28
+ }
29
+
30
+ def supportsNamespace() {
31
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
32
+ def major = parsed[0].toInteger()
33
+ def minor = parsed[1].toInteger()
34
+
35
+ // Namespace support was added in 7.3.0
36
+ return (major == 7 && minor >= 3) || major >= 8
37
+ }
38
+
39
+ android {
40
+ if (supportsNamespace()) {
41
+ namespace "com.pensasdkreactnative"
42
+
43
+ sourceSets {
44
+ main {
45
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
46
+ }
47
+ }
48
+ }
49
+
50
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
51
+
52
+ defaultConfig {
53
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
54
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
55
+ }
56
+
57
+ buildTypes {
58
+ release {
59
+ minifyEnabled false
60
+ }
61
+ }
62
+
63
+ lintOptions {
64
+ disable "GradleCompatible"
65
+ }
66
+
67
+ compileOptions {
68
+ sourceCompatibility JavaVersion.VERSION_17
69
+ targetCompatibility JavaVersion.VERSION_17
70
+ coreLibraryDesugaringEnabled true
71
+ }
72
+ }
73
+
74
+ repositories {
75
+ mavenCentral()
76
+ google()
77
+ maven {
78
+ url = uri("https://sdk.pensasystems.net/pensa-sdk-android")
79
+ }
80
+ }
81
+
82
+ def kotlin_version = getExtOrDefault("kotlinVersion")
83
+
84
+ dependencies {
85
+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
86
+ implementation "com.pensasystems:pensasdk:1.0.8"
87
+ implementation "com.facebook.react:react-android"
88
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
89
+ }
90
+
@@ -0,0 +1,5 @@
1
+ PensaSdkReactNative_kotlinVersion=2.0.21
2
+ PensaSdkReactNative_minSdkVersion=24
3
+ PensaSdkReactNative_targetSdkVersion=34
4
+ PensaSdkReactNative_compileSdkVersion=35
5
+ PensaSdkReactNative_ndkVersion=27.1.12297006
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.pensasdkreactnative">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,21 @@
1
+ package com.pensasdkreactnative
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
5
+ import com.facebook.react.bridge.WritableMap
6
+ import com.facebook.react.bridge.Arguments
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
+ import com.facebook.react.bridge.ReactMethod
9
+
10
+ class PensaEventEmitterModule(private val reactContext: ReactApplicationContext) :
11
+ ReactContextBaseJavaModule(reactContext) {
12
+
13
+ override fun getName(): String = "PensaEventEmitter"
14
+
15
+ fun sendEvent(eventName: String, params: Map<String, Any?>) {
16
+ val map: WritableMap = Arguments.makeNativeMap(params)
17
+ reactContext
18
+ .getJSModule(RCTDeviceEventEmitter::class.java)
19
+ .emit(eventName, map)
20
+ }
21
+ }
@@ -0,0 +1,44 @@
1
+ package com.pensasdkreactnative
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.pensasystems.pensasdk.listener.CantScanEventListener
5
+ import com.pensasystems.pensasdk.listener.ScanUploadListener
6
+
7
+ object PensaListeners : ScanUploadListener, CantScanEventListener {
8
+
9
+ private var emitter: PensaEventEmitterModule? = null
10
+
11
+ fun setup(reactContext: ReactApplicationContext) {
12
+ emitter = PensaEventEmitterModule(reactContext)
13
+ }
14
+
15
+ override fun onScanUploadCompleted(tdlinxId: String, scanAreaId: String) {
16
+ emitter?.sendEvent("onScanUploadCompleted", mapOf(
17
+ "tdlinxId" to tdlinxId,
18
+ "scanAreaId" to scanAreaId
19
+ ))
20
+ }
21
+
22
+ override fun onScanUploadFailed(tdlinxId: String, scanAreaId: String) {
23
+ emitter?.sendEvent("onScanUploadFailed", mapOf(
24
+ "tdlinxId" to tdlinxId,
25
+ "scanAreaId" to scanAreaId
26
+ ))
27
+ }
28
+
29
+ override fun onScanUploadProgressUpdate(tdlinxId: String, scanAreaId: String, progress: Int) {
30
+ emitter?.sendEvent("onScanUploadProgressUpdate", mapOf(
31
+ "tdlinxId" to tdlinxId,
32
+ "scanAreaId" to scanAreaId,
33
+ "progress" to progress
34
+ ))
35
+ }
36
+
37
+ override fun onCantScanReported(tdlinxId: String, scanAreaId: String, cantScanReason: String) {
38
+ emitter?.sendEvent("onCantScanReported", mapOf(
39
+ "tdlinxId" to tdlinxId,
40
+ "scanAreaId" to scanAreaId,
41
+ "reason" to cantScanReason
42
+ ))
43
+ }
44
+ }
@@ -0,0 +1,172 @@
1
+ package com.pensasdkreactnative
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
7
+ import com.facebook.react.bridge.ReadableMap
8
+ import com.pensasystems.pensasdk.PensaSdk
9
+ import com.pensasystems.pensasdk.PensaSdkConfiguration
10
+ import com.pensasystems.pensasdk.listener.CantScanEventListener
11
+ import com.pensasystems.pensasdk.listener.ScanUploadListener
12
+
13
+ class PensaSdkReactNativeModule(reactContext: ReactApplicationContext) :
14
+ ReactContextBaseJavaModule(reactContext) {
15
+ private val context = reactContext.applicationContext
16
+ private val rnContext = reactContext
17
+
18
+ init {
19
+ PensaListeners.setup(reactContext)
20
+ }
21
+
22
+ override fun getName(): String {
23
+ return NAME
24
+ }
25
+
26
+ companion object {
27
+ const val NAME = "PensaSdkReactNative"
28
+ }
29
+
30
+ @ReactMethod
31
+ fun initPensa(configMap: ReadableMap, promise: Promise) {
32
+ try {
33
+ val clientId = configMap.getString("clientId") ?: ""
34
+ val clientSecret = configMap.getString("clientSecret") ?: ""
35
+ val isLoggingEnabled = configMap.getBoolean("isLoggingEnabled")
36
+
37
+ val sdkConfig = PensaSdkConfiguration.Builder()
38
+ .setClientId(clientId)
39
+ .setClientSecret(clientSecret)
40
+ .enableLogging(isLoggingEnabled)
41
+ .setScanUploadListener(PensaListeners)
42
+ .setCantScanEventListener(PensaListeners)
43
+ .build()
44
+
45
+ PensaSdk.initPensa(
46
+ applicationContext = rnContext.applicationContext,
47
+ sdkConfiguration = sdkConfig,
48
+ onSuccess = {
49
+ promise.resolve(null)
50
+ },
51
+ onError = { errorMessage ->
52
+ if (!PensaSdk.isPensaStarted()) {
53
+ promise.reject("INIT_FAILED", errorMessage)
54
+ } else {
55
+ promise.resolve(null)
56
+ }
57
+ }
58
+ )
59
+
60
+ } catch (e: Exception) {
61
+ promise.reject("INIT_EXCEPTION", e.message, e)
62
+ }
63
+ }
64
+
65
+ @ReactMethod
66
+ fun isPensaStarted(promise: Promise) {
67
+ promise.resolve(PensaSdk.isPensaStarted())
68
+ }
69
+
70
+ @ReactMethod
71
+ fun showShelfScans(promise: Promise) {
72
+ val activity = currentActivity
73
+ if (activity != null) {
74
+ PensaSdk.showShelfScans(
75
+ context = activity,
76
+ onError = { error -> promise.reject("SHOW_SHELF_SCANS_FAILED", error) }
77
+ )
78
+ promise.resolve(null)
79
+ } else {
80
+ promise.reject("NO_ACTIVITY", "Current activity is null")
81
+ }
82
+ }
83
+ @ReactMethod
84
+ fun showProductScans(promise: Promise) {
85
+ val activity = currentActivity
86
+ if (activity != null) {
87
+ PensaSdk.showProductScans(
88
+ context = activity,
89
+ onError = { error -> promise.reject("SHOW_PRODUCT_SCANS_FAILED", error) }
90
+ )
91
+ promise.resolve(null)
92
+ } else {
93
+ promise.reject("NO_ACTIVITY", "Current activity is null")
94
+ }
95
+ }
96
+
97
+ @ReactMethod
98
+ fun showStoreSearchView(promise: Promise) {
99
+ val activity = currentActivity
100
+ if (activity != null) {
101
+ PensaSdk.showStoreSearchView(
102
+ context = activity,
103
+ onError = { error -> promise.reject("SHOW_STORES_SEARCH_SCREEN_FAILED", error) }
104
+ )
105
+ promise.resolve(null)
106
+ } else {
107
+ promise.reject("NO_ACTIVITY", "Current activity is null")
108
+ }
109
+ }
110
+
111
+ @ReactMethod
112
+ fun showStoresScreen(promise: Promise) {
113
+ val activity = currentActivity
114
+ if (activity != null) {
115
+ PensaSdk.showStoresScreen(
116
+ context = activity,
117
+ onError = { error -> promise.reject("SHOW_STORES_SCREEN_FAILED", error) }
118
+ )
119
+ promise.resolve(null)
120
+ } else {
121
+ promise.reject("NO_ACTIVITY", "Current activity is null")
122
+ }
123
+ }
124
+
125
+ @ReactMethod
126
+ fun showScanArea(scanId: Int, storeId: Int?, globalStoreId: String?, promise: Promise) {
127
+ val activity = currentActivity
128
+ if (activity != null) {
129
+ PensaSdk.showScanArea(
130
+ context = activity,
131
+ scanId = scanId,
132
+ storeId = storeId,
133
+ globalStoreId = globalStoreId,
134
+ onError = { error -> promise.reject("SHOW_SCAN_AREA_FAILED", error) }
135
+ )
136
+ promise.resolve(null)
137
+ } else {
138
+ promise.reject("NO_ACTIVITY", "Current activity is null")
139
+ }
140
+ }
141
+
142
+ @ReactMethod
143
+ fun showStockingScreen(promise: Promise) {
144
+ val activity = currentActivity
145
+ if (activity != null) {
146
+ PensaSdk.showStockingScreen(
147
+ context = activity,
148
+ onError = { error -> promise.reject("SHOW_STOCKING_SCREEN_FAILED", error) }
149
+ )
150
+ promise.resolve(null)
151
+ } else {
152
+ promise.reject("NO_ACTIVITY", "Current activity is null")
153
+ }
154
+ }
155
+
156
+ @ReactMethod
157
+ fun showStoreChecklist(globalStoreId: String, guid: String?, sectionKey: String?, promise: Promise) {
158
+ val activity = currentActivity
159
+ if (activity != null) {
160
+ PensaSdk.showStoreChecklist(
161
+ context = activity,
162
+ globalStoreId = globalStoreId,
163
+ guid = guid,
164
+ sectionKey = sectionKey,
165
+ onError = { error -> promise.reject("SHOW_STORE_CHECKLIST_FAILED", error) }
166
+ )
167
+ promise.resolve(null)
168
+ } else {
169
+ promise.reject("NO_ACTIVITY", "Current activity is null")
170
+ }
171
+ }
172
+ }
@@ -0,0 +1,20 @@
1
+ package com.pensasdkreactnative
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class PensaSdkReactNativePackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(
12
+ PensaSdkReactNativeModule(reactContext),
13
+ PensaEventEmitterModule(reactContext)
14
+ )
15
+ }
16
+
17
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
18
+ return emptyList()
19
+ }
20
+ }