react-native-steerpath-smart-map 1.29.4 → 2.0.0-alpha.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 (107) hide show
  1. package/.eslintrc.js +66 -0
  2. package/.prettierrc +7 -0
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +7 -0
  5. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.class +0 -0
  6. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.class +0 -0
  7. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.class +0 -0
  8. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.class +0 -0
  9. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.class +0 -0
  10. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.class +0 -0
  11. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.kt +28 -0
  12. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.class +0 -0
  13. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.class +0 -0
  14. package/android/bin/src/main/java/com/steerpath/rnsmartmap/Utils.class +0 -0
  15. package/android/build.gradle +22 -33
  16. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  17. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.java +22 -14
  18. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.java +9 -31
  19. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.java +11 -9
  20. package/android/src/main/java/com/steerpath/rnsmartmap/Utils.java +36 -36
  21. package/ios/RNSmartLocationManager.m +28 -3
  22. package/ios/RNSmartMapManager.m +10 -22
  23. package/lib/commonjs/SmartLocationManager.js +50 -0
  24. package/lib/commonjs/SmartLocationManager.js.map +1 -0
  25. package/lib/commonjs/SmartLocationManager.web.js +11 -0
  26. package/lib/commonjs/SmartLocationManager.web.js.map +1 -0
  27. package/lib/commonjs/SmartMapManager.js +59 -0
  28. package/lib/commonjs/SmartMapManager.js.map +1 -0
  29. package/lib/commonjs/SmartMapManager.web.js +24 -0
  30. package/lib/commonjs/SmartMapManager.web.js.map +1 -0
  31. package/lib/commonjs/index.js +28 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/commonjs/package.json +1 -0
  34. package/lib/module/SmartLocationManager.js +46 -0
  35. package/lib/module/SmartLocationManager.js.map +1 -0
  36. package/lib/module/SmartLocationManager.web.js +7 -0
  37. package/lib/module/SmartLocationManager.web.js.map +1 -0
  38. package/lib/module/SmartMapManager.js +54 -0
  39. package/lib/module/SmartMapManager.js.map +1 -0
  40. package/lib/module/SmartMapManager.web.js +20 -0
  41. package/lib/module/SmartMapManager.web.js.map +1 -0
  42. package/lib/module/index.js +5 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/typescript/SmartLocationManager.d.ts +19 -0
  45. package/lib/typescript/SmartLocationManager.d.ts.map +1 -0
  46. package/{dist → lib/typescript}/SmartLocationManager.web.d.ts +1 -0
  47. package/lib/typescript/SmartLocationManager.web.d.ts.map +1 -0
  48. package/{dist → lib/typescript}/SmartMapManager.d.ts +13 -15
  49. package/lib/typescript/SmartMapManager.d.ts.map +1 -0
  50. package/lib/typescript/SmartMapManager.web.d.ts +8 -0
  51. package/lib/typescript/SmartMapManager.web.d.ts.map +1 -0
  52. package/lib/typescript/index.d.ts +5 -0
  53. package/lib/typescript/index.d.ts.map +1 -0
  54. package/package.json +38 -13
  55. package/react-native-steerpath-smart-map.podspec +15 -12
  56. package/src/SmartLocationManager.ts +25 -9
  57. package/src/SmartMapManager.ts +12 -19
  58. package/src/SmartMapManager.web.ts +3 -24
  59. package/src/index.ts +3 -4
  60. package/tsconfig.json +14 -9
  61. package/.eslintrc.json +0 -81
  62. package/android/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.java +0 -29
  63. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.java +0 -103
  64. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.java +0 -284
  65. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.java +0 -470
  66. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.java +0 -307
  67. package/dist/SmartGeofenceManager.d.ts +0 -17
  68. package/dist/SmartGeofenceManager.js +0 -61
  69. package/dist/SmartGeofenceManager.web.d.ts +0 -9
  70. package/dist/SmartGeofenceManager.web.js +0 -10
  71. package/dist/SmartLocationManager.d.ts +0 -11
  72. package/dist/SmartLocationManager.js +0 -22
  73. package/dist/SmartLocationManager.web.js +0 -4
  74. package/dist/SmartMapEventManager.web.d.ts +0 -5
  75. package/dist/SmartMapEventManager.web.js +0 -10
  76. package/dist/SmartMapManager.js +0 -53
  77. package/dist/SmartMapManager.web.d.ts +0 -12
  78. package/dist/SmartMapManager.web.js +0 -33
  79. package/dist/SmartMapView.d.ts +0 -3
  80. package/dist/SmartMapView.js +0 -294
  81. package/dist/SmartMapView.web.d.ts +0 -3
  82. package/dist/SmartMapView.web.js +0 -270
  83. package/dist/SmartMapViewProps.d.ts +0 -267
  84. package/dist/SmartMapViewProps.js +0 -76
  85. package/dist/index.d.ts +0 -5
  86. package/dist/index.js +0 -5
  87. package/dist/internalUtils.d.ts +0 -1
  88. package/dist/internalUtils.js +0 -5
  89. package/ios/RCTConvert+SmartMapView.h +0 -35
  90. package/ios/RCTConvert+SmartMapView.m +0 -295
  91. package/ios/RNSmartGeofenceManager.h +0 -24
  92. package/ios/RNSmartGeofenceManager.m +0 -110
  93. package/ios/RNSmartMapUserTaskEventManager.h +0 -19
  94. package/ios/RNSmartMapUserTaskEventManager.m +0 -46
  95. package/ios/RNSmartMapView.h +0 -37
  96. package/ios/RNSmartMapView.m +0 -21
  97. package/ios/RNSmartMapViewManager.h +0 -27
  98. package/ios/RNSmartMapViewManager.m +0 -608
  99. package/package-lock.json +0 -6570
  100. package/src/SmartGeofenceManager.ts +0 -94
  101. package/src/SmartGeofenceManager.web.ts +0 -11
  102. package/src/SmartMapEventManager.web.ts +0 -13
  103. package/src/SmartMapView.tsx +0 -377
  104. package/src/SmartMapView.web.tsx +0 -342
  105. package/src/SmartMapViewProps.ts +0 -338
  106. package/src/internalUtils.ts +0 -5
  107. package/src/typings/steerpath-smart-sdk.d.ts +0 -5
package/.eslintrc.js ADDED
@@ -0,0 +1,66 @@
1
+ // .eslintrc.js
2
+ module.exports = {
3
+ root: true,
4
+ parser: '@typescript-eslint/parser',
5
+ parserOptions: {
6
+ ecmaFeatures: {
7
+ jsx: true,
8
+ },
9
+ ecmaVersion: 2018,
10
+ sourceType: 'module',
11
+ },
12
+ plugins: [
13
+ 'react',
14
+ '@typescript-eslint',
15
+ 'prettier',
16
+ 'jsx-a11y',
17
+ 'import',
18
+ 'react-hooks',
19
+ ],
20
+ extends: [
21
+ 'eslint:recommended',
22
+ 'airbnb',
23
+ 'plugin:react/recommended',
24
+ 'prettier',
25
+ ],
26
+ rules: {
27
+ 'react/react-in-jsx-scope': 'off',
28
+ 'import/prefer-default-export': 'off',
29
+ 'prettier/prettier': 'error',
30
+ 'react-hooks/exhaustive-deps': 'error',
31
+ 'no-unused-expressions': 'off',
32
+ 'no-undef': 'error',
33
+ 'prettier/prettier': 'error',
34
+ 'import/extensions': [
35
+ 'error',
36
+ 'ignorePackages',
37
+ {
38
+ ts: 'never',
39
+ tsx: 'never',
40
+ js: 'never',
41
+ jsx: 'never',
42
+ },
43
+ ],
44
+ 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
45
+ "@typescript-eslint/no-unused-vars": [
46
+ "error",
47
+ {
48
+ "vars": "all",
49
+ "args": "none",
50
+ "argsIgnorePattern": "_",
51
+ "varsIgnorePattern": "_"
52
+ }
53
+ ],
54
+ },
55
+ settings: {
56
+ 'import/resolver': {
57
+ alias: {
58
+ map: [['@', './']],
59
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
60
+ },
61
+ },
62
+ react: {
63
+ version: 'detect',
64
+ },
65
+ },
66
+ };
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 80,
5
+ "tabWidth": 2,
6
+ "semi": true
7
+ }
package/CHANGELOG.md CHANGED
@@ -15,6 +15,45 @@ This package is built on top of Steerpath's Smart SDK, and most of releases are
15
15
  - [iOS](https://s3-eu-west-1.amazonaws.com/steerpath/ios/releases/smart-sdk-changelog/index.html)
16
16
  - [Web](https://s3-eu-west-1.amazonaws.com/steerpath-web-sdk/documentation/smart/latest/index.html)
17
17
 
18
+ ## [2.0.0-alpha.1] - 2025-01-27
19
+
20
+ Smart SDK is now a so called "Bluedot SDK" which main task is to provide indoor positioning.
21
+ All map related content is removed.
22
+
23
+ ### Breaking changes
24
+ - Removed SmartGeofenceManager
25
+ - Removed SmartMapEventManager
26
+ - Removed SmartMapView
27
+ - Removed SmartMapViewProps
28
+ - Renamed SmartSDK.fetchVersions to SmartSDK.fetchVersion
29
+ - returns just a single string. See docs.
30
+ - Changed return type from Callback to Promise
31
+ - Removed SmartSdk.setLanguage
32
+ - Web support dropped
33
+
34
+ ### Added
35
+ - SmartLocationManager.getLocation
36
+ - Gets user's location one time. Mostly used for internal workaround for sending events from native to JS. See comments in SmartLocationManager.ts
37
+
38
+ ### iOS:
39
+ - Updated min version to iOS 15.1
40
+ - Mapbox dependency was removed so library consumers need to update their Podfile.
41
+ - Remove source 'https://bitbucket.org/nimbledevices/steerpath-mapbox-ios-podspec.git' from Podfile
42
+ - Smart SDK source repo was changed from bitbucket to github
43
+ - Change source repo to source 'https://github.com/steerpath/steerpath-smart-sdk-podspec.git' in Podfile
44
+
45
+ ### Android:
46
+ - min SDK version is now 24.
47
+ - target SDK version upgraded to 35.
48
+ - uses gradle 8.7
49
+
50
+ ### Web:
51
+ - Removed web support, only stub implementation to prevent runtime/build issues on react-native
52
+
53
+ ## [1.29.5] - 2025-08-28
54
+
55
+ - Bump Android Smart SDK version to android-smart-1.23.3 to fix the default config
56
+
18
57
  ## [1.29.4] - 2024-11-18
19
58
 
20
59
  - Bump Android Smart SDK version to android-smart-1.23.2 to fix crash when starting live service on Android 15 devices, before location permissions are granted.
package/README.md CHANGED
@@ -20,6 +20,13 @@ We only support Cocoapod linking for iOS at the moment
20
20
 
21
21
  In your `ios/Podfile`, add the following lines to the top it:
22
22
 
23
+ Version >= 2.0.0
24
+ ```ruby
25
+ source 'https://github.com/CocoaPods/Specs.git'
26
+ source 'https://github.com/steerpath/steerpath-smart-sdk-podspec.git'
27
+ ```
28
+
29
+ or version < 2.0.0
23
30
  ```ruby
24
31
  source 'https://github.com/CocoaPods/Specs.git'
25
32
  source 'https://bitbucket.org/nimbledevices/steerpath-mapbox-ios-podspec.git'
@@ -0,0 +1,28 @@
1
+ package com.steerpath.rnsmartmap
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
+ class RNSmartMapPackage : ReactPackage {
9
+
10
+ // 1. Return type must be List<NativeModule> (No '?' and no 'Mutable')
11
+ override fun createNativeModules(
12
+ reactContext: ReactApplicationContext
13
+ ): List<NativeModule> {
14
+ val modules = mutableListOf<NativeModule>() // Create it as mutable locally
15
+
16
+ modules.add(RNSmartMapManager(reactContext))
17
+ modules.add(RNSmartLocationManager(reactContext))
18
+
19
+ return modules // Kotlin automatically casts MutableList to List
20
+ }
21
+
22
+ // 2. Return type must be List<ViewManager<*, *>> (No '?' and no 'Mutable')
23
+ override fun createViewManagers(
24
+ reactContext: ReactApplicationContext
25
+ ): List<ViewManager<*, *>> {
26
+ return emptyList() // The most idiomatic way to return an empty list in Kotlin
27
+ }
28
+ }
@@ -5,64 +5,53 @@ buildscript {
5
5
  repositories {
6
6
  mavenCentral()
7
7
  google()
8
- jcenter()
9
8
  }
10
9
 
11
10
  dependencies {
12
- classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '4.0.2')}")
11
+ classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '8.7.0')}")
12
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '2.1.0')}"
13
13
  }
14
14
  }
15
15
 
16
16
  apply plugin: 'com.android.library'
17
17
  apply plugin: 'maven-publish'
18
+ apply plugin: 'kotlin-android'
18
19
 
19
- def DEFAULT_COMPILE_SDK_VERSION = 30
20
- def DEFAULT_BUILD_TOOLS_VERSION = "30.0.3"
21
- def DEFAULT_MIN_SDK_VERSION = 21
22
- def DEFAULT_TARGET_SDK_VERSION = 30
23
-
24
- def supportsNamespace() {
25
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
26
- def major = parsed[0].toInteger()
27
- def minor = parsed[1].toInteger()
28
-
29
- // Namespace support was added in 7.3.0
30
- if (major == 7 && minor >= 3) {
31
- return true
32
- }
33
-
34
- return major >= 8
35
- }
20
+ def DEFAULT_COMPILE_SDK_VERSION = 35
21
+ def DEFAULT_MIN_SDK_VERSION = 24
22
+ def DEFAULT_TARGET_SDK_VERSION = 35
36
23
 
37
24
  android {
38
25
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
39
- buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
40
26
 
41
- if (supportsNamespace()) {
42
- namespace "com.steerpath.rnsmartmap"
43
- }
27
+ namespace "com.steerpath.rnsmartmap"
44
28
 
45
29
 
46
30
  defaultConfig {
47
31
  minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
48
32
  targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
49
33
  versionCode 1
50
- versionName "1.0"
34
+ versionName "2.0"
51
35
  }
52
36
  lintOptions {
53
37
  abortOnError false
54
38
  }
55
39
 
56
40
  compileOptions {
57
- sourceCompatibility JavaVersion.VERSION_1_8
58
- targetCompatibility JavaVersion.VERSION_1_8
41
+ sourceCompatibility JavaVersion.VERSION_17
42
+ targetCompatibility JavaVersion.VERSION_17
43
+ }
44
+
45
+ kotlinOptions {
46
+ jvmTarget = '17'
47
+ }
48
+
49
+ lintOptions {
50
+ abortOnError false
59
51
  }
60
52
  }
61
53
 
62
54
  repositories {
63
- maven {
64
- url "$projectDir/../node_modules/react-native/android"
65
- }
66
55
  mavenCentral()
67
56
  // For Steerpath Smart Map SDK
68
57
  maven { url "https://android-sdk.steerpath.net" }
@@ -70,8 +59,8 @@ repositories {
70
59
  }
71
60
 
72
61
  dependencies {
73
- implementation "com.facebook.react:react-native:${safeExtGet('reactnativeVersion', '+')}"
74
- implementation "com.steerpath:smart:android-smart-1.23.2"
75
- implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
76
- implementation "androidx.lifecycle:lifecycle-viewmodel:2.2.0"
62
+ implementation "com.facebook.react:react-native"
63
+ implementation "com.facebook.react:react-android"
64
+ implementation "com.steerpath:smart:android-smart-2.0.0"
65
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.7"
77
66
  }
@@ -1,6 +1,6 @@
1
1
  #Wed May 11 12:57:00 EEST 2022
2
2
  distributionBase=GRADLE_USER_HOME
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
4
4
  distributionPath=wrapper/dists
5
5
  zipStorePath=wrapper/dists
6
6
  zipStoreBase=GRADLE_USER_HOME
@@ -1,13 +1,9 @@
1
1
  package com.steerpath.rnsmartmap;
2
2
 
3
- import static com.steerpath.rnsmartmap.RNEventKeys.ON_LOCATION_CHANGED;
4
-
5
- import android.util.Log;
6
-
7
3
  import androidx.annotation.NonNull;
8
4
 
5
+ import com.facebook.react.bridge.Promise;
9
6
  import com.facebook.react.bridge.ReactApplicationContext;
10
- import com.facebook.react.bridge.ReactContext;
11
7
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
8
  import com.facebook.react.bridge.ReactMethod;
13
9
  import com.facebook.react.bridge.WritableMap;
@@ -21,12 +17,12 @@ import javax.annotation.Nullable;
21
17
 
22
18
  public class RNSmartLocationManager extends ReactContextBaseJavaModule implements SmartLocationListener{
23
19
 
24
- private final ReactApplicationContext appContext;
25
20
  private int listenerCount = 0;
21
+ private static String ON_LOCATION_CHANGED = "locationChanged";
22
+ private WritableMap location = null;
26
23
 
27
24
  public RNSmartLocationManager(@Nonnull ReactApplicationContext reactContext) {
28
25
  super(reactContext);
29
- this.appContext = reactContext;
30
26
  }
31
27
 
32
28
  @NonNull
@@ -63,14 +59,26 @@ public class RNSmartLocationManager extends ReactContextBaseJavaModule implement
63
59
  }
64
60
  map.putInt("floorIndex", floorIndex);
65
61
  map.putDouble("accuracyM", accuracyM);
66
- sendEvent(appContext, ON_LOCATION_CHANGED, map);
62
+
63
+ this.location = map.copy();
64
+
65
+ // See comment about workaround in src/SmartLocationManager.ts
66
+ // sendEvent(map);
67
+ }
68
+
69
+ @ReactMethod
70
+ public void getLocation(Promise promise) {
71
+ if (this.location != null) {
72
+ promise.resolve(this.location.copy());
73
+ } else {
74
+ promise.resolve((Object) null);
75
+ }
76
+
67
77
  }
68
78
 
69
- private void sendEvent(ReactContext reactContext,
70
- String eventName,
71
- @Nullable WritableMap params) {
72
- reactContext
79
+ private void sendEvent(@Nullable WritableMap params) {
80
+ getReactApplicationContext()
73
81
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
74
- .emit(eventName, params);
82
+ .emit(ON_LOCATION_CHANGED, params);
75
83
  }
76
- }
84
+ }
@@ -3,6 +3,7 @@ package com.steerpath.rnsmartmap;
3
3
  import android.util.Log;
4
4
 
5
5
  import com.facebook.react.bridge.Callback;
6
+ import com.facebook.react.bridge.Promise;
6
7
  import com.facebook.react.bridge.ReactApplicationContext;
7
8
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
9
  import com.facebook.react.bridge.ReactMethod;
@@ -58,23 +59,7 @@ public class RNSmartMapManager extends ReactContextBaseJavaModule {
58
59
  // TODO: throw error
59
60
  }
60
61
  }
61
-
62
- @Deprecated
63
- @ReactMethod
64
- public void setLiveConfig(ReadableMap map) {
65
- if (map == null) {
66
- // Logout and stop LiveService
67
- appContext.runOnUiQueueThread(() -> SmartSDK.getInstance().setLiveConfiguration(appContext, null));
68
- } else {
69
- try {
70
- JSONObject object = Utils.convertMapToJson(map);
71
- appContext.runOnUiQueueThread(() -> SmartSDK.getInstance().setLiveConfiguration(appContext, object));
72
- } catch (JSONException e) {
73
- Log.e("Error", "Failed to set live configuration for SmartSDK");
74
- }
75
- }
76
- }
77
-
62
+
78
63
  @ReactMethod
79
64
  public void loginToLive(ReadableMap map) {
80
65
  if (map != null) {
@@ -86,27 +71,20 @@ public class RNSmartMapManager extends ReactContextBaseJavaModule {
86
71
  }
87
72
  }
88
73
  }
89
-
74
+
90
75
  @ReactMethod
91
- public void logoutFromLive(){
76
+ public void logoutFromLive() {
92
77
  appContext.runOnUiQueueThread(() -> SmartSDK.getInstance().logoutFromLive(appContext));
93
78
  }
94
-
95
79
 
96
80
  @ReactMethod
97
- public void fetchVersions(Callback callback) {
98
- WritableMap map = new WritableNativeMap();
81
+ public void fetchVersion(Promise promise) {
99
82
  JSONObject versions = SmartSDK.getVersions();
100
83
  try {
101
- map = Utils.convertJsonToWritableMap(versions);
84
+ String version = versions.getString("smartSDKVersion");
85
+ promise.resolve(version);
102
86
  } catch (JSONException e) {
103
- e.printStackTrace();
87
+ promise.reject("ERROR", "failed to fetch Smart SDK version");
104
88
  }
105
- callback.invoke(map);
106
- }
107
-
108
- @ReactMethod
109
- public void setLanguage(String languageCode) {
110
- appContext.runOnUiQueueThread(() -> SmartSDK.getInstance().setLanguage(languageCode));
111
89
  }
112
- }
90
+ }
@@ -2,6 +2,9 @@ package com.steerpath.rnsmartmap;
2
2
 
3
3
  import android.app.Activity;
4
4
 
5
+ import androidx.annotation.NonNull;
6
+ import androidx.annotation.Nullable;
7
+
5
8
  import com.facebook.react.ReactPackage;
6
9
  import com.facebook.react.bridge.NativeModule;
7
10
  import com.facebook.react.bridge.ReactApplicationContext;
@@ -9,6 +12,7 @@ import com.facebook.react.uimanager.ViewManager;
9
12
 
10
13
  import java.util.ArrayList;
11
14
  import java.util.Arrays;
15
+ import java.util.Collections;
12
16
  import java.util.List;
13
17
 
14
18
  public class RNSmartMapPackage implements ReactPackage {
@@ -17,12 +21,6 @@ public class RNSmartMapPackage implements ReactPackage {
17
21
 
18
22
  public RNSmartMapPackage() {}
19
23
 
20
- @Override
21
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
22
- return Arrays.<ViewManager>asList(
23
- new RNSmartMapViewManager(reactContext)
24
- );
25
- }
26
24
 
27
25
  @Override
28
26
  public List<NativeModule> createNativeModules(
@@ -30,9 +28,13 @@ public class RNSmartMapPackage implements ReactPackage {
30
28
  List<NativeModule> modules = new ArrayList<>();
31
29
 
32
30
  modules.add(new RNSmartMapManager(reactContext));
33
- modules.add(new RNSmartGeofenceManager(reactContext));
34
- modules.add(new RNSmartMapModule(reactContext));
35
31
  modules.add(new RNSmartLocationManager(reactContext));
36
32
  return modules;
37
33
  }
38
- }
34
+
35
+ @NonNull
36
+ @Override
37
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactApplicationContext) {
38
+ return Collections.emptyList();
39
+ }
40
+ }
@@ -66,24 +66,24 @@ public class Utils {
66
66
  while (iterator.hasNextKey()) {
67
67
  String key = iterator.nextKey();
68
68
  switch (readableMap.getType(key)) {
69
- case Null:
70
- object.put(key, JSONObject.NULL);
71
- break;
72
- case Boolean:
73
- object.put(key, readableMap.getBoolean(key));
74
- break;
75
- case Number:
76
- object.put(key, readableMap.getDouble(key));
77
- break;
78
- case String:
79
- object.put(key, readableMap.getString(key));
80
- break;
81
- case Map:
82
- object.put(key, convertMapToJson(readableMap.getMap(key)));
83
- break;
84
- case Array:
85
- object.put(key, convertArrayToJson(readableMap.getArray(key)));
86
- break;
69
+ case Null:
70
+ object.put(key, JSONObject.NULL);
71
+ break;
72
+ case Boolean:
73
+ object.put(key, readableMap.getBoolean(key));
74
+ break;
75
+ case Number:
76
+ object.put(key, readableMap.getDouble(key));
77
+ break;
78
+ case String:
79
+ object.put(key, readableMap.getString(key));
80
+ break;
81
+ case Map:
82
+ object.put(key, convertMapToJson(readableMap.getMap(key)));
83
+ break;
84
+ case Array:
85
+ object.put(key, convertArrayToJson(readableMap.getArray(key)));
86
+ break;
87
87
  }
88
88
  }
89
89
  return object;
@@ -93,25 +93,25 @@ public class Utils {
93
93
  JSONArray array = new JSONArray();
94
94
  for (int i = 0; i < readableArray.size(); i++) {
95
95
  switch (readableArray.getType(i)) {
96
- case Null:
97
- break;
98
- case Boolean:
99
- array.put(readableArray.getBoolean(i));
100
- break;
101
- case Number:
102
- array.put(readableArray.getDouble(i));
103
- break;
104
- case String:
105
- array.put(readableArray.getString(i));
106
- break;
107
- case Map:
108
- array.put(convertMapToJson(readableArray.getMap(i)));
109
- break;
110
- case Array:
111
- array.put(convertArrayToJson(readableArray.getArray(i)));
112
- break;
96
+ case Null:
97
+ break;
98
+ case Boolean:
99
+ array.put(readableArray.getBoolean(i));
100
+ break;
101
+ case Number:
102
+ array.put(readableArray.getDouble(i));
103
+ break;
104
+ case String:
105
+ array.put(readableArray.getString(i));
106
+ break;
107
+ case Map:
108
+ array.put(convertMapToJson(readableArray.getMap(i)));
109
+ break;
110
+ case Array:
111
+ array.put(convertArrayToJson(readableArray.getArray(i)));
112
+ break;
113
113
  }
114
114
  }
115
115
  return array;
116
116
  }
117
- }
117
+ }
@@ -10,6 +10,7 @@
10
10
 
11
11
  @implementation RNSmartLocationManager {
12
12
  bool hasListeners;
13
+ NSDictionary *lastLocation;
13
14
  }
14
15
 
15
16
  RCT_EXPORT_MODULE(RNSmartLocationManager);
@@ -19,6 +20,16 @@ RCT_EXPORT_MODULE(RNSmartLocationManager);
19
20
  return @[@"locationChanged"];
20
21
  }
21
22
 
23
+ RCT_EXPORT_METHOD(getLocation:(RCTPromiseResolveBlock)resolve
24
+ rejecter:(RCTPromiseRejectBlock)reject)
25
+ {
26
+ if (lastLocation != nil) {
27
+ resolve(lastLocation);
28
+ } else {
29
+ resolve([NSNull null]);
30
+ }
31
+ }
32
+
22
33
  // Start listening location updates. Starts positioning unless map has started it already.
23
34
  -(void)startObserving {
24
35
  hasListeners = YES;
@@ -35,9 +46,23 @@ RCT_EXPORT_MODULE(RNSmartLocationManager);
35
46
  }
36
47
 
37
48
  -(void)spSmartLocationManager:(SPSmartLocationManager *)manager onLocationChanged:(double)latitude longitude:(double)longitude buildingRef:(nullable NSString *)buildingRef floorIndex:(NSInteger)floorIndex accuracyM:(double)accuracyM{
38
- if (hasListeners) {
39
- [self sendEventWithName:@"locationChanged" body:@{@"latitude": [NSNumber numberWithDouble:latitude], @"longitude": [NSNumber numberWithDouble:longitude], @"buildingRef": buildingRef ?: [NSNull null], @"floorIndex": [NSNumber numberWithInteger:floorIndex], @"accuracyM": [NSNumber numberWithDouble:accuracyM]}];
40
- }
49
+
50
+ NSDictionary *locationBody = @{
51
+ @"latitude": [NSNumber numberWithDouble:latitude],
52
+ @"longitude": [NSNumber numberWithDouble:longitude],
53
+ @"buildingRef": buildingRef ?: [NSNull null],
54
+ @"floorIndex": [NSNumber numberWithInteger:floorIndex],
55
+ @"accuracyM": [NSNumber numberWithDouble:accuracyM]
56
+ };
57
+
58
+ lastLocation = locationBody;
59
+
60
+ // Using hack on JS side to get the location instead of sending event.
61
+ // Sending events through the bridge doesnt work, so using this workaround until moving to new arch
62
+ // if (hasListeners) {
63
+ // [self sendEventWithName:@"locationChanged" body:locationBody];
64
+ // }
65
+
41
66
  }
42
67
 
43
68
  @end
@@ -7,7 +7,6 @@
7
7
  //
8
8
 
9
9
  #import "RNSmartMapManager.h"
10
- #import <Mapbox/Mapbox.h>
11
10
 
12
11
  @implementation RNSmartMapManager
13
12
 
@@ -30,15 +29,6 @@ RCT_EXPORT_METHOD(startWithConfig:(nonnull NSDictionary *)config)
30
29
  [[SPSmartSDK getInstance] start:apiKey config:configFilePath];
31
30
  }
32
31
 
33
- RCT_EXPORT_METHOD(setLiveConfig:(NSDictionary *)config)
34
- {
35
- // TODO: call setLiveConfiguration in the native iOS Smart SDK on main thead instead of here
36
- dispatch_async(dispatch_get_main_queue(), ^{
37
- [[SPSmartSDK getInstance] setLiveConfiguration: config];
38
- });
39
-
40
- }
41
-
42
32
  RCT_EXPORT_METHOD(loginToLive:(NSDictionary *)config)
43
33
  {
44
34
  // TODO: call loginToLive in the native iOS Smart SDK on main thead instead of here
@@ -56,21 +46,19 @@ RCT_EXPORT_METHOD(logoutFromLive)
56
46
 
57
47
  }
58
48
 
59
- RCT_EXPORT_METHOD(fetchVersions:(RCTResponseSenderBlock)callback)
49
+ RCT_EXPORT_METHOD(fetchVersion:(RCTPromiseResolveBlock)resolve
50
+ rejecter:(RCTPromiseRejectBlock)reject)
60
51
  {
61
52
  NSDictionary *infoDictionary = [[NSBundle bundleForClass: [SPSmartSDK class]] infoDictionary];
62
53
  NSString *smartSDKVersion = [infoDictionary valueForKey:@"CFBundleShortVersionString"];
63
- NSDictionary *mapboxInfoDictionary = [[NSBundle bundleForClass: [MGLMapView class]] infoDictionary];
64
- NSString *mapboxVersion = [mapboxInfoDictionary valueForKey:@"CFBundleShortVersionString"];
65
- callback(@[@{
66
- @"smartSDKVersion": smartSDKVersion,
67
- @"mapboxSDKVersion": mapboxVersion
68
- }]);
69
- }
70
-
71
- RCT_EXPORT_METHOD(setLanguage:(nonnull NSString *)languageCode)
72
- {
73
- [[SPSmartSDK getInstance] setLanguage: languageCode];
54
+
55
+ if (smartSDKVersion != nil) {
56
+ resolve(smartSDKVersion);
57
+ } else {
58
+ reject(@"ERROR",
59
+ @"The SmartSDK version could not be found in the info dictionary.",
60
+ nil);
61
+ }
74
62
  }
75
63
 
76
64
  @end