Loading...
Searching...
No Matches
NavigineSdkExample.m
Go to the documentation of this file.
1#import <Foundation/Foundation.h>
2#import "NCNavigineSdk.h"
3#import "NCLocationManager.h"
4#import "NCNavigationManager.h"
5#import "NCZoneManager.h"
6#import "NCRouteManager.h"
7#import "NCAsyncRouteManager.h"
8#import "NCNotificationManager.h"
9#import "NCMeasurementManager.h"
10#import "NCLocationListManager.h"
11#import "NCLocationWindow.h"
12
17@interface NavigineSdkExample : NSObject
18
19@property (nonatomic, strong) NCNavigineSdk *sdk;
20@property (nonatomic, strong) NCLocationManager *locationManager;
21@property (nonatomic, strong) NCNavigationManager *navigationManager;
22@property (nonatomic, strong) NCZoneManager *zoneManager;
23@property (nonatomic, strong) NCRouteManager *routeManager;
24@property (nonatomic, strong) NCAsyncRouteManager *asyncRouteManager;
25@property (nonatomic, strong) NCNotificationManager *notificationManager;
26@property (nonatomic, strong) NCMeasurementManager *measurementManager;
27@property (nonatomic, strong) NCLocationListManager *locationListManager;
28@property (nonatomic, strong) NCStorageManager *storageManager;
29
30- (void)initializeSdk;
31- (void)initializeManagers;
33- (void)printSdkInfo;
34- (void)demonstrateManagersUsage;
35- (void)runExample;
36
37@end
38
39@implementation NavigineSdkExample
40
41- (instancetype)init {
42 self = [super init];
43 if (self) {
44 [self initializeSdk];
45 }
46 return self;
47}
48
52 - (void)initializeSdk {
53 @try {
54 // [objc_NavigineSdk_getInstance]
55 // Get SDK instance
56 self.sdk = [NCNavigineSdk getInstance];
57 // [objc_NavigineSdk_getInstance]
58
59 if (!self.sdk) {
60 NSLog(@"Error: failed to get NavigineSdk instance");
61 return;
62 }
63
64 // [objc_NavigineSdk_getVersion]
65 // Get SDK version
66 NSLog(@"Navigine SDK Version: %@", [NCNavigineSdk getVersion]);
67 // [objc_NavigineSdk_getVersion]
68
69 // [objc_NavigineSdk_getDeviceId]
70 // Get device ID
71 NSLog(@"Device ID: %@", [NCNavigineSdk getDeviceId]);
72 // [objc_NavigineSdk_getDeviceId]
73
74 // [objc_NavigineSdk_getRelativeTime]
75 // Get relative time
76 NSLog(@"Relative Time: %lld", [NCNavigineSdk getRelativeTime]);
77 // [objc_NavigineSdk_getRelativeTime]
78
79 // [objc_NavigineSdk_setUserHash]
80 // Set user hash (authorization token)
81 [self.sdk setUserHash:@"XXXX-XXXX-XXXX-XXXX"];
82 // [objc_NavigineSdk_setUserHash]
83
84 // [objc_NavigineSdk_setServer]
85 // Set server URL (optional)
86 [self.sdk setServer:@"https://custom.navigine.com"];
87 // [objc_NavigineSdk_setServer]
88
89 // Initialize managers
90 [self initializeManagers];
91
92 } @catch (NSException *exception) {
93 NSLog(@"SDK initialization error: %@", exception.reason);
94 }
95 }
96
101 // [objc_NavigineSdk_getLocationManager]
102 // Get LocationManager for working with locations
103 self.locationManager = [self.sdk getLocationManager];
104 if (self.locationManager) {
105 NSLog(@"LocationManager successfully initialized");
106 }
107 // [objc_NavigineSdk_getLocationManager]
108
109 // [objc_NavigineSdk_getNavigationManager]
110 // Get NavigationManager for navigation
111 if (self.locationManager) {
112 self.navigationManager = [self.sdk getNavigationManager:self.locationManager];
113 if (self.navigationManager) {
114 NSLog(@"NavigationManager successfully initialized");
115 }
116 }
117 // [objc_NavigineSdk_getNavigationManager]
118
119 // [objc_NavigineSdk_getZoneManager]
120 // Get ZoneManager for working with zones
121 if (self.navigationManager) {
122 self.zoneManager = [self.sdk getZoneManager:self.navigationManager];
123 if (self.zoneManager) {
124 NSLog(@"ZoneManager successfully initialized");
125 }
126 }
127 // [objc_NavigineSdk_getZoneManager]
128
129 // [objc_NavigineSdk_getRouteManager]
130 // Get RouteManager for building routes
131 if (self.locationManager && self.navigationManager) {
132 self.routeManager = [self.sdk getRouteManager:self.locationManager
133 navigationManager:self.navigationManager];
134 if (self.routeManager) {
135 NSLog(@"RouteManager successfully initialized");
136 }
137 }
138 // [objc_NavigineSdk_getRouteManager]
139
140 // [objc_NavigineSdk_getAsyncRouteManager]
141 // Get AsyncRouteManager for async route operations
142 if (self.locationManager && self.navigationManager) {
143 self.asyncRouteManager = [self.sdk getAsyncRouteManager:self.locationManager
144 navigationManager:self.navigationManager];
145 if (self.asyncRouteManager) {
146 NSLog(@"AsyncRouteManager successfully initialized");
147 }
148 }
149 // [objc_NavigineSdk_getAsyncRouteManager]
150
151 // [objc_NavigineSdk_getNotificationManager]
152 // Get NotificationManager for notifications
153 if (self.locationManager) {
154 self.notificationManager = [self.sdk getNotificationManager:self.locationManager];
155 if (self.notificationManager) {
156 NSLog(@"NotificationManager successfully initialized");
157 }
158 }
159 // [objc_NavigineSdk_getNotificationManager]
160
161 // [objc_NavigineSdk_getMeasurementManager]
162 // Get MeasurementManager for measurements
163 if (self.locationManager) {
164 self.measurementManager = [self.sdk getMeasurementManager:self.locationManager];
165 if (self.measurementManager) {
166 NSLog(@"MeasurementManager successfully initialized");
167 }
168 }
169 // [objc_NavigineSdk_getMeasurementManager]
170
171 // [objc_NavigineSdk_getLocationListManager]
172 // Get LocationListManager for location list operations
173 self.locationListManager = [self.sdk getLocationListManager];
174 if (self.locationListManager) {
175 NSLog(@"LocationListManager successfully initialized");
176 }
177 // [objc_NavigineSdk_getLocationListManager]
178
179 // [objc_NavigineSdk_getStorageManager]
180 // Get StorageManager for working with storages
181 self.storageManager = [self.sdk getStorageManager];
182 if (self.storageManager) {
183 NSLog(@"StorageManager successfully initialized");
184 }
185 // [objc_NavigineSdk_getStorageManager]
186 }
187
191 - (void)printSdkInfo {
192 NSLog(@"=== Navigine SDK Information ===");
193 NSLog(@"SDK Version: %@", [NCNavigineSdk getVersion]);
194 NSLog(@"Device ID: %@", [NCNavigineSdk getDeviceId]);
195 NSLog(@"Relative Time: %lld", [NCNavigineSdk getRelativeTime]);
196 NSLog(@"LocationManager: %@", self.locationManager ? @"available" : @"unavailable");
197 NSLog(@"NavigationManager: %@", self.navigationManager ? @"available" : @"unavailable");
198 NSLog(@"ZoneManager: %@", self.zoneManager ? @"available" : @"unavailable");
199 NSLog(@"RouteManager: %@", self.routeManager ? @"available" : @"unavailable");
200 NSLog(@"AsyncRouteManager: %@", self.asyncRouteManager ? @"available" : @"unavailable");
201 NSLog(@"NotificationManager: %@", self.notificationManager ? @"available" : @"unavailable");
202 NSLog(@"MeasurementManager: %@", self.measurementManager ? @"available" : @"unavailable");
203 NSLog(@"LocationListManager: %@", self.locationListManager ? @"available" : @"unavailable");
204 NSLog(@"StorageManager: %@", self.storageManager ? @"available" : @"unavailable");
205 }
206
210 - (void)demonstrateManagersUsage {
211 NSLog(@"=== Manager Usage Demonstration ===");
212
213 // LocationManager usage example
214 if (self.locationManager) {
215 NSLog(@"LocationManager ready for location operations");
216 // Add code here for loading locations, working with them, etc.
217 }
218
219 // NavigationManager usage example
220 if (self.navigationManager) {
221 NSLog(@"NavigationManager ready for positioning");
222 // Add code here for getting position, setting up listeners, etc.
223 }
224
225 // ZoneManager usage example
226 if (self.zoneManager) {
227 NSLog(@"ZoneManager ready for zone operations");
228 // Add code here for setting up zones, handling enter/exit events, etc.
229 }
230
231 // RouteManager usage example
232 if (self.routeManager) {
233 NSLog(@"RouteManager ready for route building");
234 // Add code here for building routes, setting destination points, etc.
235 }
236
237 // AsyncRouteManager usage example
238 if (self.asyncRouteManager) {
239 NSLog(@"AsyncRouteManager ready for async route operations");
240 // Add code here for creating routing sessions, etc.
241 }
242
243 // NotificationManager usage example
244 if (self.notificationManager) {
245 NSLog(@"NotificationManager ready for notifications");
246 // Add code here for setting up beacon notifications, etc.
247 }
248
249 // MeasurementManager usage example
250 if (self.measurementManager) {
251 NSLog(@"MeasurementManager ready for measurements");
252 // Add code here for managing measurement generators, etc.
253 }
254
255 // LocationListManager usage example
256 if (self.locationListManager) {
257 NSLog(@"LocationListManager ready for location list operations");
258 // Add code here for getting available locations list, etc.
259 }
260
261 // StorageManager usage example
262 if (self.storageManager) {
263 NSLog(@"StorageManager ready for storage operations");
264 // Add code here for creating storages, managing data, etc.
265 }
266 }
267
271 - (void)demonstrateObjectiveCFeatures {
272 NSLog(@"=== Objective-C Features Demonstration ===");
273
274 // Using blocks for async operations
275 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
276 // Async operation
277 dispatch_async(dispatch_get_main_queue(), ^{
278 NSLog(@"Async operation completed");
279 });
280 });
281
282 // Using KVO (Key-Value Observing) - example
283 [self addObserver:self forKeyPath:@"locationManager" options:NSKeyValueObservingOptionNew context:nil];
284
285 // Using categories (if they were defined)
286 // [self.sdk performCustomOperation];
287
288 // Using selectors
289 SEL selector = @selector(printSdkInfo);
290 if ([self respondsToSelector:selector]) {
291 [self performSelector:selector];
292 }
293 }
294
298 - (void)observeValueForKeyPath:(NSString *)keyPath
299 ofObject:(id)object
300 change:(NSDictionary<NSKeyValueChangeKey,id> *)change
301 context:(void *)context {
302 if ([keyPath isEqualToString:@"locationManager"]) {
303 NSLog(@"LocationManager changed");
304 }
305 }
306
310 - (void)runExample {
311 [self printSdkInfo];
312 [self demonstrateManagersUsage];
313 [self demonstrateObjectiveCFeatures];
314 }
315
316- (void)dealloc {
317 [self removeObserver:self forKeyPath:@"locationManager"];
318}
319
320@end
321
325int main(int argc, const char * argv[]) {
326 @autoreleasepool {
327 NavigineSdkExample *example = [[NavigineSdkExample alloc] init];
328 [example runExample];
329 }
330 return 0;
331}