Hi I'm using Kontakt iOS SDK and I have followed tutorial as mentioned
Through pods I'm installing SDK
pod out is :
Update all pods
Updating local specs repositories
CocoaPods 1.2.0.beta.1 is available.
To update use: sudo gem install cocoapods --pre
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.0.beta.1
Analyzing dependencies
Downloading dependencies
Using KontaktSDK (1.3.2)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
My Code :
AppDelegate.h :
#import <UIKit/UIKit.h>
#import <KontaktSDK/KontaktSDK.h>
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
@interface AppDelegate : UIResponder <UIApplicationDelegate,KTKBeaconManagerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property(strong,nonatomic) KTKBeaconManager *beaconManager;
@end
AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// self.locationManger = [[CLLocationManager alloc] init];
// self.locationManger.desiredAccuracy = kCLLocationAccuracyBest;
// [self.locationManger setDelegate:self];
// [self.locationManger startUpdatingLocation];
[Kontakt setAPIKey:@"*****************"];
[self beaconScan];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
-(void)beaconScan{
NSLog(@"beaconScan");
self.beaconManager = [[KTKBeaconManager alloc] initWithDelegate:self];
NSUUID *myProximityUUID = [[NSUUID alloc] initWithUUIDString:@"*************"];
KTKBeaconRegion *region1 = [[KTKBeaconRegion alloc] initWithProximityUUID:myProximityUUID identifier:@"Beacon region 1"];
switch ([KTKBeaconManager locationAuthorizationStatus]) {
case kCLAuthorizationStatusNotDetermined:
[self.beaconManager requestLocationAlwaysAuthorization];
break;
case kCLAuthorizationStatusDenied:
case kCLAuthorizationStatusRestricted:
// No access to Location Services
break;
case kCLAuthorizationStatusAuthorizedWhenInUse:
// For most iBeacon-based app this type of
// permission is not adequate
break;
case kCLAuthorizationStatusAuthorizedAlways:
if ([KTKBeaconManager isMonitoringAvailable]) {
NSLog(@"kCLAuthorizationStatusAuthorizedAlways");
[self.beaconManager startMonitoringForRegion:region1];
}
break;
}
}
- (void)beaconManager:(KTKBeaconManager *)manager didChangeLocationAuthorizationStatus:(CLAuthorizationStatus)status {
if (status == kCLAuthorizationStatusAuthorizedAlways) {
NSUUID *myProximityUUID = [[NSUUID alloc] initWithUUIDString:@"****************"];
KTKBeaconRegion *region1 = [[KTKBeaconRegion alloc] initWithProximityUUID:myProximityUUID identifier:@"Beacon region 1"];
[self.beaconManager startMonitoringForRegion:region1];
}else if (status == kCLAuthorizationStatusNotDetermined){
[self.beaconManager requestLocationAlwaysAuthorization];
}
}
- (void)beaconManager:(KTKBeaconManager *)manager didStartMonitoringForRegion:(__kindof KTKBeaconRegion *)region {
// Do something when monitoring for a particular
// region is successfully initiated
NSLog(@"didStartMonitoringForRegion %@",region);
[manager startRangingBeaconsInRegion:region];
}
- (void)beaconManager:(KTKBeaconManager *)manager monitoringDidFailForRegion:(__kindof KTKBeaconRegion *)region withError:(NSError *)error {
NSLog(@"monitoringDidFailForRegion %@ %@error ",region,error);
}
- (void)beaconManager:(KTKBeaconManager *)manager didEnterRegion:(__kindof KTKBeaconRegion *)region {
NSLog(@"didStartMonitoringForRegion %@",region);
[manager startRangingBeaconsInRegion:region];
}
- (void)beaconManager:(KTKBeaconManager *)manager didExitRegion:(__kindof KTKBeaconRegion *)region {
NSLog(@"didStartMonitoringForRegion %@",region);
[manager stopRangingBeaconsInRegion:region];
}
-(void)beaconManager:(KTKBeaconManager *)manager didRangeBeacons:(NSArray<CLBeacon *> *)beacons inRegion:(__kindof KTKBeaconRegion *)region{
NSLog(@"didRangeBeacons beacons %@ in region %@",beacons,region);
}
@end
For the first time I have run the app in device through xcode it is working properly
and second time running the app no delegate methods are calling, even the CLAuthorizationStatus is kCLAuthorizationStatusAuthorizedAlways,and app is in device privacy location service. if I uninstall the app and installed it again it is working fine for the first time and from second time as same no delegate methods are calling
Device : iPhone 5S
iOS Version : iOS 10,9