@situm/cordova 3.0.0
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.
- package/CHANGELOG.md +3 -0
- package/CHANGELOG_UNRELEASED.md +28 -0
- package/Jenkinsfile +84 -0
- package/LICENSE +21 -0
- package/README.md +472 -0
- package/azure/common-steps.yaml +5 -0
- package/azure-pipelines.yml +336 -0
- package/docs/JSDoc/MapView.html +300 -0
- package/docs/JSDoc/MapViewControllerImpl.html +299 -0
- package/docs/JSDoc/Situm.html +5257 -0
- package/docs/JSDoc/android_Interfaces.js.html +825 -0
- package/docs/JSDoc/android_situm.js.html +380 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.eot +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.svg +288 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/docs/JSDoc/global.html +7538 -0
- package/docs/JSDoc/img/toast-ui.png +0 -0
- package/docs/JSDoc/index.html +90 -0
- package/docs/JSDoc/map-view-controller.js.html +307 -0
- package/docs/JSDoc/map-view.js.html +172 -0
- package/docs/JSDoc/scripts/jquery.min.js +2 -0
- package/docs/JSDoc/scripts/linenumber.js +30 -0
- package/docs/JSDoc/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/JSDoc/scripts/prettify/lang-css.js +2 -0
- package/docs/JSDoc/scripts/prettify/prettify.js +28 -0
- package/docs/JSDoc/scripts/tui-doc.js +200 -0
- package/docs/JSDoc/styles/bootstrap.min.css +6 -0
- package/docs/JSDoc/styles/custom.css +23 -0
- package/docs/JSDoc/styles/prettify-jsdoc.css +111 -0
- package/docs/JSDoc/styles/prettify-tomorrow.css +132 -0
- package/docs/JSDoc/styles/tui-doc.css +485 -0
- package/docs/conf.json +28 -0
- package/docs/getting-started.md +298 -0
- package/docs/imagotype-SITUM-transparent-90.png +0 -0
- package/docs/static/styles/custom.css +23 -0
- package/package.json +60 -0
- package/plugin.xml +102 -0
- package/scripts/update_changelog.sh +22 -0
- package/src/android/app/build.gradle +51 -0
- package/src/android/app/proguard-rules.pro +21 -0
- package/src/android/app/src/main/AndroidManifest.xml +11 -0
- package/src/android/app/src/main/java/es/situm/plugin/DateUtils.java +15 -0
- package/src/android/app/src/main/java/es/situm/plugin/PluginHelper.java +919 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumMapper.java +968 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java +109 -0
- package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/values/colors.xml +6 -0
- package/src/android/app/src/main/res/values/strings.xml +3 -0
- package/src/android/app/src/main/res/values/styles.xml +11 -0
- package/src/android/app/src/test/java/es/situm/plugin/PluginHelperTest.java +27 -0
- package/src/android/app/src/test/java/es/situm/plugin/SitumMapperTest.java +1485 -0
- package/src/android/app/src/test/java/es/situm/plugin/angle/AngleCreator.java +46 -0
- package/src/android/app/src/test/java/es/situm/plugin/bounds/BoundsCreator.java +50 -0
- package/src/android/app/src/test/java/es/situm/plugin/building/BuildingCreator.java +76 -0
- package/src/android/app/src/test/java/es/situm/plugin/cartesianCoordinate/CartesianCoordinateCreator.java +31 -0
- package/src/android/app/src/test/java/es/situm/plugin/circle/CircleCreator.java +41 -0
- package/src/android/app/src/test/java/es/situm/plugin/coordinate/CoordinateCreator.java +32 -0
- package/src/android/app/src/test/java/es/situm/plugin/dimensions/DimensionsCreator.java +31 -0
- package/src/android/app/src/test/java/es/situm/plugin/directionsRequest/DirectionsRequestCreator.java +105 -0
- package/src/android/app/src/test/java/es/situm/plugin/event/EventCreator.java +108 -0
- package/src/android/app/src/test/java/es/situm/plugin/floor/FloorCreator.java +58 -0
- package/src/android/app/src/test/java/es/situm/plugin/indication/IndicationCreator.java +40 -0
- package/src/android/app/src/test/java/es/situm/plugin/location/LocationCreator.java +197 -0
- package/src/android/app/src/test/java/es/situm/plugin/locationRequest/LocationRequestCreator.java +45 -0
- package/src/android/app/src/test/java/es/situm/plugin/locationStatus/LocationStatusCreator.java +211 -0
- package/src/android/app/src/test/java/es/situm/plugin/navigationProgress/NavigationProgressCreator.java +154 -0
- package/src/android/app/src/test/java/es/situm/plugin/poi/PoiCreator.java +126 -0
- package/src/android/app/src/test/java/es/situm/plugin/poiCategory/PoiCategoryCreator.java +38 -0
- package/src/android/app/src/test/java/es/situm/plugin/point/PointCreator.java +200 -0
- package/src/android/app/src/test/java/es/situm/plugin/route/RouteCreator.java +142 -0
- package/src/android/app/src/test/java/es/situm/plugin/routeStep/RouteStepCreator.java +173 -0
- package/src/android/app/src/test/java/es/situm/plugin/situmConversionArea/SitumConversionAreaCreator.java +35 -0
- package/src/android/build.gradle +31 -0
- package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/android/gradle.properties +16 -0
- package/src/android/gradlew +172 -0
- package/src/android/gradlew.bat +84 -0
- package/src/android/settings.gradle +3 -0
- package/src/android/situm.gradle +19 -0
- package/src/ios/Classes/Private/CDVDebug.h +25 -0
- package/src/ios/Classes/Private/CDVJSON_private.h +31 -0
- package/src/ios/Classes/Private/CDVJSON_private.m +99 -0
- package/src/ios/Classes/Private/CDVPlugin+Private.h +24 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.h +26 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.m +70 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.h +27 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.m +86 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h +34 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m +153 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.h +50 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.m +487 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.h +26 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.m +37 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h +41 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m +399 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h +27 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m +202 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h +29 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m +153 -0
- package/src/ios/Classes/Public/CDV.h +32 -0
- package/src/ios/Classes/Public/CDVAppDelegate.h +28 -0
- package/src/ios/Classes/Public/CDVAppDelegate.m +118 -0
- package/src/ios/Classes/Public/CDVAvailability.h +111 -0
- package/src/ios/Classes/Public/CDVAvailabilityDeprecated.h +26 -0
- package/src/ios/Classes/Public/CDVCommandDelegate.h +51 -0
- package/src/ios/Classes/Public/CDVCommandDelegateImpl.h +36 -0
- package/src/ios/Classes/Public/CDVCommandDelegateImpl.m +186 -0
- package/src/ios/Classes/Public/CDVCommandQueue.h +39 -0
- package/src/ios/Classes/Public/CDVCommandQueue.m +194 -0
- package/src/ios/Classes/Public/CDVConfigParser.h +30 -0
- package/src/ios/Classes/Public/CDVConfigParser.m +81 -0
- package/src/ios/Classes/Public/CDVInvokedUrlCommand.h +52 -0
- package/src/ios/Classes/Public/CDVInvokedUrlCommand.m +116 -0
- package/src/ios/Classes/Public/CDVPlugin+Resources.h +39 -0
- package/src/ios/Classes/Public/CDVPlugin+Resources.m +38 -0
- package/src/ios/Classes/Public/CDVPlugin.h +85 -0
- package/src/ios/Classes/Public/CDVPlugin.m +202 -0
- package/src/ios/Classes/Public/CDVPluginResult.h +66 -0
- package/src/ios/Classes/Public/CDVPluginResult.m +186 -0
- package/src/ios/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
- package/src/ios/Classes/Public/CDVTimer.h +27 -0
- package/src/ios/Classes/Public/CDVTimer.m +123 -0
- package/src/ios/Classes/Public/CDVURLProtocol.h +27 -0
- package/src/ios/Classes/Public/CDVURLProtocol.m +113 -0
- package/src/ios/Classes/Public/CDVUserAgentUtil.h +27 -0
- package/src/ios/Classes/Public/CDVUserAgentUtil.m +124 -0
- package/src/ios/Classes/Public/CDVViewController.h +92 -0
- package/src/ios/Classes/Public/CDVViewController.m +821 -0
- package/src/ios/Classes/Public/CDVWebViewEngineProtocol.h +42 -0
- package/src/ios/Classes/Public/CDVWhitelist.h +34 -0
- package/src/ios/Classes/Public/CDVWhitelist.m +285 -0
- package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
- package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
- package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.h +29 -0
- package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.m +58 -0
- package/src/ios/Cordova/Cordova.h +51 -0
- package/src/ios/Cordova/Info.plist +24 -0
- package/src/ios/Podfile +5 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.pbxproj +1324 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/xcshareddata/xcschemes/CordovaLib.xcscheme +100 -0
- package/src/ios/SitumCordovaPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/src/ios/SitumCordovaPlugin_Prefix.pch +22 -0
- package/src/ios/VERSION +1 -0
- package/src/ios/cordova.js +2432 -0
- package/src/ios/situmcordovaplugin/AppDelegate.h +22 -0
- package/src/ios/situmcordovaplugin/AppDelegate.m +98 -0
- package/src/ios/situmcordovaplugin/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/src/ios/situmcordovaplugin/Base.lproj/LaunchScreen.storyboard +25 -0
- package/src/ios/situmcordovaplugin/Base.lproj/Main.storyboard +24 -0
- package/src/ios/situmcordovaplugin/Constants.h +14 -0
- package/src/ios/situmcordovaplugin/Constants.m +14 -0
- package/src/ios/situmcordovaplugin/Info.plist +45 -0
- package/src/ios/situmcordovaplugin/SITUtils.h +7 -0
- package/src/ios/situmcordovaplugin/SITUtils.m +13 -0
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.h +109 -0
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.m +983 -0
- package/src/ios/situmcordovaplugin/SitumPlugin.h +41 -0
- package/src/ios/situmcordovaplugin/SitumPlugin.m +752 -0
- package/src/ios/situmcordovaplugin/ViewController.h +15 -0
- package/src/ios/situmcordovaplugin/ViewController.m +29 -0
- package/src/ios/situmcordovaplugin/main.m +16 -0
- package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/.xccurrentversion +8 -0
- package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/situmcordovaplugin.xcdatamodel/contents +4 -0
- package/src/ios/situmcordovaplugintests/AngleTests.m +53 -0
- package/src/ios/situmcordovaplugintests/BoundTests.m +51 -0
- package/src/ios/situmcordovaplugintests/BuildingTests.m +41 -0
- package/src/ios/situmcordovaplugintests/CartesianCoordinateTests.m +42 -0
- package/src/ios/situmcordovaplugintests/ConversionAreaTests.m +43 -0
- package/src/ios/situmcordovaplugintests/CoordinateTests.m +42 -0
- package/src/ios/situmcordovaplugintests/DimensionTests.m +43 -0
- package/src/ios/situmcordovaplugintests/EventTests.m +42 -0
- package/src/ios/situmcordovaplugintests/FloorTests.m +52 -0
- package/src/ios/situmcordovaplugintests/Info.plist +38 -0
- package/src/ios/situmcordovaplugintests/InputTests/DirectionsRequestTest.m +108 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputCartesianCoordinateTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputCoordinateTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputFloorTests.m +59 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputIndicationTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputLocationTests.m +163 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputPoiCategoryTests.m +46 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputPointTests.m +137 -0
- package/src/ios/situmcordovaplugintests/InputTests/LocationRequestTest.m +79 -0
- package/src/ios/situmcordovaplugintests/LocationStatusTests.m +60 -0
- package/src/ios/situmcordovaplugintests/LocationTests.m +114 -0
- package/src/ios/situmcordovaplugintests/NavigationProgressTests.m +50 -0
- package/src/ios/situmcordovaplugintests/PoiCategoryIconTests.m +43 -0
- package/src/ios/situmcordovaplugintests/PoiCategoryTests.m +42 -0
- package/src/ios/situmcordovaplugintests/PoiTests.m +83 -0
- package/src/ios/situmcordovaplugintests/PointTests.m +107 -0
- package/src/ios/situmcordovaplugintests/RouteStepTests.m +78 -0
- package/src/ios/situmcordovaplugintests/RouteTests.m +42 -0
- package/src/ios/situmcordovaplugintests/SitumCreatorTests.h +91 -0
- package/src/ios/situmcordovaplugintests/SitumCreatorTests.m +928 -0
- package/src/ios/situmcordovaplugintests/TestingHelper.h +48 -0
- package/src/ios/situmcordovaplugintests/TestingHelper.m +342 -0
- package/src/ios/situmcordovaplugintests/indicationTests.m +43 -0
- package/tests/common-resources/angle/angle1.json +6 -0
- package/tests/common-resources/angle/angle2.json +6 -0
- package/tests/common-resources/bounds/bounds1.json +18 -0
- package/tests/common-resources/bounds/bounds2.json +18 -0
- package/tests/common-resources/building/building1.json +64 -0
- package/tests/common-resources/cartesianCoordinate/cartesianCoordinate1.json +4 -0
- package/tests/common-resources/circle/circle1.json +17 -0
- package/tests/common-resources/coordinate/coordinate1.json +4 -0
- package/tests/common-resources/dimensions/dimensions1.json +4 -0
- package/tests/common-resources/directionsRequest/directionsRequest1.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest2.json +167 -0
- package/tests/common-resources/directionsRequest/directionsRequest3.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest4.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest5.json +167 -0
- package/tests/common-resources/directionsRequest/directionsRequest6.json +153 -0
- package/tests/common-resources/events/event1.json +66 -0
- package/tests/common-resources/floor/floor1.json +13 -0
- package/tests/common-resources/floor/floor2.json +13 -0
- package/tests/common-resources/indication/indication1.json +10 -0
- package/tests/common-resources/location/location1.json +48 -0
- package/tests/common-resources/location/location10.json +48 -0
- package/tests/common-resources/location/location2.json +48 -0
- package/tests/common-resources/location/location3.json +48 -0
- package/tests/common-resources/location/location4.json +48 -0
- package/tests/common-resources/location/location5.json +48 -0
- package/tests/common-resources/location/location6.json +48 -0
- package/tests/common-resources/location/location7.json +48 -0
- package/tests/common-resources/location/location8.json +48 -0
- package/tests/common-resources/location/location9.json +48 -0
- package/tests/common-resources/locationRequest/locationRequest1.json +6 -0
- package/tests/common-resources/locationRequest/locationRequest2.json +32 -0
- package/tests/common-resources/locationRequest/locationRequest3.json +33 -0
- package/tests/common-resources/locationRequest/locationRequest4.json +31 -0
- package/tests/common-resources/locationStatus/locationStatus1.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus10.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus11.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus12.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus13.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus2.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus3.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus4.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus5.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus6.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus7.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus8.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus9.json +4 -0
- package/tests/common-resources/navigationProgress/navigationProgress1.json +77 -0
- package/tests/common-resources/navigationProgress/navigationProgress2.json +77 -0
- package/tests/common-resources/poi/poi1.json +35 -0
- package/tests/common-resources/poi/poi2.json +35 -0
- package/tests/common-resources/poi/poi3.json +35 -0
- package/tests/common-resources/poi/poi4.json +38 -0
- package/tests/common-resources/poi/poi5.json +35 -0
- package/tests/common-resources/poiCategory/poiCategory1.json +7 -0
- package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.json +1 -0
- package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.png +0 -0
- package/tests/common-resources/point/point1.json +14 -0
- package/tests/common-resources/point/point2.json +14 -0
- package/tests/common-resources/point/point3.json +14 -0
- package/tests/common-resources/point/point4.json +14 -0
- package/tests/common-resources/point/point5.json +14 -0
- package/tests/common-resources/point/point6.json +14 -0
- package/tests/common-resources/point/point7.json +14 -0
- package/tests/common-resources/point/point8.json +14 -0
- package/tests/common-resources/route/route1.json +530 -0
- package/tests/common-resources/routeStep/routeStep1.json +35 -0
- package/tests/common-resources/routeStep/routeStep2.json +35 -0
- package/tests/common-resources/routeStep/routeStep3.json +35 -0
- package/tests/common-resources/routeStep/routeStep4.json +35 -0
- package/tests/common-resources/routeStep/routeStep5.json +35 -0
- package/tests/common-resources/situmConversionArea/situmConversionArea1.json +19 -0
- package/tests/js/resources/fetchBuildings.json +176 -0
- package/tests/js/resources/fetchEventsFromBuilding.json +201 -0
- package/tests/js/resources/fetchFloorsFromBuilding.json +34 -0
- package/tests/js/resources/fetchIndoorPOIsFromBuilding.json +574 -0
- package/tests/js/resources/fetchMapFromFloor.json +3 -0
- package/tests/js/resources/fetchOutdoorPOIsFromBuilding.json +68 -0
- package/tests/js/resources/fetchPoiCategories.json +72 -0
- package/tests/js/resources/fetchPoiCategoryIconNormal.json +3 -0
- package/tests/js/resources/fetchPoiCategoryIconSelected.json +3 -0
- package/tests/js/resources/requestDirections.json +1167 -0
- package/tests/js/resources/startPositioning/0_starting.json +4 -0
- package/tests/js/resources/startPositioning/1_preparingPositioningModel.json +4 -0
- package/tests/js/resources/startPositioning/2_startingPositioning.json +4 -0
- package/tests/js/resources/startPositioning/3_calculating.json +4 -0
- package/tests/js/resources/startPositioning/4_position.json +48 -0
- package/tests/js/resources/startPositioning/5_position.json +48 -0
- package/tests/js/test.js +416 -0
- package/tests/scripts/clean_android_resources.sh +3 -0
- package/tests/scripts/clean_ios_resources.sh +3 -0
- package/tests/scripts/copy_android_resources.sh +3 -0
- package/tests/scripts/copy_ios_resources.sh +3 -0
- package/tests/scripts/self-destruct.sh +1 -0
- package/www/android/Interfaces.js +742 -0
- package/www/android/situm.js +296 -0
- package/www/ios/situm.js +99 -0
- package/www/map-view-controller.js +223 -0
- package/www/map-view.js +88 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
#import "SitumPlugin.h"
|
|
2
|
+
#import "SitumLocationWrapper.h"
|
|
3
|
+
#import "SITUtils.h"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#import <Cordova/CDVAvailability.h>
|
|
7
|
+
|
|
8
|
+
static NSString *ResultsKey = @"results";
|
|
9
|
+
|
|
10
|
+
static NSString *StartingAngle=@"startingAngle";
|
|
11
|
+
static NSString *Accessible=@"accessible";
|
|
12
|
+
|
|
13
|
+
static BOOL IS_LOG_ENABLED = NO;
|
|
14
|
+
|
|
15
|
+
static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
|
|
16
|
+
|
|
17
|
+
@interface SitumPlugin() {}
|
|
18
|
+
|
|
19
|
+
@property (nonatomic, strong) SITRoute *computedRoute;
|
|
20
|
+
|
|
21
|
+
@end
|
|
22
|
+
|
|
23
|
+
@implementation SitumPlugin
|
|
24
|
+
|
|
25
|
+
@synthesize computedRoute = _computedRoute;
|
|
26
|
+
|
|
27
|
+
- (void)setApiKey:(CDVInvokedUrlCommand *)command {
|
|
28
|
+
NSString* email = [command.arguments objectAtIndex:0];
|
|
29
|
+
NSString* apiKey = [command.arguments objectAtIndex:1];
|
|
30
|
+
[SITServices provideAPIKey:apiKey forEmail:email];
|
|
31
|
+
|
|
32
|
+
if (IS_LOG_ENABLED) {
|
|
33
|
+
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
34
|
+
NSString *documentsDirectory = [allPaths objectAtIndex:0];
|
|
35
|
+
NSString *pathForLog = [documentsDirectory stringByAppendingPathComponent:@"logging.txt"];
|
|
36
|
+
freopen([pathForLog cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
|
|
37
|
+
|
|
38
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ Logging ios calls", DEFAULT_SITUM_LOG]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)setUseRemoteConfig:(CDVInvokedUrlCommand *)command {
|
|
44
|
+
BOOL useRemoteConfig = [[command.arguments objectAtIndex: 0] boolValue];
|
|
45
|
+
[SITServices setUseRemoteConfig:useRemoteConfig];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)setUserPass:(CDVInvokedUrlCommand *)command {
|
|
49
|
+
NSString* email = [command.arguments objectAtIndex:0];
|
|
50
|
+
NSString* password = [command.arguments objectAtIndex:1];
|
|
51
|
+
[SITServices provideUser:email password:password];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)setCacheMaxAge:(CDVInvokedUrlCommand *)command {
|
|
55
|
+
NSNumber* cacheMaxAge = [command.arguments objectAtIndex:0]; // on iOS this value
|
|
56
|
+
[[SITCommunicationManager sharedManager] setCacheMaxAge:[cacheMaxAge integerValue]];
|
|
57
|
+
NSString *operation = [NSString stringWithFormat:@"Setting cache max age to :%@ seconds", cacheMaxAge];
|
|
58
|
+
|
|
59
|
+
if (IS_LOG_ENABLED) {
|
|
60
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ ", DEFAULT_SITUM_LOG, operation]);
|
|
61
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ Cache max age is %ld seconds", DEFAULT_SITUM_LOG, (long)[[SITCommunicationManager sharedManager] cacheMaxAge]]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)fetchBuildingInfo:(CDVInvokedUrlCommand *)command
|
|
66
|
+
{
|
|
67
|
+
// TODO:
|
|
68
|
+
// Retrieve the buildingIdentifier
|
|
69
|
+
NSDictionary* buildingJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
70
|
+
|
|
71
|
+
NSString *operation = @"Fetching building info request";
|
|
72
|
+
if (IS_LOG_ENABLED) {
|
|
73
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ with parameters: %@", DEFAULT_SITUM_LOG, operation, buildingJO]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
NSString *buildingId = [buildingJO valueForKey:@"identifier"];
|
|
77
|
+
|
|
78
|
+
[[SITCommunicationManager sharedManager] fetchBuildingInfo:buildingId withOptions:nil success:^(NSDictionary * _Nullable mapping) {
|
|
79
|
+
if (IS_LOG_ENABLED) {
|
|
80
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ Fetching buildings returned values", DEFAULT_SITUM_LOG, operation]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Parse and convert to json
|
|
84
|
+
NSDictionary *buildingInfoJson = [SitumLocationWrapper.shared buildingInfoToJsonObject:mapping[@"results"]];
|
|
85
|
+
|
|
86
|
+
// Send result outsidecon e
|
|
87
|
+
if (IS_LOG_ENABLED) {
|
|
88
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ retrieved building info: %@ of building: %@", DEFAULT_SITUM_LOG, operation, buildingInfoJson, buildingJO]);
|
|
89
|
+
}
|
|
90
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:buildingInfoJson.copy];
|
|
91
|
+
// }
|
|
92
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
93
|
+
|
|
94
|
+
} failure:^(NSError * _Nullable error) {
|
|
95
|
+
if (IS_LOG_ENABLED) {
|
|
96
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ error : %@ retrieving building info on building: %@", DEFAULT_SITUM_LOG, operation, error, buildingId]);
|
|
97
|
+
}
|
|
98
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
99
|
+
}];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
- (void)fetchBuildings:(CDVInvokedUrlCommand*)command
|
|
103
|
+
{
|
|
104
|
+
if (buildingsStored == nil) {
|
|
105
|
+
buildingsStored = [[NSMutableDictionary alloc] init];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
NSString *operation = @"Fetching buildings request";
|
|
109
|
+
if (IS_LOG_ENABLED) {
|
|
110
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ ", DEFAULT_SITUM_LOG, operation]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Forcing requests to go to the network instead of cache
|
|
114
|
+
NSDictionary *options = @{@"forceRequest":@YES,};
|
|
115
|
+
|
|
116
|
+
[[SITCommunicationManager sharedManager] fetchBuildingsWithOptions:options success:^(NSDictionary *mapping) {
|
|
117
|
+
if (IS_LOG_ENABLED) {
|
|
118
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ Fetching buildings returned values", DEFAULT_SITUM_LOG, operation]);
|
|
119
|
+
}
|
|
120
|
+
NSArray *buildings = [mapping valueForKey:ResultsKey];
|
|
121
|
+
CDVPluginResult* pluginResult = nil;
|
|
122
|
+
if (buildings.count == 0) {
|
|
123
|
+
if (IS_LOG_ENABLED) {
|
|
124
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ No buildings were retrieved", DEFAULT_SITUM_LOG, operation]);
|
|
125
|
+
}
|
|
126
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"There are no buildings on the account. Please go to dashboard http://dashboard.situm.es and learn more about the first step with Situm technology"];
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
130
|
+
for (SITBuilding *obj in buildings) {
|
|
131
|
+
[ja addObject:[SitumLocationWrapper.shared buildingToJsonObject:obj]];
|
|
132
|
+
[buildingsStored setObject:obj forKey:[NSString stringWithFormat:@"%@", obj.identifier]];
|
|
133
|
+
}
|
|
134
|
+
if (IS_LOG_ENABLED) {
|
|
135
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ Retrieved the following buildings: %@", DEFAULT_SITUM_LOG, operation, buildings]);
|
|
136
|
+
}
|
|
137
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
138
|
+
}
|
|
139
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
140
|
+
}
|
|
141
|
+
failure:^(NSError *error) {
|
|
142
|
+
if (IS_LOG_ENABLED)
|
|
143
|
+
{
|
|
144
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ Error retrieving buildings: %@", DEFAULT_SITUM_LOG, operation, error]);
|
|
145
|
+
}
|
|
146
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (void)fetchGeofencesFromBuilding:(CDVInvokedUrlCommand*)command
|
|
151
|
+
{
|
|
152
|
+
NSDictionary* buildingJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
153
|
+
|
|
154
|
+
NSString *operation = @"Fetching geofences request";
|
|
155
|
+
if (IS_LOG_ENABLED) {
|
|
156
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ with parameters: %@", DEFAULT_SITUM_LOG, operation, buildingJO]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
NSString *buildingId = [buildingJO valueForKey:@"identifier"];
|
|
160
|
+
SITBuilding *building = [[SITBuilding alloc]init];
|
|
161
|
+
building.identifier = buildingId;
|
|
162
|
+
|
|
163
|
+
[[SITCommunicationManager sharedManager] fetchGeofencesFromBuilding:building
|
|
164
|
+
withOptions:nil
|
|
165
|
+
withCompletion:^(id _Nullable array, NSError * _Nullable error) {
|
|
166
|
+
if (error) {
|
|
167
|
+
if (IS_LOG_ENABLED) {
|
|
168
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ error : %@ retrieving geofences on building: %@", DEFAULT_SITUM_LOG, operation, error, buildingJO]);
|
|
169
|
+
}
|
|
170
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
171
|
+
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// A success has been returned
|
|
176
|
+
if (IS_LOG_ENABLED) {
|
|
177
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ responded", DEFAULT_SITUM_LOG, operation]);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
181
|
+
if (IS_LOG_ENABLED) {
|
|
182
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ results: %@", DEFAULT_SITUM_LOG, operation, array]);
|
|
183
|
+
}
|
|
184
|
+
// TODO: for some reason, the array of Geofences is being received into a "results" dict.
|
|
185
|
+
if ([array objectForKey:@"results"]) {
|
|
186
|
+
array = [array objectForKey:@"results"];
|
|
187
|
+
}
|
|
188
|
+
for (SITGeofence *obj in array) {
|
|
189
|
+
NSDictionary *jsonObject = [SitumLocationWrapper.shared geofenceToJsonObject:obj];
|
|
190
|
+
if (IS_LOG_ENABLED) {
|
|
191
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ parsed floor: %@", DEFAULT_SITUM_LOG, operation, jsonObject]);
|
|
192
|
+
}
|
|
193
|
+
[ja addObject:jsonObject];
|
|
194
|
+
if (IS_LOG_ENABLED) {
|
|
195
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ json array has : %@", DEFAULT_SITUM_LOG, operation, ja]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
CDVPluginResult* pluginResult = nil;
|
|
199
|
+
// Not having geofences is not an error
|
|
200
|
+
if (IS_LOG_ENABLED) {
|
|
201
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ retrieved geofences: %@ on building: %@", DEFAULT_SITUM_LOG, operation, array, buildingJO]);
|
|
202
|
+
}
|
|
203
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
204
|
+
// }
|
|
205
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
206
|
+
}];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
- (void)fetchFloorsFromBuilding:(CDVInvokedUrlCommand*)command
|
|
211
|
+
{
|
|
212
|
+
NSDictionary* buildingJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
213
|
+
|
|
214
|
+
NSString *operation = @"Fetching floors request";
|
|
215
|
+
if (IS_LOG_ENABLED) {
|
|
216
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ with parameters: %@", DEFAULT_SITUM_LOG, operation, buildingJO]);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (floorStored == nil) {
|
|
220
|
+
floorStored = [[NSMutableDictionary alloc] init];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
NSString *buildingId = [buildingJO valueForKey:@"identifier"];
|
|
224
|
+
|
|
225
|
+
[[SITCommunicationManager sharedManager] fetchFloorsForBuilding:buildingId withOptions:nil success:^(NSDictionary *mapping) {
|
|
226
|
+
if (IS_LOG_ENABLED) {
|
|
227
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ responded", DEFAULT_SITUM_LOG, operation]);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
231
|
+
NSArray *floors = [mapping objectForKey:@"results"];
|
|
232
|
+
if (IS_LOG_ENABLED) {
|
|
233
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ results: %@", DEFAULT_SITUM_LOG, operation, floors]);
|
|
234
|
+
}
|
|
235
|
+
for (SITFloor *obj in floors) {
|
|
236
|
+
NSDictionary *floorJson = [SitumLocationWrapper.shared floorToJsonObject:obj];
|
|
237
|
+
if (IS_LOG_ENABLED) {
|
|
238
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ parsed floor: %@", DEFAULT_SITUM_LOG, operation, floorJson]);
|
|
239
|
+
}
|
|
240
|
+
[ja addObject:floorJson];
|
|
241
|
+
if (IS_LOG_ENABLED) {
|
|
242
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ json array has : %@", DEFAULT_SITUM_LOG, operation, ja]);
|
|
243
|
+
}
|
|
244
|
+
[floorStored setObject:obj forKey:[NSString stringWithFormat:@"%@", obj.identifier]];
|
|
245
|
+
if (IS_LOG_ENABLED) {
|
|
246
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ added: %@ to dictionary results", DEFAULT_SITUM_LOG, operation, obj]);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
CDVPluginResult* pluginResult = nil;
|
|
250
|
+
if (floors.count == 0) {
|
|
251
|
+
if (IS_LOG_ENABLED) {
|
|
252
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ no floors on building: %@", DEFAULT_SITUM_LOG, operation, buildingJO]);
|
|
253
|
+
}
|
|
254
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"The selected building does not have floors. Correct that on http://dashboard.situm.es"];
|
|
255
|
+
} else {
|
|
256
|
+
if (IS_LOG_ENABLED) {
|
|
257
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ retrieved floors: %@ on building: %@", DEFAULT_SITUM_LOG, operation, floors, buildingJO]);
|
|
258
|
+
}
|
|
259
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
260
|
+
}
|
|
261
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
262
|
+
} failure:^(NSError *error) {
|
|
263
|
+
if (IS_LOG_ENABLED) {
|
|
264
|
+
NSLog(@"%@", [NSString stringWithFormat: @"%@ %@ error : %@ retrieving floors on building: %@", DEFAULT_SITUM_LOG, operation, error, buildingJO]);
|
|
265
|
+
}
|
|
266
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
267
|
+
}];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
- (void)fetchIndoorPOIsFromBuilding:(CDVInvokedUrlCommand*)command
|
|
272
|
+
{
|
|
273
|
+
NSDictionary* buildingJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
274
|
+
|
|
275
|
+
if (poisStored == nil) {
|
|
276
|
+
poisStored = [[NSMutableDictionary alloc] init];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
[[SITCommunicationManager sharedManager] fetchPoisOfBuilding:[buildingJO valueForKey:@"identifier"] withOptions:nil success:^(NSDictionary *mapping) {
|
|
280
|
+
NSArray *list = [mapping objectForKey:@"results"];
|
|
281
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
282
|
+
for (SITPOI *obj in list) {
|
|
283
|
+
[ja addObject:[SitumLocationWrapper.shared poiToJsonObject:obj]];
|
|
284
|
+
[poisStored setObject:obj forKey:obj.name];
|
|
285
|
+
}
|
|
286
|
+
CDVPluginResult* pluginResult = nil;
|
|
287
|
+
if (list.count == 0) {
|
|
288
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"You have no poi. Create one in the Dashboard"];
|
|
289
|
+
} else {
|
|
290
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
291
|
+
}
|
|
292
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
293
|
+
} failure:^(NSError *error) {
|
|
294
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
295
|
+
}];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
- (void)fetchOutdoorPOIsFromBuilding:(CDVInvokedUrlCommand*)command
|
|
299
|
+
{
|
|
300
|
+
NSDictionary* buildingJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
301
|
+
|
|
302
|
+
if (poisStored == nil) {
|
|
303
|
+
poisStored = [[NSMutableDictionary alloc] init];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
[[SITCommunicationManager sharedManager] fetchOutdoorPoisOfBuilding:[buildingJO valueForKey:@"identifier"] withOptions:nil success:^(NSDictionary *mapping) {
|
|
307
|
+
NSArray *list = [mapping objectForKey:@"results"];
|
|
308
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
309
|
+
for (SITPOI *obj in list) {
|
|
310
|
+
[ja addObject:[SitumLocationWrapper.shared poiToJsonObject:obj]];
|
|
311
|
+
[poisStored setObject:obj forKey:obj.name];
|
|
312
|
+
}
|
|
313
|
+
CDVPluginResult* pluginResult = nil;
|
|
314
|
+
if (list.count == 0) {
|
|
315
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"You have no poi. Create one in the Dashboard"];
|
|
316
|
+
} else {
|
|
317
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
318
|
+
}
|
|
319
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
320
|
+
} failure:^(NSError *error) {
|
|
321
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
322
|
+
}];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
- (void)fetchEventsFromBuilding:(CDVInvokedUrlCommand*)command
|
|
326
|
+
{
|
|
327
|
+
NSDictionary* buildingJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
328
|
+
|
|
329
|
+
if (eventStored == nil) {
|
|
330
|
+
eventStored = [[NSMutableDictionary alloc] init];
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
SITBuilding *building = [SITBuilding new];
|
|
334
|
+
building.identifier = buildingJO[@"identifier"];
|
|
335
|
+
|
|
336
|
+
[[SITCommunicationManager sharedManager] fetchEventsFromBuilding:building withOptions:nil withCompletion:^SITHandler(NSArray<SITEvent *> *events, NSError *error) {
|
|
337
|
+
if (!error) {
|
|
338
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
339
|
+
for (SITEvent *obj in events) {
|
|
340
|
+
[ja addObject:[SitumLocationWrapper.shared eventToJsonObject:obj]];
|
|
341
|
+
[eventStored setObject:obj forKey:[NSString stringWithFormat:@"%@", obj.name]];
|
|
342
|
+
}
|
|
343
|
+
CDVPluginResult* pluginResult = nil;
|
|
344
|
+
if (events.count == 0) {
|
|
345
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"You have no events. Create one in the Dashboard"];
|
|
346
|
+
} else {
|
|
347
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
348
|
+
}
|
|
349
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
350
|
+
} else {
|
|
351
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
352
|
+
}
|
|
353
|
+
return false;
|
|
354
|
+
}];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
- (void)fetchPoiCategories:(CDVInvokedUrlCommand *)command
|
|
358
|
+
{
|
|
359
|
+
//NSDictionary* categoryJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
360
|
+
|
|
361
|
+
if (categoryStored == nil) {
|
|
362
|
+
categoryStored = [[NSMutableDictionary alloc] init];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
[[SITCommunicationManager sharedManager] fetchCategoriesWithOptions:nil withCompletion:^(NSArray *categories, NSError *error) {
|
|
366
|
+
if (!error) {
|
|
367
|
+
NSMutableArray *ja = [[NSMutableArray alloc] init];
|
|
368
|
+
for (SITPOICategory *obj in categories) {
|
|
369
|
+
[ja addObject:[SitumLocationWrapper.shared poiCategoryToJsonObject:obj]];
|
|
370
|
+
[categoryStored setObject:obj forKey:[NSString stringWithFormat:@"%@", obj.name]];
|
|
371
|
+
}
|
|
372
|
+
CDVPluginResult* pluginResult = nil;
|
|
373
|
+
if (categories.count == 0) {
|
|
374
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"You have no categories. Create one in the Dashboard"];
|
|
375
|
+
} else {
|
|
376
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ja.copy];
|
|
377
|
+
}
|
|
378
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
379
|
+
} else {
|
|
380
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
381
|
+
}
|
|
382
|
+
}];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
- (void)fetchPoiCategoryIconNormal:(CDVInvokedUrlCommand *)command
|
|
386
|
+
{
|
|
387
|
+
NSDictionary* categoryJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
388
|
+
|
|
389
|
+
if (categoryStored == nil) {
|
|
390
|
+
categoryStored = [[NSMutableDictionary alloc] init];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
SITPOICategory *category = [[SitumLocationWrapper shared] poiCategoryFromJsonObject:categoryJO];
|
|
394
|
+
|
|
395
|
+
[[SITCommunicationManager sharedManager] fetchSelected:false iconForCategory:category withCompletion:^(NSData *data, NSError *error) {
|
|
396
|
+
if (!error) {
|
|
397
|
+
CDVPluginResult* pluginResult = nil;
|
|
398
|
+
if (data == nil) {
|
|
399
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Icon not found"];
|
|
400
|
+
} else {
|
|
401
|
+
UIImage *icon = [UIImage imageWithData:data];
|
|
402
|
+
NSDictionary * dict = [[SitumLocationWrapper shared] bitmapToJsonObject:icon];
|
|
403
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
|
|
404
|
+
}
|
|
405
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
406
|
+
} else {
|
|
407
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
408
|
+
}
|
|
409
|
+
}];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
- (void)fetchPoiCategoryIconSelected:(CDVInvokedUrlCommand *)command
|
|
413
|
+
{
|
|
414
|
+
NSDictionary* categoryJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
415
|
+
|
|
416
|
+
if (categoryStored == nil) {
|
|
417
|
+
categoryStored = [[NSMutableDictionary alloc] init];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
SITPOICategory *category = [[SitumLocationWrapper shared] poiCategoryFromJsonObject:categoryJO];
|
|
421
|
+
|
|
422
|
+
[[SITCommunicationManager sharedManager] fetchSelected:true iconForCategory:category withCompletion:^(NSData *data, NSError *error) {
|
|
423
|
+
if (!error) {
|
|
424
|
+
CDVPluginResult* pluginResult = nil;
|
|
425
|
+
if (data == nil) {
|
|
426
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Icon not found"];
|
|
427
|
+
} else {
|
|
428
|
+
UIImage *icon = [UIImage imageWithData:data];
|
|
429
|
+
NSDictionary * dict = [[SitumLocationWrapper shared] bitmapToJsonObject:icon];
|
|
430
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
|
|
431
|
+
}
|
|
432
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
433
|
+
} else {
|
|
434
|
+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description] callbackId:command.callbackId];
|
|
435
|
+
}
|
|
436
|
+
}];
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
- (void)fetchMapFromFloor:(CDVInvokedUrlCommand *)command
|
|
440
|
+
{
|
|
441
|
+
NSDictionary* floorJO = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
442
|
+
|
|
443
|
+
if (floorStored == nil) {
|
|
444
|
+
floorStored = [[NSMutableDictionary alloc] init];
|
|
445
|
+
}
|
|
446
|
+
SITFloor* floor = [SitumLocationWrapper.shared jsonObjectToFloor:floorJO];
|
|
447
|
+
|
|
448
|
+
[[SITCommunicationManager sharedManager] fetchMapFromFloor: floor withCompletion:^(NSData *imageData) {
|
|
449
|
+
NSMutableDictionary *jaMap = [[NSMutableDictionary alloc] init];
|
|
450
|
+
NSString *imageBase64Encoded = [imageData base64EncodedStringWithOptions:0];
|
|
451
|
+
[jaMap setObject:[NSString stringWithFormat:@"%@", imageBase64Encoded] forKey:@"data"];
|
|
452
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:jaMap];
|
|
453
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
454
|
+
}];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
- (void)startPositioning:(CDVInvokedUrlCommand *)command {
|
|
458
|
+
locationCallbackId = command.callbackId;
|
|
459
|
+
SITLocationRequest *locationRequest = [SitumLocationWrapper.shared jsonObjectToLocationRequest:command.arguments];
|
|
460
|
+
[[SITLocationManager sharedInstance] addDelegate:self];
|
|
461
|
+
[[SITLocationManager sharedInstance] requestLocationUpdates:locationRequest];
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
- (void)stopPositioning:(CDVInvokedUrlCommand *)command {
|
|
465
|
+
locationCallbackId = command.callbackId;
|
|
466
|
+
[[SITLocationManager sharedInstance] removeUpdates];
|
|
467
|
+
[[SITLocationManager sharedInstance] removeDelegate:self];
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
- (void)onEnterGeofences:(CDVInvokedUrlCommand *)command {
|
|
471
|
+
enterGeofencesCallbackId = command.callbackId;
|
|
472
|
+
[[SITLocationManager sharedInstance] setGeofenceDelegate:self];
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
- (void)onExitGeofences:(CDVInvokedUrlCommand *)command {
|
|
476
|
+
exitGeofencesCallbackId = command.callbackId;
|
|
477
|
+
[[SITLocationManager sharedInstance] setGeofenceDelegate:self];
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
- (void)requestDirections:(CDVInvokedUrlCommand*)command
|
|
481
|
+
{
|
|
482
|
+
|
|
483
|
+
routeCallbackId = command.callbackId;
|
|
484
|
+
|
|
485
|
+
if (routesStored == nil) {
|
|
486
|
+
routesStored = [[NSMutableDictionary alloc] init];
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
SITDirectionsRequest* directionsRequest = [SitumLocationWrapper.shared jsonObjectToDirectionsRequest:command.arguments];
|
|
490
|
+
|
|
491
|
+
if (directionsRequest == nil) {
|
|
492
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Unable to parse request"];
|
|
493
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:routeCallbackId];
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
[[SITDirectionsManager sharedInstance] setDelegate:self];
|
|
498
|
+
[[SITDirectionsManager sharedInstance] requestDirections:directionsRequest];
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
- (void)requestNavigationUpdates:(CDVInvokedUrlCommand*)command
|
|
502
|
+
{
|
|
503
|
+
navigationProgressCallbackId = command.callbackId;
|
|
504
|
+
NSNumber* distanceToChangeFloorThreshold;
|
|
505
|
+
NSNumber* distanceToChangeIndicationThreshold;
|
|
506
|
+
NSNumber* distanceToGoalThreshold;
|
|
507
|
+
NSNumber* outsideRouteThreshold;
|
|
508
|
+
NSNumber* indicationsInterval;
|
|
509
|
+
NSNumber* timeToFirstIndication;
|
|
510
|
+
NSNumber* roundIndicationsStep;
|
|
511
|
+
NSNumber* timeToIgnoreUnexpectedFloorChanges;
|
|
512
|
+
|
|
513
|
+
if (command.arguments.count > 0) {
|
|
514
|
+
// Processing configuration parameters
|
|
515
|
+
NSDictionary *options = (NSDictionary*)[command.arguments objectAtIndex:0];
|
|
516
|
+
distanceToChangeFloorThreshold = (NSNumber*)[options objectForKey:@"distanceToFloorChangeThreshold"];
|
|
517
|
+
distanceToChangeIndicationThreshold = (NSNumber*)[options objectForKey:@"distanceToChangeIndicationThreshold"];
|
|
518
|
+
distanceToGoalThreshold = (NSNumber*)[options objectForKey:@"distanceToGoalThreshold"];
|
|
519
|
+
outsideRouteThreshold = (NSNumber*)[options objectForKey:@"outsideRouteThreshold"];
|
|
520
|
+
indicationsInterval = (NSNumber*)[options objectForKey:@"indicationsInterval"];
|
|
521
|
+
timeToFirstIndication = (NSNumber*)[options objectForKey:@"timeToFirstIndication"];
|
|
522
|
+
roundIndicationsStep = (NSNumber*)[options objectForKey:@"roundIndicationsStep"];
|
|
523
|
+
timeToIgnoreUnexpectedFloorChanges = (NSNumber*)[options objectForKey:@"timeToIgnoreUnexpectedFloorChanges"];
|
|
524
|
+
}
|
|
525
|
+
SITRoute *routeObj = self.computedRoute;
|
|
526
|
+
if (routeObj) {
|
|
527
|
+
SITNavigationRequest *navigationRequest = [[SITNavigationRequest alloc] initWithRoute:routeObj];
|
|
528
|
+
if (distanceToChangeIndicationThreshold != nil) {
|
|
529
|
+
NSInteger value = [distanceToChangeIndicationThreshold integerValue];
|
|
530
|
+
[navigationRequest setDistanceToChangeIndicationThreshold: value];
|
|
531
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.distanceToChangeIndicationThreshold: %ld", navigationRequest.distanceToChangeIndicationThreshold]);
|
|
532
|
+
}
|
|
533
|
+
if (distanceToChangeFloorThreshold != nil) {
|
|
534
|
+
NSInteger value = [distanceToChangeFloorThreshold integerValue];
|
|
535
|
+
[navigationRequest setDistanceToChangeFloorThreshold: value];
|
|
536
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.distanceToChangeFloorThreshold: %ld", navigationRequest.distanceToFloorChangeThreshold]);
|
|
537
|
+
}
|
|
538
|
+
if (distanceToGoalThreshold != nil) {
|
|
539
|
+
NSInteger value = [distanceToGoalThreshold integerValue];
|
|
540
|
+
[navigationRequest setDistanceToGoalThreshold: value];
|
|
541
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.distanceToGoalThreshold: %ld", navigationRequest.distanceToGoalThreshold]);
|
|
542
|
+
}
|
|
543
|
+
if (outsideRouteThreshold != nil) {
|
|
544
|
+
NSInteger value = [outsideRouteThreshold integerValue];
|
|
545
|
+
[navigationRequest setOutsideRouteThreshold: value];
|
|
546
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.outsideRouteThreshold: %ld", navigationRequest.outsideRouteThreshold]);
|
|
547
|
+
}
|
|
548
|
+
if (indicationsInterval != nil) {
|
|
549
|
+
NSInteger value = [indicationsInterval integerValue];
|
|
550
|
+
[navigationRequest setIndicationsInterval: value];
|
|
551
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.indicationsInterval: %ld", navigationRequest.indicationsInterval]);
|
|
552
|
+
}
|
|
553
|
+
if (timeToFirstIndication != nil) {
|
|
554
|
+
NSInteger value = [timeToFirstIndication integerValue];
|
|
555
|
+
[navigationRequest setTimeToFirstIndication: value];
|
|
556
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.timeToFirstIndication: %ld", navigationRequest.timeToFirstIndication]);
|
|
557
|
+
}
|
|
558
|
+
if (roundIndicationsStep != nil) {
|
|
559
|
+
NSInteger value = [roundIndicationsStep integerValue];
|
|
560
|
+
[navigationRequest setRoundIndicationsStep: value];
|
|
561
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.roundIndicationsStep: %ld", navigationRequest.roundIndicationsStep]);
|
|
562
|
+
}
|
|
563
|
+
if (timeToIgnoreUnexpectedFloorChanges != nil) {
|
|
564
|
+
NSInteger value = [timeToIgnoreUnexpectedFloorChanges integerValue];
|
|
565
|
+
[navigationRequest setTimeToIgnoreUnexpectedFloorChanges: value];
|
|
566
|
+
NSLog(@"%@", [NSString stringWithFormat: @"navigationRequest.timeToIgnoreUnexpectedFloorChanges: %ld", navigationRequest.timeToIgnoreUnexpectedFloorChanges]);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
[[SITNavigationManager sharedManager] setDelegate:self]; // Configure delegation first
|
|
570
|
+
[[SITNavigationManager sharedManager] requestNavigationUpdates:navigationRequest];
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
- (void)updateNavigationWithLocation:(CDVInvokedUrlCommand *)command {
|
|
577
|
+
|
|
578
|
+
SITLocation *location = [SitumLocationWrapper.shared locationJsonObjectToLocation:(NSDictionary*)[command.arguments objectAtIndex:0]];
|
|
579
|
+
|
|
580
|
+
[[SITNavigationManager sharedManager] updateWithLocation:location];
|
|
581
|
+
|
|
582
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Navigation updated"];
|
|
583
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
584
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
- (void) removeNavigationUpdates:(CDVInvokedUrlCommand *)command {
|
|
588
|
+
[[SITNavigationManager sharedManager] removeUpdates];
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
- (void) invalidateCache:(CDVInvokedUrlCommand *)command {
|
|
592
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc] init];
|
|
593
|
+
[[SITCommunicationManager sharedManager] clearCache];
|
|
594
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:obj.copy];
|
|
595
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Realtime
|
|
599
|
+
- (void)requestRealTimeUpdates:(CDVInvokedUrlCommand *)command {
|
|
600
|
+
realtimeCallbackId = command.callbackId;
|
|
601
|
+
SITRealTimeRequest *request = [SitumLocationWrapper.shared realtimeRequestFromJson:(NSDictionary*)[command.arguments objectAtIndex:0]];
|
|
602
|
+
|
|
603
|
+
[[SITRealTimeManager sharedManager] requestRealTimeUpdates:request];
|
|
604
|
+
[SITRealTimeManager sharedManager].delegate = self;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
- (void)removeRealTimeUpdates:(CDVInvokedUrlCommand *)command {
|
|
608
|
+
[[SITRealTimeManager sharedManager] removeRealTimeUpdates];
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// SITRealtimeDelegate methods
|
|
612
|
+
- (void)realTimeManager:(id <SITRealTimeInterface> _Nonnull)realTimeManager
|
|
613
|
+
didUpdateUserLocations:(SITRealTimeData * _Nonnull)realTimeData
|
|
614
|
+
{
|
|
615
|
+
// SITRealTimeData to json
|
|
616
|
+
NSDictionary *realtimeInfo = [SitumLocationWrapper.shared jsonFromRealtimeData:realTimeData];
|
|
617
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:realtimeInfo.copy];
|
|
618
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
619
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:realtimeCallbackId];
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
- (void)realTimeManager:(id <SITRealTimeInterface> _Nonnull)realTimeManager
|
|
623
|
+
didFailWithError:(NSError * _Nonnull)error
|
|
624
|
+
{
|
|
625
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description];
|
|
626
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
627
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:realtimeCallbackId];
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// SITLocationDelegate methods
|
|
631
|
+
|
|
632
|
+
- (void)locationManager:(nonnull id<SITLocationInterface>)locationManager
|
|
633
|
+
didUpdateLocation:(nonnull SITLocation *)location {
|
|
634
|
+
if (location) {
|
|
635
|
+
NSDictionary *locationJO = [SitumLocationWrapper.shared locationToJsonObject:location];
|
|
636
|
+
|
|
637
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:locationJO.copy];
|
|
638
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
639
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
- (void)locationManager:(nonnull id<SITLocationInterface>)locationManager
|
|
644
|
+
didFailWithError: (NSError * _Nullable)error {
|
|
645
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description];
|
|
646
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
647
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
- (void)locationManager:(nonnull id<SITLocationInterface>)locationManager
|
|
651
|
+
didUpdateState:(SITLocationState)state {
|
|
652
|
+
NSDictionary *locationChanged = [SitumLocationWrapper.shared locationStateToJsonObject:state];
|
|
653
|
+
|
|
654
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:locationChanged.copy];
|
|
655
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
656
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
// SITDirectionsDelegate
|
|
661
|
+
|
|
662
|
+
- (void)directionsManager:(id<SITDirectionsInterface>)manager
|
|
663
|
+
didFailProcessingRequest:(SITDirectionsRequest *)request
|
|
664
|
+
withError:(NSError *)error {
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
self.computedRoute = nil; // if something fails then the previous computedRoute is clean
|
|
668
|
+
|
|
669
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description];
|
|
670
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:routeCallbackId];
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
- (void)directionsManager:(id<SITDirectionsInterface>)manager
|
|
674
|
+
didProcessRequest:(SITDirectionsRequest *)request
|
|
675
|
+
withResponse:(SITRoute *)route {
|
|
676
|
+
NSString * timestamp = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970] * 1000];
|
|
677
|
+
|
|
678
|
+
NSMutableDictionary *routeJO = [[SitumLocationWrapper.shared routeToJsonObject:route] mutableCopy];
|
|
679
|
+
[routesStored setObject:route forKey:timestamp];
|
|
680
|
+
|
|
681
|
+
self.computedRoute = route; // We store the computed route in order to insert it into the navigation component if neccessary
|
|
682
|
+
|
|
683
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:routeJO.copy];
|
|
684
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:routeCallbackId];
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// SITNavigationDelegate
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
- (void)navigationManager:(id<SITNavigationInterface>)navigationManager
|
|
691
|
+
didFailWithError:(NSError *)error {
|
|
692
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description];
|
|
693
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
694
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:navigationProgressCallbackId];
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
- (void)navigationManager:(id<SITNavigationInterface>)navigationManager
|
|
698
|
+
didUpdateProgress:(SITNavigationProgress *)progress
|
|
699
|
+
onRoute:(SITRoute *)route {
|
|
700
|
+
NSMutableDictionary *navigationJO = [NSMutableDictionary dictionaryWithDictionary:[SitumLocationWrapper.shared navigationProgressToJsonObject:progress]];
|
|
701
|
+
[navigationJO setValue:@"progress" forKey:@"type"];
|
|
702
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:navigationJO.copy];
|
|
703
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
704
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:navigationProgressCallbackId];
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
- (void)navigationManager:(id<SITNavigationInterface>)navigationManager
|
|
708
|
+
destinationReachedOnRoute:(SITRoute *)route {
|
|
709
|
+
NSMutableDictionary *navigationJO = [[NSMutableDictionary alloc] init];
|
|
710
|
+
[navigationJO setValue:@"destinationReached" forKey:@"type"];
|
|
711
|
+
[navigationJO setValue:@"Destination reached" forKey:@"message"];
|
|
712
|
+
|
|
713
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:navigationJO.copy];
|
|
714
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
715
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:navigationProgressCallbackId];
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
- (void)navigationManager:(id<SITNavigationInterface>)navigationManager
|
|
720
|
+
userOutsideRoute:(SITRoute *)route {
|
|
721
|
+
NSMutableDictionary *navigationJO = [[NSMutableDictionary alloc] init];
|
|
722
|
+
[navigationJO setValue:@"userOutsideRoute" forKey:@"type"];
|
|
723
|
+
[navigationJO setValue:@"User outside route" forKey:@"message"];
|
|
724
|
+
|
|
725
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:navigationJO.copy];
|
|
726
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
727
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:navigationProgressCallbackId];
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// SITGeofencesDelegate
|
|
731
|
+
|
|
732
|
+
- (void)didEnteredGeofences:(NSArray<SITGeofence *> *)geofences {
|
|
733
|
+
if (enterGeofencesCallbackId) {
|
|
734
|
+
[self sendGeofences:geofences withCallbackId:enterGeofencesCallbackId];
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
- (void)didExitedGeofences:(NSArray<SITGeofence *> *)geofences {
|
|
739
|
+
if (exitGeofencesCallbackId) {
|
|
740
|
+
[self sendGeofences:geofences withCallbackId:exitGeofencesCallbackId];
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
- (void)sendGeofences:(NSArray<SITGeofence *> *)geofences
|
|
745
|
+
withCallbackId:(NSString *)callbackId {
|
|
746
|
+
NSArray *geofencesList = [SITUtils toArrayDict: geofences];
|
|
747
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:geofencesList.copy];
|
|
748
|
+
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
749
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
@end
|