ZIP File for SkyGolfKit Library consists of:
includes/ Directory with SkyGolfKit Headers-ObjC -all_load directives to Build Settings -> Other Linker Flags SectionBuild Phases -> Link Binary with Libraries Phase add CoreBluetooth.frameworkSomewhere in your App’s source (for example, in .PCH File or in AppDelegate), add:
#import <SkyGolfKit/SkyGolfKit.h>
In AppDelegate’s - (BOOL)application:didFinishLaunchingWithOptions: add lines like below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SGCore activate:@"" error:nil];
});
return YES;
}
This will activate SkyGolfKit’s Core and required Modules in it.
You can subscribe to Device Discovered Event like below:
[[SGBluetoothService sharedInstance] listenAlways:kSGKEventDeviceDiscovered
selector:@selector(devicesListUpdated:)
target:self];
where kSGKEventDeviceDiscovered is the predefined Event Name. More details about definitions you can find in SkyGolfKitDefinitions.h Header in bundle.
Full list of discovered Devices is available with call:
[SGBluetoothService sharedInstance].devices
NOTE: CoreBluetooth’s Stack needs some time to discover and identify Devices abroad. So this is asynchronous operations. Devices might not be discovered and exposed immediately.
It’s simple, like in example:
// Somewhere in the code...
if(![SGBluetoothService sharedInstance].device) {
[SGBluetoothService sharedInstance].device = <device chosen from Devices List>
}
// Then later...
BOOL _connected = [SGBluetoothService sharedInstance].device.connected;
if (!_connected) {
[[SGBluetoothService sharedInstance].device connectWithCompletion:^(id data, NSError *error) {
NSLog(@"Connected; Err: %@", error);
[self updateDeviceInfo];
}];
} else {
[[SGBluetoothService sharedInstance].device disconnectWithCompletion:^(id data, NSError *error) {
NSLog(@"Disconnected; Err: %@", error);
[self updateDeviceInfo];
}];
}
Please make sure that the Device is connected and ready to use before Read GPS Info Operation Performed. Otherwise you’ll get an error on Opration Completion:
SGOperationReadGPSInfo* readGPSOperation = [SGOperationReadGPSInfo new];
[readGPSOperation executeWithCompletionCallback:^(SGFileGPSInfo* gpsInfo, NSError *error) {
DDLogVerbose(@"GPS OP Completed %@ == %@", gpsInfo, error);
}];
where SGFileGPSInfo object has properties latitude && longitude, populated with response from Device:
@interface SGFileGPSInfo : SGFile
/**
* Latitude Value read from Device
*/
@property (nonatomic, assign) double latitude;
/**
* Longitude Value Read from Device
*/
@property (nonatomic, assign) double longitude;
@end
If you’ve acquired the real GPS Location (by walking outdoor) or by using SkyGolf’s Service Tools, these lat && lon values are ready to use as a real Map’s Coordinates. If you didn’t get the real GPS Location on your Device, then lat & lon values will be defaulted to 0.000000.