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_getReferencePoints]
276 // Get reference points
277 let referencePoints = sublocation.getReferencePoints()
278 print("Number of reference points: \(referencePoints.count)")
279 // [swift_Sublocation_getReferencePoints]
281 // [swift_Sublocation_getVenues]
283 let venues = sublocation.getVenues()
284 print("Number of venues: \(venues.count)")
285 // [swift_Sublocation_getVenues]
287 // [swift_Sublocation_getZones]
289 let zones = sublocation.getZones()
290 print("Number of zones: \(zones.count)")
291 // [swift_Sublocation_getZones]
293 // [swift_Sublocation_getBeacons]
295 let beacons = sublocation.getBeacons()
296 print("Number of beacons: \(beacons.count)")
297 // [swift_Sublocation_getBeacons]
299 // [swift_Sublocation_getWifis]
300 // Get WiFi access points
301 let wifis = sublocation.getWifis()
302 print("Number of WiFi access points: \(wifis.count)")
303 // [swift_Sublocation_getWifis]
305 // [swift_Sublocation_getEddystones]
306 // Get Eddystone beacons
307 let eddystones = sublocation.getEddystones()
308 print("Number of Eddystone beacons: \(eddystones.count)")
309 // [swift_Sublocation_getEddystones]
311 // [swift_Sublocation_getGraph]
313 let graph = sublocation.getGraph()
314 if let graph = graph {
315 demonstrateGraphUsage(graph)
317 // [swift_Sublocation_getGraph]
319 // [swift_Sublocation_getGraph_withTag]
321 if let graphByTag = sublocation.getGraph("main") {
322 print("Found graph with tag \"main\"")
323 demonstrateGraphUsage(graphByTag)
325 // [swift_Sublocation_getGraph_withTag]
327 // [swift_Sublocation_getVenueById]
330 if let venueById = sublocation.getVenueById(venues.first!.getId()) {
331 print("Found venue by ID: \(venueById.getId())")
332 demonstrateVenueUsage(venueById)
335 // [swift_Sublocation_getVenueById]
337 // [swift_Sublocation_getZoneById]
340 if let zoneById = sublocation.getZoneById(zones.first!.getId()) {
341 print("Found zone by ID: \(zoneById.getId())")
342 demonstrateZoneUsage(zoneById)
345 // [swift_Sublocation_getZoneById]
347 // [swift_Sublocation_globalToLocal]
348 // Convert global coordinates to local coordinates
349 let globalPoint = NCGlobalPoint(lat: 55.7558, lon: 37.6176) // Moscow coordinates
350 let localPoint = sublocation.globalToLocal(globalPoint)
351 print("Global point \(globalPoint.getLat()), \(globalPoint.getLon()) converted to local: \(localPoint.getX()), \(localPoint.getY())")
352 // [swift_Sublocation_globalToLocal]
354 // [swift_Sublocation_localToGlobal]
355 // Convert local coordinates to global coordinates
356 let localPoint2 = NCLocationPoint(x: 100.0, y: 200.0)
357 let globalPoint2 = sublocation.localToGlobal(localPoint2)
358 print("Local point \(localPoint2.getX()), \(localPoint2.getY()) converted to global: \(globalPoint2.getLat()), \(globalPoint2.getLon())")
359 // [swift_Sublocation_localToGlobal]
361 // [swift_Sublocation_getImage]
362 // Get sublocation image
363 if let image = sublocation.getImage(1024) { // max texture size 1024
364 print("Sublocation image obtained with max texture size 1024")
366 // [swift_Sublocation_getImage]
370 * Demonstrate Venue class methods
372 func demonstrateVenueUsage(_ venue: NCVenue) {
373 // [swift_Venue_getId]
375 let venueId = venue.getId()
376 print("Venue ID: \(venueId)")
377 // [swift_Venue_getId]
379 // [swift_Venue_getLocationId]
380 // Get venue location ID
381 let locationId = venue.getLocationId()
382 print("Venue location ID: \(locationId)")
383 // [swift_Venue_getLocationId]
385 // [swift_Venue_getSublocationId]
386 // Get venue sublocation ID
387 let sublocationId = venue.getSublocationId()
388 print("Venue sublocation ID: \(sublocationId)")
389 // [swift_Venue_getSublocationId]
391 // [swift_Venue_getName]
393 let venueName = venue.getName()
394 print("Venue name: \(venueName ?? "nil")")
395 // [swift_Venue_getName]
397 // [swift_Venue_getPhone]
399 let phone = venue.getPhone()
400 print("Venue phone: \(phone ?? "nil")")
401 // [swift_Venue_getPhone]
403 // [swift_Venue_getDescript]
404 // Get venue description
405 let venueDescription = venue.getDescript()
406 print("Venue description: \(venueDescription ?? "nil")")
407 // [swift_Venue_getDescript]
409 // [swift_Venue_getAlias]
411 let alias = venue.getAlias()
412 print("Venue alias: \(alias ?? "nil")")
413 // [swift_Venue_getAlias]
415 // [swift_Venue_getCategoryId]
417 let categoryId = venue.getCategoryId()
418 print("Venue category ID: \(categoryId)")
419 // [swift_Venue_getCategoryId]
421 // [swift_Venue_getImageUrl]
422 // Get venue image URL
423 if let imageUrl = venue.getImageUrl() {
424 print("Venue image URL: \(imageUrl)")
426 // [swift_Venue_getImageUrl]
428 // [swift_Venue_getPoint]
430 let point = venue.getPoint()
431 if let point = point {
432 demonstratePointUsage(point)
434 // [swift_Venue_getPoint]
438 * Demonstrate Zone class methods
440 func demonstrateZoneUsage(_ zone: NCZone) {
441 // [swift_Zone_getId]
443 let zoneId = zone.getId()
444 print("Zone ID: \(zoneId)")
445 // [swift_Zone_getId]
447 // [swift_Zone_getLocationId]
448 // Get zone location ID
449 let locationId = zone.getLocationId()
450 print("Zone location ID: \(locationId)")
451 // [swift_Zone_getLocationId]
453 // [swift_Zone_getSublocationId]
454 // Get zone sublocation ID
455 let sublocationId = zone.getSublocationId()
456 print("Zone sublocation ID: \(sublocationId)")
457 // [swift_Zone_getSublocationId]
459 // [swift_Zone_getName]
461 let zoneName = zone.getName()
462 print("Zone name: \(zoneName ?? "nil")")
463 // [swift_Zone_getName]
465 // [swift_Zone_getDescript]
466 // Get zone description
467 let zoneDescription = zone.getDescript()
468 print("Zone description: \(zoneDescription ?? "nil")")
469 // [swift_Zone_getDescript]
471 // [swift_Zone_getCategoryId]
473 let categoryId = zone.getCategoryId()
474 print("Zone category ID: \(categoryId)")
475 // [swift_Zone_getCategoryId]
477 // [swift_Zone_getAlias]
479 let alias = zone.getAlias()
480 print("Zone alias: \(alias ?? "nil")")
481 // [swift_Zone_getAlias]
483 // [swift_Zone_getColor]
485 let color = zone.getColor()
486 print("Zone color: \(color ?? "nil")")
487 // [swift_Zone_getColor]
489 // [swift_Zone_getPolygon]
491 let polygon = zone.getPolygon()
492 print("Zone polygon points: \(polygon.count)")
493 // [swift_Zone_getPolygon]
497 * Demonstrate Beacon class methods
499 func demonstrateBeaconUsage(_ beacon: NCBeacon) {
500 // [swift_Beacon_getPoint]
502 let point = beacon.getPoint()
503 if let point = point {
504 demonstratePointUsage(point)
506 // [swift_Beacon_getPoint]
508 // [swift_Beacon_getLocationId]
509 // Get beacon location ID
510 let locationId = beacon.getLocationId()
511 print("Beacon location ID: \(locationId)")
512 // [swift_Beacon_getLocationId]
514 // [swift_Beacon_getSublocationId]
515 // Get beacon sublocation ID
516 let sublocationId = beacon.getSublocationId()
517 print("Beacon sublocation ID: \(sublocationId)")
518 // [swift_Beacon_getSublocationId]
520 // [swift_Beacon_getName]
522 let beaconName = beacon.getName()
523 print("Beacon name: \(beaconName ?? "nil")")
524 // [swift_Beacon_getName]
526 // [swift_Beacon_getMajor]
528 let major = beacon.getMajor()
529 print("Beacon major: \(major)")
530 // [swift_Beacon_getMajor]
532 // [swift_Beacon_getMinor]
534 let minor = beacon.getMinor()
535 print("Beacon minor: \(minor)")
536 // [swift_Beacon_getMinor]
538 // [swift_Beacon_getUuid]
540 let uuid = beacon.getUuid()
541 print("Beacon UUID: \(uuid ?? "nil")")
542 // [swift_Beacon_getUuid]
544 // [swift_Beacon_getPower]
546 let power = beacon.getPower()
547 if let power = power {
548 print("Beacon power: \(power)")
550 // [swift_Beacon_getPower]
552 // [swift_Beacon_getStatus]
554 let status = beacon.getStatus()
555 print("Beacon status: \(status)")
556 // [swift_Beacon_getStatus]
560 * Demonstrate Wifi class methods
562 func demonstrateWifiUsage(_ wifi: NCWifi) {
563 // [swift_Wifi_getPoint]
565 let point = wifi.getPoint()
566 if let point = point {
567 demonstratePointUsage(point)
569 // [swift_Wifi_getPoint]
571 // [swift_Wifi_getLocationId]
572 // Get WiFi location ID
573 let locationId = wifi.getLocationId()
574 print("WiFi location ID: \(locationId)")
575 // [swift_Wifi_getLocationId]
577 // [swift_Wifi_getSublocationId]
578 // Get WiFi sublocation ID
579 let sublocationId = wifi.getSublocationId()
580 print("WiFi sublocation ID: \(sublocationId)")
581 // [swift_Wifi_getSublocationId]
583 // [swift_Wifi_getName]
585 let wifiName = wifi.getName()
586 print("WiFi name: \(wifiName ?? "nil")")
587 // [swift_Wifi_getName]
589 // [swift_Wifi_getMac]
590 // Get WiFi MAC address
591 let mac = wifi.getMac()
592 print("WiFi MAC: \(mac ?? "nil")")
593 // [swift_Wifi_getMac]
595 // [swift_Wifi_getStatus]
597 let status = wifi.getStatus()
598 print("WiFi status: \(status)")
599 // [swift_Wifi_getStatus]
603 * Demonstrate Eddystone class methods
605 func demonstrateEddystoneUsage(_ eddystone: NCEddystone) {
606 // [swift_Eddystone_getPoint]
607 // Get Eddystone point
608 let point = eddystone.getPoint()
609 if let point = point {
610 demonstratePointUsage(point)
612 // [swift_Eddystone_getPoint]
614 // [swift_Eddystone_getLocationId]
615 // Get Eddystone location ID
616 let locationId = eddystone.getLocationId()
617 print("Eddystone location ID: \(locationId)")
618 // [swift_Eddystone_getLocationId]
620 // [swift_Eddystone_getSublocationId]
621 // Get Eddystone sublocation ID
622 let sublocationId = eddystone.getSublocationId()
623 print("Eddystone sublocation ID: \(sublocationId)")
624 // [swift_Eddystone_getSublocationId]
626 // [swift_Eddystone_getName]
627 // Get Eddystone name
628 let eddystoneName = eddystone.getName()
629 print("Eddystone name: \(eddystoneName ?? "nil")")
630 // [swift_Eddystone_getName]
632 // [swift_Eddystone_getNamespaceId]
633 // Get Eddystone namespace ID
634 let namespaceId = eddystone.getNamespaceId()
635 print("Eddystone namespace ID: \(namespaceId ?? "nil")")
636 // [swift_Eddystone_getNamespaceId]
638 // [swift_Eddystone_getInstanceId]
639 // Get Eddystone instance ID
640 let instanceId = eddystone.getInstanceId()
641 print("Eddystone instance ID: \(instanceId ?? "nil")")
642 // [swift_Eddystone_getInstanceId]
644 // [swift_Eddystone_getPower]
645 // Get Eddystone power
646 let power = eddystone.getPower()
647 if let power = power {
648 print("Eddystone power: \(power)")
650 // [swift_Eddystone_getPower]
652 // [swift_Eddystone_getStatus]
653 // Get Eddystone status
654 let status = eddystone.getStatus()
655 print("Eddystone status: \(status)")
656 // [swift_Eddystone_getStatus]
660 * Demonstrate Point class methods
662 func demonstratePointUsage(_ point: NCPoint) {
663 // [swift_Point_getX]
666 print("Point X: \(x)")
667 // [swift_Point_getX]
669 // [swift_Point_getY]
672 print("Point Y: \(y)")
673 // [swift_Point_getY]
677 * Demonstrate Graph class methods
679 func demonstrateGraphUsage(_ graph: NCGraph) {
680 // [swift_Graph_getVertices]
681 // Get graph vertices
682 let vertices = graph.getVertices()
683 print("Number of graph vertices: \(vertices.count)")
684 // [swift_Graph_getVertices]
686 // [swift_Graph_getEdges]
688 let edges = graph.getEdges()
689 print("Number of graph edges: \(edges.count)")
690 // [swift_Graph_getEdges]
694 * Demonstrate GraphVertex class methods
696 func demonstrateGraphVertexUsage(_ vertex: NCGraphVertex) {
697 // [swift_GraphVertex_getId]
699 let vertexId = vertex.getId()
700 print("Vertex ID: \(vertexId)")
701 // [swift_GraphVertex_getId]
703 // [swift_GraphVertex_getPoint]
705 let point = vertex.getPoint()
706 if let point = point {
707 demonstratePointUsage(point)
709 // [swift_GraphVertex_getPoint]
711 // [swift_GraphVertex_getName]
713 let name = vertex.getName()
714 print("Vertex name: \(name ?? "nil")")
715 // [swift_GraphVertex_getName]
717 // [swift_GraphVertex_getIsExternal]
718 // Get vertex external flag
719 let isExternal = vertex.getIsExternal()
720 print("Vertex is external: \(isExternal)")
721 // [swift_GraphVertex_getIsExternal]
723 // [swift_GraphVertex_getIsElevation]
724 // Get vertex elevation flag
725 let isElevation = vertex.getIsElevation()
726 print("Vertex is elevation: \(isElevation)")
727 // [swift_GraphVertex_getIsElevation]
731 * Demonstrate GraphEdge class methods
733 func demonstrateGraphEdgeUsage(_ edge: NCGraphEdge) {
734 // [swift_GraphEdge_getWeight]
736 let weight = edge.getWeight()
737 print("Edge weight: \(weight)")
738 // [swift_GraphEdge_getWeight]
740 // [swift_GraphEdge_getDst]
741 // Get destination vertex ID
742 let dst = edge.getDst()
743 print("Edge destination ID: \(dst)")
744 // [swift_GraphEdge_getDst]
746 // [swift_GraphEdge_getSrc]
747 // Get source vertex ID
748 let src = edge.getSrc()
749 print("Edge source ID: \(src)")
750 // [swift_GraphEdge_getSrc]
752 // [swift_GraphEdge_getWeightCoef]
753 // Get edge weight coefficient
754 let weightCoef = edge.getWeightCoef()
755 print("Edge weight coefficient: \(weightCoef)")
756 // [swift_GraphEdge_getWeightCoef]
760 * Demonstrate ElevationGraph class methods
762 func demonstrateElevationGraphUsage(_ elevationGraph: NCElevationGraph) {
763 // [swift_ElevationGraph_getEdges]
764 // Get elevation graph edges
765 let edges = elevationGraph.getEdges()
766 print("Number of elevation graph edges: \(edges.count)")
768 // Demonstrate each edge
769 for (index, edge) in edges.enumerated() {
770 print("Elevation graph edge \(index + 1):")
771 demonstrateGraphEdgeUsage(edge)
773 // [swift_ElevationGraph_getEdges]
777 * Demonstrate TransmitterStatus enum
779 func demonstrateTransmitterStatus() {
780 // [swift_TransmitterStatus_values]
781 // Get all transmitter status values
782 print("Available transmitter statuses:")
783 print(" - NCTransmitterStatusActive: \(NCTransmitterStatusActive)")
784 print(" - NCTransmitterStatusInactive: \(NCTransmitterStatusInactive)")
785 // [swift_TransmitterStatus_values]
792 if let manager = locationManager {
793 // [swift_LocationManager_removeLocationListener]
794 // Remove location listener
795 manager.removeLocationListener(self)
796 // [swift_LocationManager_removeLocationListener]
801 * Main demonstration method
804 print("=== LocationManager Example ===")
806 demonstrateLocationManagerMethods()
807 demonstrateTransmitterStatus()
809 // Wait a bit for location to load
810 Thread.sleep(forTimeInterval: 2.0)
813 print("=== Example completed ===")
817// MARK: - NCLocationListener
819extension LocationManagerExample {
820 // [swift_LocationListener_onLocationLoaded]
821 func onLocationLoaded(_ location: NCLocation?) {
822 print("Location loaded successfully")
823 currentLocation = location
824 if let location = location {
825 demonstrateLocationUsage(location)
828 // [swift_LocationListener_onLocationLoaded]
830 // [swift_LocationListener_onLocationUploaded]
831 func onLocationUploaded(_ locationId: Int32) {
832 print("Location uploaded: \(locationId)")
834 // [swift_LocationListener_onLocationUploaded]
836 // [swift_LocationListener_onLocationFailed]
837 func onLocationFailed(_ locationId: Int32, error: Error?) {
838 print("Failed to load location \(locationId): \(error?.localizedDescription ?? "Unknown error")")
840 // [swift_LocationListener_onLocationFailed]
844 * Function to run the example
847 let example = LocationManagerExample()