4 * LocationManager usage example for Swift
5 * Demonstrates working with locations, sublocations, categories, and other location-related classes
7class LocationManagerExample: NSObject, NCLocationListener {
8 private var sdk: NCNavigineSdk?
9 private var locationManager: NCLocationManager?
10 private var currentLocation: NCLocation?
18 * Initialize SDK and get LocationManager
20 private func initializeSdk() {
22 // [swift_NavigineSdk_getInstance]
24 sdk = NCNavigineSdk.getInstance()
25 // [swift_NavigineSdk_getInstance]
27 // [swift_NavigineSdk_setUserHash]
29 sdk?.setUserHash("USER-HASH-HERE")
30 // [swift_NavigineSdk_setUserHash]
32 // [swift_NavigineSdk_setServer]
33 // Set server URL (optional)
34 sdk?.setServer("https://custom.navigine.com")
35 // [swift_NavigineSdk_setServer]
37 // [swift_NavigineSdk_getLocationManager]
38 // Get LocationManager for working with locations
39 locationManager = sdk?.getLocationManager()
40 // [swift_NavigineSdk_getLocationManager]
42 if locationManager != nil {
43 print("LocationManager successfully initialized")
46 print("Error initializing SDK: \(error)")
51 * Demonstrate LocationManager methods
53 func demonstrateLocationManagerMethods() {
54 guard let manager = locationManager else {
55 print("LocationManager not initialized")
59 // [swift_LocationManager_addLocationListener]
60 // Add location listener
61 manager.addLocationListener(self)
62 // [swift_LocationManager_addLocationListener]
64 // [swift_LocationManager_setLocationId]
65 // Set location ID to load
66 manager.setLocationId(12345)
67 // [swift_LocationManager_setLocationId]
69 // [swift_LocationManager_getLocationId]
70 // Get current location ID
71 let currentLocationId = manager.getLocationId()
72 print("Current location ID: \(currentLocationId)")
73 // [swift_LocationManager_getLocationId]
75 // [swift_LocationManager_setLocationUpdateInterval]
76 // Set location update interval (in seconds)
77 manager.setLocationUpdateInterval(600) // 10 minutes
78 // [swift_LocationManager_setLocationUpdateInterval]
80 // [swift_LocationManager_commitChanges]
82 manager.commitChanges()
83 // [swift_LocationManager_commitChanges]
85 // [swift_LocationManager_revertChanges]
86 // Revert changes (if needed)
87 // manager.revertChanges()
88 // [swift_LocationManager_revertChanges]
92 * Demonstrate Location class methods
94 func demonstrateLocationUsage(_ location: NCLocation) {
95 // [swift_Location_getId]
97 let locationId = location.getId()
98 print("Location ID: \(locationId)")
99 // [swift_Location_getId]
101 // [swift_Location_getVersion]
102 // Get location version
103 let version = location.getVersion()
104 print("Location version: \(version)")
105 // [swift_Location_getVersion]
107 // [swift_Location_getName]
109 let name = location.getName()
110 print("Location name: \(name ?? "nil")")
111 // [swift_Location_getName]
113 // [swift_Location_getDescript]
114 // Get location description
115 let description = location.getDescript()
116 print("Location description: \(description ?? "nil")")
117 // [swift_Location_getDescript]
119 // [swift_Location_getModified]
120 // Check if location is modified
121 let isModified = location.getModified()
122 print("Location modified: \(isModified)")
123 // [swift_Location_getModified]
125 // [swift_Location_getGraphTags]
126 // Get available graph tags
127 let graphTags = location.getGraphTags()
128 print("Available graph tags: \(graphTags)")
129 // [swift_Location_getGraphTags]
131 // [swift_Location_getElevationGraph]
132 // Get elevation graph by tag
133 if let firstTag = graphTags.first {
134 let elevationGraph = location.getElevationGraph(firstTag)
135 if let elevationGraph = elevationGraph {
136 demonstrateElevationGraphUsage(elevationGraph)
139 // [swift_Location_getElevationGraph]
141 // [swift_Location_getCategories]
142 // Get all categories
143 let categories = location.getCategories()
144 print("Number of categories: \(categories.count)")
145 // [swift_Location_getCategories]
147 // [swift_Location_getCategoryById]
148 // Get category by ID
149 if let firstCategory = categories.first {
150 let category = location.getCategoryById(firstCategory.getId())
151 if let category = category {
152 demonstrateCategoryUsage(category)
155 // [swift_Location_getCategoryById]
157 // [swift_Location_getSublocations]
158 // Get all sublocations
159 let sublocations = location.getSublocations()
160 print("Number of sublocations: \(sublocations.count)")
161 // [swift_Location_getSublocations]
163 // [swift_Location_getSublocationById]
164 // Get sublocation by ID
165 if let firstSublocation = sublocations.first {
166 let sublocation = location.getSublocationById(firstSublocation.getId())
167 if let sublocation = sublocation {
168 demonstrateSublocationUsage(sublocation)
171 // [swift_Location_getSublocationById]
175 * Demonstrate Category class methods
177 func demonstrateCategoryUsage(_ category: NCCategory) {
178 // [swift_Category_getId]
180 let categoryId = category.getId()
181 print("Category ID: \(categoryId)")
182 // [swift_Category_getId]
184 // [swift_Category_getName]
186 let categoryName = category.getName()
187 print("Category name: \(categoryName ?? "nil")")
188 // [swift_Category_getName]
190 // [swift_Category_getImageUrl]
191 // Get category image URL
192 if let imageUrl = category.getImageUrl() {
193 print("Category image URL: \(imageUrl)")
195 // [swift_Category_getImageUrl]
199 * Demonstrate Sublocation class methods
201 func demonstrateSublocationUsage(_ sublocation: NCSublocation) {
202 // [swift_Sublocation_getId]
203 // Get sublocation ID
204 let sublocationId = sublocation.getId()
205 print("Sublocation ID: \(sublocationId)")
206 // [swift_Sublocation_getId]
208 // [swift_Sublocation_getName]
209 // Get sublocation name
210 let sublocationName = sublocation.getName()
211 print("Sublocation name: \(sublocationName ?? "nil")")
212 // [swift_Sublocation_getName]
214 // [swift_Sublocation_getDescript]
215 // Get sublocation description
216 let sublocationDescription = sublocation.getDescript()
217 print("Sublocation description: \(sublocationDescription ?? "nil")")
218 // [swift_Sublocation_getDescript]
220 // [swift_Sublocation_getCategoryId]
222 let categoryId = sublocation.getCategoryId()
223 print("Sublocation category ID: \(categoryId)")
224 // [swift_Sublocation_getCategoryId]
226 // [swift_Sublocation_getLocation]
228 let locationId = sublocation.getLocation()
229 print("Sublocation location ID: \(locationId)")
230 // [swift_Sublocation_getLocation]
232 // [swift_Sublocation_getWidth]
233 // Get sublocation width in meters
234 let width = sublocation.getWidth()
235 print("Sublocation width: \(width) meters")
236 // [swift_Sublocation_getWidth]
238 // [swift_Sublocation_getHeight]
239 // Get sublocation height in meters
240 let height = sublocation.getHeight()
241 print("Sublocation height: \(height) meters")
242 // [swift_Sublocation_getHeight]
244 // [swift_Sublocation_getAltitude]
245 // Get sublocation altitude in meters
246 if let altitude = sublocation.getAltitude() {
247 print("Sublocation altitude: \(altitude) meters")
249 // [swift_Sublocation_getAltitude]
251 // [swift_Sublocation_getAzimuth]
252 // Get sublocation azimuth in degrees
253 let azimuth = sublocation.getAzimuth()
254 print("Sublocation azimuth: \(azimuth) degrees")
255 // [swift_Sublocation_getAzimuth]
257 // [swift_Sublocation_getOriginPoint]
258 // Get sublocation origin point in WGS84 coordinates
259 let originPoint = sublocation.getOriginPoint()
260 print("Sublocation origin point: \(originPoint.getLat()), \(originPoint.getLon())")
261 // [swift_Sublocation_getOriginPoint]
263 // [swift_Sublocation_getLevelId]
264 // Get sublocation level ID
265 let levelId = sublocation.getLevelId()
266 print("Sublocation level ID: \(levelId)")
267 // [swift_Sublocation_getLevelId]
269 // [swift_Sublocation_getExternalId]
270 // Get sublocation external ID
271 let externalId = sublocation.getExternalId()
272 print("Sublocation external ID: \(externalId)")
273 // [swift_Sublocation_getExternalId]
275 // [swift_Sublocation_getBuildingName]
276 // Get sublocation building name
277 let buildingName = sublocation.getBuildingName()
278 print("Sublocation building name: \(buildingName)")
279 // [swift_Sublocation_getBuildingName]
281 // [swift_Sublocation_getReferencePoints]
282 // Get reference points
283 let referencePoints = sublocation.getReferencePoints()
284 print("Number of reference points: \(referencePoints.count)")
285 // [swift_Sublocation_getReferencePoints]
287 // [swift_Sublocation_getVenues]
289 let venues = sublocation.getVenues()
290 print("Number of venues: \(venues.count)")
291 // [swift_Sublocation_getVenues]
293 // [swift_Sublocation_getZones]
295 let zones = sublocation.getZones()
296 print("Number of zones: \(zones.count)")
297 // [swift_Sublocation_getZones]
299 // [swift_Sublocation_getBeacons]
301 let beacons = sublocation.getBeacons()
302 print("Number of beacons: \(beacons.count)")
303 // [swift_Sublocation_getBeacons]
305 // [swift_Sublocation_getWifis]
306 // Get WiFi access points
307 let wifis = sublocation.getWifis()
308 print("Number of WiFi access points: \(wifis.count)")
309 // [swift_Sublocation_getWifis]
311 // [swift_Sublocation_getEddystones]
312 // Get Eddystone beacons
313 let eddystones = sublocation.getEddystones()
314 print("Number of Eddystone beacons: \(eddystones.count)")
315 // [swift_Sublocation_getEddystones]
317 // [swift_Sublocation_getGraph]
319 let graph = sublocation.getGraph()
320 if let graph = graph {
321 demonstrateGraphUsage(graph)
323 // [swift_Sublocation_getGraph]
325 // [swift_Sublocation_getGraph_withTag]
327 if let graphByTag = sublocation.getGraph("main") {
328 print("Found graph with tag \"main\"")
329 demonstrateGraphUsage(graphByTag)
331 // [swift_Sublocation_getGraph_withTag]
333 // [swift_Sublocation_getVenueById]
336 if let venueById = sublocation.getVenueById(venues.first!.getId()) {
337 print("Found venue by ID: \(venueById.getId())")
338 demonstrateVenueUsage(venueById)
341 // [swift_Sublocation_getVenueById]
343 // [swift_Sublocation_getZoneById]
346 if let zoneById = sublocation.getZoneById(zones.first!.getId()) {
347 print("Found zone by ID: \(zoneById.getId())")
348 demonstrateZoneUsage(zoneById)
351 // [swift_Sublocation_getZoneById]
353 // [swift_Sublocation_globalToLocal]
354 // Convert global coordinates to local coordinates
355 let globalPoint = NCGlobalPoint(lat: 55.7558, lon: 37.6176) // Moscow coordinates
356 let localPoint = sublocation.globalToLocal(globalPoint)
357 print("Global point \(globalPoint.getLat()), \(globalPoint.getLon()) converted to local: \(localPoint.getX()), \(localPoint.getY())")
358 // [swift_Sublocation_globalToLocal]
360 // [swift_Sublocation_localToGlobal]
361 // Convert local coordinates to global coordinates
362 let localPoint2 = NCLocationPoint(x: 100.0, y: 200.0)
363 let globalPoint2 = sublocation.localToGlobal(localPoint2)
364 print("Local point \(localPoint2.getX()), \(localPoint2.getY()) converted to global: \(globalPoint2.getLat()), \(globalPoint2.getLon())")
365 // [swift_Sublocation_localToGlobal]
367 // [swift_Sublocation_getImage]
368 // Get sublocation image
369 if let image = sublocation.getImage(1024) { // max texture size 1024
370 print("Sublocation image obtained with max texture size 1024")
372 // [swift_Sublocation_getImage]
376 * Demonstrate Venue class methods
378 func demonstrateVenueUsage(_ venue: NCVenue) {
379 // [swift_Venue_getId]
381 let venueId = venue.getId()
382 print("Venue ID: \(venueId)")
383 // [swift_Venue_getId]
385 // [swift_Venue_getLocationId]
386 // Get venue location ID
387 let locationId = venue.getLocationId()
388 print("Venue location ID: \(locationId)")
389 // [swift_Venue_getLocationId]
391 // [swift_Venue_getSublocationId]
392 // Get venue sublocation ID
393 let sublocationId = venue.getSublocationId()
394 print("Venue sublocation ID: \(sublocationId)")
395 // [swift_Venue_getSublocationId]
397 // [swift_Venue_getName]
399 let venueName = venue.getName()
400 print("Venue name: \(venueName ?? "nil")")
401 // [swift_Venue_getName]
403 // [swift_Venue_getPhone]
405 let phone = venue.getPhone()
406 print("Venue phone: \(phone ?? "nil")")
407 // [swift_Venue_getPhone]
409 // [swift_Venue_getDescript]
410 // Get venue description
411 let venueDescription = venue.getDescript()
412 print("Venue description: \(venueDescription ?? "nil")")
413 // [swift_Venue_getDescript]
415 // [swift_Venue_getAlias]
417 let alias = venue.getAlias()
418 print("Venue alias: \(alias ?? "nil")")
419 // [swift_Venue_getAlias]
421 // [swift_Venue_getCategoryId]
423 let categoryId = venue.getCategoryId()
424 print("Venue category ID: \(categoryId)")
425 // [swift_Venue_getCategoryId]
427 // [swift_Venue_getImageUrl]
428 // Get venue image URL
429 if let imageUrl = venue.getImageUrl() {
430 print("Venue image URL: \(imageUrl)")
432 // [swift_Venue_getImageUrl]
434 // [swift_Venue_getPoint]
436 let point = venue.getPoint()
437 if let point = point {
438 demonstratePointUsage(point)
440 // [swift_Venue_getPoint]
444 * Demonstrate Zone class methods
446 func demonstrateZoneUsage(_ zone: NCZone) {
447 // [swift_Zone_getId]
449 let zoneId = zone.getId()
450 print("Zone ID: \(zoneId)")
451 // [swift_Zone_getId]
453 // [swift_Zone_getLocationId]
454 // Get zone location ID
455 let locationId = zone.getLocationId()
456 print("Zone location ID: \(locationId)")
457 // [swift_Zone_getLocationId]
459 // [swift_Zone_getSublocationId]
460 // Get zone sublocation ID
461 let sublocationId = zone.getSublocationId()
462 print("Zone sublocation ID: \(sublocationId)")
463 // [swift_Zone_getSublocationId]
465 // [swift_Zone_getName]
467 let zoneName = zone.getName()
468 print("Zone name: \(zoneName ?? "nil")")
469 // [swift_Zone_getName]
471 // [swift_Zone_getDescript]
472 // Get zone description
473 let zoneDescription = zone.getDescript()
474 print("Zone description: \(zoneDescription ?? "nil")")
475 // [swift_Zone_getDescript]
477 // [swift_Zone_getCategoryId]
479 let categoryId = zone.getCategoryId()
480 print("Zone category ID: \(categoryId)")
481 // [swift_Zone_getCategoryId]
483 // [swift_Zone_getAlias]
485 let alias = zone.getAlias()
486 print("Zone alias: \(alias ?? "nil")")
487 // [swift_Zone_getAlias]
489 // [swift_Zone_getColor]
491 let color = zone.getColor()
492 print("Zone color: \(color ?? "nil")")
493 // [swift_Zone_getColor]
495 // [swift_Zone_getPolygon]
497 let polygon = zone.getPolygon()
498 print("Zone polygon points: \(polygon.count)")
499 // [swift_Zone_getPolygon]
503 * Demonstrate Beacon class methods
505 func demonstrateBeaconUsage(_ beacon: NCBeacon) {
506 // [swift_Beacon_getPoint]
508 let point = beacon.getPoint()
509 if let point = point {
510 demonstratePointUsage(point)
512 // [swift_Beacon_getPoint]
514 // [swift_Beacon_getLocationId]
515 // Get beacon location ID
516 let locationId = beacon.getLocationId()
517 print("Beacon location ID: \(locationId)")
518 // [swift_Beacon_getLocationId]
520 // [swift_Beacon_getSublocationId]
521 // Get beacon sublocation ID
522 let sublocationId = beacon.getSublocationId()
523 print("Beacon sublocation ID: \(sublocationId)")
524 // [swift_Beacon_getSublocationId]
526 // [swift_Beacon_getName]
528 let beaconName = beacon.getName()
529 print("Beacon name: \(beaconName ?? "nil")")
530 // [swift_Beacon_getName]
532 // [swift_Beacon_getMajor]
534 let major = beacon.getMajor()
535 print("Beacon major: \(major)")
536 // [swift_Beacon_getMajor]
538 // [swift_Beacon_getMinor]
540 let minor = beacon.getMinor()
541 print("Beacon minor: \(minor)")
542 // [swift_Beacon_getMinor]
544 // [swift_Beacon_getUuid]
546 let uuid = beacon.getUuid()
547 print("Beacon UUID: \(uuid ?? "nil")")
548 // [swift_Beacon_getUuid]
550 // [swift_Beacon_getPower]
552 let power = beacon.getPower()
553 if let power = power {
554 print("Beacon power: \(power)")
556 // [swift_Beacon_getPower]
558 // [swift_Beacon_getStatus]
560 let status = beacon.getStatus()
561 print("Beacon status: \(status)")
562 // [swift_Beacon_getStatus]
566 * Demonstrate Wifi class methods
568 func demonstrateWifiUsage(_ wifi: NCWifi) {
569 // [swift_Wifi_getPoint]
571 let point = wifi.getPoint()
572 if let point = point {
573 demonstratePointUsage(point)
575 // [swift_Wifi_getPoint]
577 // [swift_Wifi_getLocationId]
578 // Get WiFi location ID
579 let locationId = wifi.getLocationId()
580 print("WiFi location ID: \(locationId)")
581 // [swift_Wifi_getLocationId]
583 // [swift_Wifi_getSublocationId]
584 // Get WiFi sublocation ID
585 let sublocationId = wifi.getSublocationId()
586 print("WiFi sublocation ID: \(sublocationId)")
587 // [swift_Wifi_getSublocationId]
589 // [swift_Wifi_getName]
591 let wifiName = wifi.getName()
592 print("WiFi name: \(wifiName ?? "nil")")
593 // [swift_Wifi_getName]
595 // [swift_Wifi_getMac]
596 // Get WiFi MAC address
597 let mac = wifi.getMac()
598 print("WiFi MAC: \(mac ?? "nil")")
599 // [swift_Wifi_getMac]
601 // [swift_Wifi_getStatus]
603 let status = wifi.getStatus()
604 print("WiFi status: \(status)")
605 // [swift_Wifi_getStatus]
609 * Demonstrate Eddystone class methods
611 func demonstrateEddystoneUsage(_ eddystone: NCEddystone) {
612 // [swift_Eddystone_getPoint]
613 // Get Eddystone point
614 let point = eddystone.getPoint()
615 if let point = point {
616 demonstratePointUsage(point)
618 // [swift_Eddystone_getPoint]
620 // [swift_Eddystone_getLocationId]
621 // Get Eddystone location ID
622 let locationId = eddystone.getLocationId()
623 print("Eddystone location ID: \(locationId)")
624 // [swift_Eddystone_getLocationId]
626 // [swift_Eddystone_getSublocationId]
627 // Get Eddystone sublocation ID
628 let sublocationId = eddystone.getSublocationId()
629 print("Eddystone sublocation ID: \(sublocationId)")
630 // [swift_Eddystone_getSublocationId]
632 // [swift_Eddystone_getName]
633 // Get Eddystone name
634 let eddystoneName = eddystone.getName()
635 print("Eddystone name: \(eddystoneName ?? "nil")")
636 // [swift_Eddystone_getName]
638 // [swift_Eddystone_getNamespaceId]
639 // Get Eddystone namespace ID
640 let namespaceId = eddystone.getNamespaceId()
641 print("Eddystone namespace ID: \(namespaceId ?? "nil")")
642 // [swift_Eddystone_getNamespaceId]
644 // [swift_Eddystone_getInstanceId]
645 // Get Eddystone instance ID
646 let instanceId = eddystone.getInstanceId()
647 print("Eddystone instance ID: \(instanceId ?? "nil")")
648 // [swift_Eddystone_getInstanceId]
650 // [swift_Eddystone_getPower]
651 // Get Eddystone power
652 let power = eddystone.getPower()
653 if let power = power {
654 print("Eddystone power: \(power)")
656 // [swift_Eddystone_getPower]
658 // [swift_Eddystone_getStatus]
659 // Get Eddystone status
660 let status = eddystone.getStatus()
661 print("Eddystone status: \(status)")
662 // [swift_Eddystone_getStatus]
666 * Demonstrate Point class methods
668 func demonstratePointUsage(_ point: NCPoint) {
669 // [swift_Point_getX]
672 print("Point X: \(x)")
673 // [swift_Point_getX]
675 // [swift_Point_getY]
678 print("Point Y: \(y)")
679 // [swift_Point_getY]
683 * Demonstrate Graph class methods
685 func demonstrateGraphUsage(_ graph: NCGraph) {
686 // [swift_Graph_getVertices]
687 // Get graph vertices
688 let vertices = graph.getVertices()
689 print("Number of graph vertices: \(vertices.count)")
690 // [swift_Graph_getVertices]
692 // [swift_Graph_getEdges]
694 let edges = graph.getEdges()
695 print("Number of graph edges: \(edges.count)")
696 // [swift_Graph_getEdges]
700 * Demonstrate GraphVertex class methods
702 func demonstrateGraphVertexUsage(_ vertex: NCGraphVertex) {
703 // [swift_GraphVertex_getId]
705 let vertexId = vertex.getId()
706 print("Vertex ID: \(vertexId)")
707 // [swift_GraphVertex_getId]
709 // [swift_GraphVertex_getPoint]
711 let point = vertex.getPoint()
712 if let point = point {
713 demonstratePointUsage(point)
715 // [swift_GraphVertex_getPoint]
717 // [swift_GraphVertex_getName]
719 let name = vertex.getName()
720 print("Vertex name: \(name ?? "nil")")
721 // [swift_GraphVertex_getName]
723 // [swift_GraphVertex_getIsExternal]
724 // Get vertex external flag
725 let isExternal = vertex.getIsExternal()
726 print("Vertex is external: \(isExternal)")
727 // [swift_GraphVertex_getIsExternal]
729 // [swift_GraphVertex_getIsElevation]
730 // Get vertex elevation flag
731 let isElevation = vertex.getIsElevation()
732 print("Vertex is elevation: \(isElevation)")
733 // [swift_GraphVertex_getIsElevation]
737 * Demonstrate GraphEdge class methods
739 func demonstrateGraphEdgeUsage(_ edge: NCGraphEdge) {
740 // [swift_GraphEdge_getWeight]
742 let weight = edge.getWeight()
743 print("Edge weight: \(weight)")
744 // [swift_GraphEdge_getWeight]
746 // [swift_GraphEdge_getDst]
747 // Get destination vertex ID
748 let dst = edge.getDst()
749 print("Edge destination ID: \(dst)")
750 // [swift_GraphEdge_getDst]
752 // [swift_GraphEdge_getSrc]
753 // Get source vertex ID
754 let src = edge.getSrc()
755 print("Edge source ID: \(src)")
756 // [swift_GraphEdge_getSrc]
758 // [swift_GraphEdge_getWeightCoef]
759 // Get edge weight coefficient
760 let weightCoef = edge.getWeightCoef()
761 print("Edge weight coefficient: \(weightCoef)")
762 // [swift_GraphEdge_getWeightCoef]
766 * Demonstrate ElevationGraph class methods
768 func demonstrateElevationGraphUsage(_ elevationGraph: NCElevationGraph) {
769 // [swift_ElevationGraph_getEdges]
770 // Get elevation graph edges
771 let edges = elevationGraph.getEdges()
772 print("Number of elevation graph edges: \(edges.count)")
774 // Demonstrate each edge
775 for (index, edge) in edges.enumerated() {
776 print("Elevation graph edge \(index + 1):")
777 demonstrateGraphEdgeUsage(edge)
779 // [swift_ElevationGraph_getEdges]
783 * Demonstrate TransmitterStatus enum
785 func demonstrateTransmitterStatus() {
786 // [swift_TransmitterStatus_values]
787 // Get all transmitter status values
788 print("Available transmitter statuses:")
789 print(" - NCTransmitterStatusActive: \(NCTransmitterStatusActive)")
790 print(" - NCTransmitterStatusInactive: \(NCTransmitterStatusInactive)")
791 // [swift_TransmitterStatus_values]
798 if let manager = locationManager {
799 // [swift_LocationManager_removeLocationListener]
800 // Remove location listener
801 manager.removeLocationListener(self)
802 // [swift_LocationManager_removeLocationListener]
807 * Main demonstration method
810 print("=== LocationManager Example ===")
812 demonstrateLocationManagerMethods()
813 demonstrateTransmitterStatus()
815 // Wait a bit for location to load
816 Thread.sleep(forTimeInterval: 2.0)
819 print("=== Example completed ===")
823// MARK: - NCLocationListener
825extension LocationManagerExample {
826 // [swift_LocationListener_onLocationLoaded]
827 func onLocationLoaded(_ location: NCLocation?) {
828 print("Location loaded successfully")
829 currentLocation = location
830 if let location = location {
831 demonstrateLocationUsage(location)
834 // [swift_LocationListener_onLocationLoaded]
836 // [swift_LocationListener_onLocationUploaded]
837 func onLocationUploaded(_ locationId: Int32) {
838 print("Location uploaded: \(locationId)")
840 // [swift_LocationListener_onLocationUploaded]
842 // [swift_LocationListener_onLocationFailed]
843 func onLocationFailed(_ locationId: Int32, error: Error?) {
844 print("Failed to load location \(locationId): \(error?.localizedDescription ?? "Unknown error")")
846 // [swift_LocationListener_onLocationFailed]
850 * Function to run the example
853 let example = LocationManagerExample()