@situm/cordova 3.14.14 → 3.15.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.
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "..": {
70
70
  "name": "@situm/cordova",
71
- "version": "3.6.11",
71
+ "version": "3.14.12",
72
72
  "engines": [
73
73
  {
74
74
  "name": "cordova-android",
@@ -24,7 +24,6 @@ import { NgFor, NgIf } from '@angular/common';
24
24
  import { locate, cloudDownload, map } from 'ionicons/icons';
25
25
  import { addIcons } from 'ionicons';
26
26
 
27
- import { requestPermissions } from '../utils/request.permissions';
28
27
  import * as Constants from '../../constants';
29
28
 
30
29
  // Declare a cordova variable to avoid typescript errors
@@ -81,6 +80,10 @@ export class SDKPage {
81
80
  // See all the parameters you can modify in https://dashboard.situm.com/settings.
82
81
  cordova.plugins.Situm.setUseRemoteConfig(true);
83
82
 
83
+ // Tell the native SDK to automatically request permissions and manage
84
+ // sensor (BLE/Location) issues.
85
+ cordova.plugins.Situm.enableUserHelper();
86
+
84
87
  // Wait until receive the MapViewController of our map and
85
88
  // be able to send actions and receive events that occur inside it.
86
89
  cordova.plugins.MapView.onLoad((controller: any) => {
@@ -114,22 +117,7 @@ export class SDKPage {
114
117
  return;
115
118
  }
116
119
  this._setInfo('');
117
- // You might want to know how we ask the all the permissions,
118
- // so take a look at /src/app/utils/request.permission.ts
119
- requestPermissions(
120
- () => {
121
- this.doStartPositioning();
122
- },
123
- (errorMessage: any) => {
124
- this._setInfo(
125
- 'Something did happen while asking for permission: ' + errorMessage
126
- );
127
- },
128
- this.platform
129
- );
130
- }
131
120
 
132
- private doStartPositioning() {
133
121
  cordova.plugins.Situm.onLocationUpdate((location: any) => {
134
122
  this._setStatus('POSITIONING');
135
123
  this._setInfo(location);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@situm/cordova",
3
- "version": "3.14.14",
3
+ "version": "3.15.1",
4
4
  "description": "Situm Wayfinding for Capacitor and Cordova. Integrate plug&play indoor navigation experience with floorplans, POIs, routes and turn-by-turn directions in no time. With the power of Situm.",
5
5
  "private": false,
6
6
  "repository": "https://github.com/situmtech/cordova",
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  id="@situm/cordova"
5
- version="3.14.14">
5
+ version="3.15.1">
6
6
  <name>Situm Cordova plugin Official</name>
7
7
  <description>This is the stable branch.</description>
8
8
  <license>MIT</license>
@@ -93,7 +93,7 @@
93
93
  <config>
94
94
  </config>
95
95
  <pods use-frameworks="false">
96
- <pod name="SitumSDK" spec="~> 3.28.1"/>
96
+ <pod name="SitumSDK" spec="~> 3.29.0"/>
97
97
  </pods>
98
98
  </podspec>
99
99
 
@@ -47,6 +47,7 @@ import es.situm.sdk.realtime.RealTimeListener;
47
47
  import es.situm.sdk.realtime.RealTimeManager;
48
48
  import es.situm.sdk.realtime.RealTimeRequest;
49
49
  import es.situm.sdk.utils.Handler;
50
+ import es.situm.sdk.userhelper.UserHelperColorScheme;
50
51
  import es.situm.sdk.v1.SitumEvent;
51
52
 
52
53
  public class PluginHelper {
@@ -546,16 +547,6 @@ public class PluginHelper {
546
547
  PluginResult result = new PluginResult(Status.ERROR, error.getMessage());
547
548
  result.setKeepCallback(true);
548
549
  callbackContext.sendPluginResult(result);
549
- switch (error.getCode()) {
550
- case 8001:
551
- requestLocationPermission(cordova);
552
- return;
553
- case 8002:
554
- showLocationSettings(cordova);
555
- return;
556
- default:
557
- return;
558
- }
559
550
  }
560
551
  };
561
552
  try {
@@ -631,16 +622,6 @@ public class PluginHelper {
631
622
  callbackContext.sendPluginResult(pluginResult);
632
623
  }
633
624
 
634
- private void showLocationSettings(CordovaInterface cordova) {
635
- Toast.makeText(cordova.getActivity(), "You must enable location", Toast.LENGTH_LONG).show();
636
- cordova.getActivity().startActivityForResult(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"), 0);
637
- }
638
-
639
- private void requestLocationPermission(CordovaInterface cordova) {
640
- ActivityCompat.requestPermissions(cordova.getActivity(),
641
- new String[] { "android.permission.ACCESS_FINE_LOCATION" }, 0);
642
- }
643
-
644
625
  public void returnDefaultResponse(CallbackContext callbackContext) {
645
626
  String message = "Error function name not found";
646
627
  Log.e(TAG, message);
@@ -899,6 +880,34 @@ public class PluginHelper {
899
880
  getRealtimeManagerInstance().removeRealTimeUpdates(); // TODO: Incorporate sending a result to the exterior
900
881
  }
901
882
 
883
+ public void configureUserHelper(
884
+ CordovaInterface cordova,
885
+ CordovaWebView webView,
886
+ JSONArray args,
887
+ final CallbackContext callbackContext
888
+ ) {
889
+ try {
890
+ JSONObject jsonUserHelperOptions = args.getJSONObject(0);
891
+ boolean enabled = false;
892
+ if (jsonUserHelperOptions.has("enabled")) {
893
+ enabled = jsonUserHelperOptions.getBoolean("enabled");
894
+ }
895
+ if (jsonUserHelperOptions.has("colorScheme")) {
896
+ JSONObject jsonColorScheme = jsonUserHelperOptions.getJSONObject("colorScheme");
897
+ UserHelperColorScheme colorScheme = SitumMapper.jsonObjectToUserHelperColorScheme(jsonColorScheme);
898
+ SitumSdk.userHelperManager().setColorScheme(colorScheme);
899
+ }
900
+ SitumSdk.userHelperManager().autoManage(enabled);
901
+
902
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, "User helper configured"));
903
+ } catch (Exception e) {
904
+ Log.d(TAG, "exception: " + e);
905
+
906
+ e.printStackTrace();
907
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
908
+ }
909
+ }
910
+
902
911
  // Initialize Navigation Component
903
912
 
904
913
  public void updateNavigationWithLocation(CordovaInterface cordova,
@@ -58,6 +58,7 @@ import es.situm.sdk.v1.SitumConversionArea;
58
58
  import es.situm.sdk.v1.SitumEvent;
59
59
  import es.situm.sdk.realtime.RealTimeRequest;
60
60
  import es.situm.sdk.model.realtime.RealTimeData;
61
+ import es.situm.sdk.userhelper.UserHelperColorScheme;
61
62
 
62
63
 
63
64
  class SitumMapper {
@@ -980,4 +981,24 @@ static JSONObject buildingInfoToJsonObject(BuildingInfo buildingInfo) throws JSO
980
981
  }
981
982
  return new DirectionsRequest.Builder().from(from, Angle.fromDegrees(startingAngle)).to(to).accessibilityMode(accessibilityMode).minimizeFloorChanges(minimizeFloorChanges).includedTags(includedTags).excludedTags(excludedTags).build();
982
983
  }
984
+
985
+ static UserHelperColorScheme jsonObjectToUserHelperColorScheme(JSONObject args) throws JSONException {
986
+ UserHelperColorScheme.Builder builder = new UserHelperColorScheme.Builder();
987
+
988
+ if (args.has("primaryColor")) {
989
+ String primaryColor = args.getString("primaryColor");
990
+ if (primaryColor != null) {
991
+ builder.setPrimaryColor(primaryColor);
992
+ }
993
+ }
994
+
995
+ if (args.has("secondaryColor")) {
996
+ String secondaryColor = args.getString("secondaryColor");
997
+ if (secondaryColor != null) {
998
+ builder.setSecondaryColor(secondaryColor);
999
+ }
1000
+ }
1001
+
1002
+ return builder.build();
1003
+ }
983
1004
  }
@@ -92,18 +92,20 @@ public class SitumPlugin extends CordovaPlugin {
92
92
  getPluginInstance().invalidateCache(callbackContext);
93
93
  } else if (action.equalsIgnoreCase("requestDirections")) {
94
94
  getPluginInstance().requestDirections(cordova, webView, args, callbackContext);
95
- } else if(action.equalsIgnoreCase("requestNavigationUpdates")) {
95
+ } else if(action.equalsIgnoreCase("requestNavigationUpdates")) {
96
96
  getPluginInstance().requestNavigationUpdates(cordova, webView, args, callbackContext);
97
- } else if(action.equalsIgnoreCase("updateNavigationWithLocation")) {
97
+ } else if(action.equalsIgnoreCase("updateNavigationWithLocation")) {
98
98
  getPluginInstance().updateNavigationWithLocation(cordova, webView, args, callbackContext);
99
- } else if(action.equalsIgnoreCase("removeNavigationUpdates")) {
99
+ } else if(action.equalsIgnoreCase("removeNavigationUpdates")) {
100
100
  getPluginInstance().removeNavigationUpdates(cordova, webView, args, callbackContext);
101
- } else if(action.equalsIgnoreCase("requestRealTimeUpdates")) {
101
+ } else if(action.equalsIgnoreCase("requestRealTimeUpdates")) {
102
102
  getPluginInstance().requestRealTimeUpdates(cordova, webView, args, callbackContext);
103
- } else if(action.equalsIgnoreCase("removeRealTimeUpdates")) {
103
+ } else if(action.equalsIgnoreCase("removeRealTimeUpdates")) {
104
104
  getPluginInstance().removeRealTimeUpdates(cordova, webView, args, callbackContext);
105
- } else if(action.equalsIgnoreCase("updateNavigationState")) {
105
+ } else if(action.equalsIgnoreCase("updateNavigationState")) {
106
106
  getPluginInstance().updateNavigationState(cordova, webView, args, callbackContext);
107
+ } else if(action.equalsIgnoreCase("configureUserHelper")) {
108
+ getPluginInstance().configureUserHelper(cordova, webView, args, callbackContext);
107
109
  } else {
108
110
  getPluginInstance().returnDefaultResponse(callbackContext);
109
111
  }
package/src/ios/Podfile CHANGED
@@ -1,5 +1,5 @@
1
1
  target 'SitumCordovaPlugin' do
2
2
  use_frameworks!
3
3
  platform :ios, '9.0'
4
- pod 'SitumSDK', '3.28.1'
4
+ pod 'SitumSDK', '3.29.0'
5
5
  end
@@ -782,4 +782,38 @@ destinationReachedOnRoute:(SITRoute *)route {
782
782
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
783
783
  }
784
784
 
785
+ - (void)configureUserHelper:(CDVInvokedUrlCommand *)command {
786
+ NSDictionary *options = [command.arguments objectAtIndex:0];
787
+ BOOL enabled = NO;
788
+
789
+ if ([options objectForKey:@"enabled"]) {
790
+ enabled = [[options objectForKey:@"enabled"] boolValue];
791
+ }
792
+
793
+ [[SITUserHelperManager sharedInstance] autoManage:enabled];
794
+
795
+ if ([options objectForKey:@"colorScheme"]) {
796
+ id colorSchemeValue = [options objectForKey:@"colorScheme"];
797
+ if ([colorSchemeValue isKindOfClass:[NSDictionary class]]) {
798
+ NSDictionary *colorScheme = [options objectForKey:@"colorScheme"];
799
+ NSString *primaryColor = [colorScheme objectForKey:@"primaryColor"];
800
+ NSString *secondaryColor = [colorScheme objectForKey:@"secondaryColor"];
801
+
802
+ SITUserHelperColorScheme *helperColorScheme = [[SITUserHelperColorScheme alloc] init];
803
+ if (primaryColor) {
804
+ helperColorScheme.primaryColor = primaryColor;
805
+ }
806
+ if (secondaryColor) {
807
+ helperColorScheme.secondaryColor = secondaryColor;
808
+ }
809
+
810
+ [[SITUserHelperManager sharedInstance] setColorScheme:helperColorScheme];
811
+ }
812
+ }
813
+
814
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"User helper configured"];
815
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
816
+ }
817
+
818
+
785
819
  @end
package/www/Interfaces.js CHANGED
@@ -817,3 +817,35 @@ var PoiDeselectedResult = {
817
817
  };
818
818
 
819
819
  module.exports = PoiDeselectedResult;
820
+
821
+ /**
822
+ * @name
823
+ * UserHelperColorScheme
824
+ * @description
825
+ * Color scheme for the user helper UI.
826
+ * @property {string} primaryColor - Primary color for the user helper UI. Use HEX color code (e.g. "#ff5733").
827
+ * @property {string} secondaryColor - Secondary color for the user helper UI. Use HEX color code (e.g. "#ff5733").
828
+ */
829
+
830
+ var UserHelperColorScheme = {
831
+ primaryColor,
832
+ secondaryColor
833
+ };
834
+
835
+ module.exports = UserHelperColorScheme;
836
+
837
+ /**
838
+ * @name
839
+ * UserHelperOptions
840
+ * @description
841
+ * Configuration options for the user helper.
842
+ * @property {boolean} enabled - Whether the user helper is enabled. Equivalent to the underlying native SitumSdk.userHelperManager#autoManage(true).
843
+ * @property {UserHelperColorScheme} colorScheme - Color scheme for the user helper UI.
844
+ */
845
+
846
+ var UserHelperOptions = {
847
+ enabled,
848
+ colorScheme
849
+ };
850
+
851
+ module.exports = UserHelperOptions;
package/www/situm.js CHANGED
@@ -449,6 +449,52 @@ var Situm = {
449
449
  */
450
450
  removeRealTimeUpdates: function (cb, error) {
451
451
  exec(cb, error, PLUGIN_NAME, 'removeRealTimeUpdates', []);
452
+ },
453
+ /**
454
+ * Automatically assists users in resolving app-related permission and sensor issues.
455
+ *
456
+ * This method tells the native SDKs to present a user interface that explains detected
457
+ * configuration issues and guides users through the required steps to resolve them,
458
+ * following best practices for runtime permission requests.
459
+ *
460
+ * Issues addressed include:
461
+ * - Missing permissions for Location or Bluetooth.
462
+ * - Disabled Location or Bluetooth sensors.
463
+ *
464
+ * Use the <code>userHelperOptions</code> parameter to configure the available options.
465
+ * Call {@link enableUserHelper} as a shortcut to enable the user helper with default configuration.
466
+ * Call {@link disableUserHelper} as a shortcut to disable the user helper.
467
+ *
468
+ * @param {UserHelperOptions} userHelperOptions - Options for the user helper.
469
+ * @param {function} cb - Cordova native callback to receive data.
470
+ * @param {function} error - Cordova native callback to receive errors.
471
+ */
472
+ configureUserHelper: function (userHelperOptions, cb, error) {
473
+ exec(cb, error, PLUGIN_NAME, 'configureUserHelper', [userHelperOptions]);
474
+ },
475
+
476
+ /**
477
+ * Enables the user helper.
478
+ *
479
+ * Shortcut for {@link configureUserHelper} with <code>{enabled: true}</code>.
480
+ *
481
+ * @param {function} cb - Cordova native callback to receive data.
482
+ * @param {function} error - Cordova native callback to receive errors.
483
+ */
484
+ enableUserHelper: function (cb, error) {
485
+ this.configureUserHelper({enabled: true}, cb, error);
486
+ },
487
+
488
+ /**
489
+ * Disables the user helper.
490
+ *
491
+ * Shortcut for {@link configureUserHelper} with <code>{enabled: false}</code>.
492
+ *
493
+ * @param {function} cb - Cordova native callback to receive data.
494
+ * @param {function} error - Cordova native callback to receive errors.
495
+ */
496
+ disableUserHelper: function (cb, error) {
497
+ this.configureUserHelper({enabled: false}, cb, error);
452
498
  }
453
499
  };
454
500
  module.exports = Situm;
@@ -1,68 +0,0 @@
1
- import { Platform } from '@ionic/angular/standalone';
2
-
3
- declare let cordova: any;
4
-
5
- export function requestPermissions(
6
- successCb: Function,
7
- errorCb: Function,
8
- platform: Platform
9
- ) {
10
- if (platform.is('android')) {
11
- cordova.plugins.diagnostic.requestRuntimePermissions(
12
- function (permissions: Map<string, string>) {
13
- console.log('EXAMPLE> permissions statuses: ', permissions);
14
- successCb();
15
- },
16
- function (error: any) {
17
- errorCb(JSON.stringify(error));
18
- },
19
- [
20
- // Android
21
- // We ask this permission to obtain the GPS data of the user and paint it on our map.
22
- cordova.plugins.diagnostic.permission.ACCESS_FINE_LOCATION,
23
- // We ask this last 2 permissions to improve the accuracy of our SDK when locating the user.
24
- cordova.plugins.diagnostic.permission.BLUETOOTH_CONNECT,
25
- cordova.plugins.diagnostic.permission.BLUETOOTH_SCAN,
26
- ]
27
- );
28
- } else if (platform.is('ios')) {
29
- cordova.plugins.diagnostic.getLocationAuthorizationStatus(
30
- (status: string) => {
31
- if (status == 'authorized') {
32
- successCb();
33
- return;
34
- }
35
- },
36
- () => {
37
- // Do nothing
38
- }
39
- );
40
-
41
- // iOS
42
- // We just need to ask for the location permission.
43
- cordova.plugins.diagnostic.requestLocationAuthorization(
44
- function (status: string) {
45
- switch (status) {
46
- case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
47
- errorCb('Permission not requested');
48
- break;
49
- case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
50
- errorCb('Permission denied');
51
- break;
52
- case cordova.plugins.diagnostic.permissionStatus.GRANTED:
53
- console.log('Permission granted always');
54
- successCb();
55
- break;
56
- case cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE:
57
- console.log('Permission granted only when in use');
58
- successCb();
59
- break;
60
- }
61
- },
62
- function (error: any) {
63
- errorCb(JSON.stringify(error));
64
- },
65
- cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS
66
- );
67
- }
68
- }