From ee30a0e9ca6800abc9b644fe48eeee29013e1a9c Mon Sep 17 00:00:00 2001 From: Heitor Tashiro Sergent Date: Tue, 13 Sep 2016 11:06:45 -0500 Subject: [PATCH 1/4] Disable geo location by default --- KeenClient/KeenClient.m | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/KeenClient/KeenClient.m b/KeenClient/KeenClient.m index 8bb9275..b76589e 100644 --- a/KeenClient/KeenClient.m +++ b/KeenClient/KeenClient.m @@ -177,23 +177,6 @@ @implementation KeenClient # pragma mark - Class lifecycle -+ (void)initialize { - // initialize the cached client exactly once. - - if (self != [KeenClient class]) { - /* - Without this extra check, your initializations could run twice if you ever have a subclass that - doesn't implement its own +initialize method. This is not just a theoretical concern, even if - you don't write any subclasses. Apple's Key-Value Observing creates dynamic subclasses which - don't override +initialize. - */ - return; - } - - [KeenClient disableLogging]; - [KeenClient enableGeoLocation]; -} - + (void)disableLogging { loggingEnabled = NO; } From f00cc4a664c6509d1a9a1ca316dc5012a2a3001a Mon Sep 17 00:00:00 2001 From: Heitor Tashiro Sergent Date: Tue, 13 Sep 2016 11:06:59 -0500 Subject: [PATCH 2/4] Fix geo location tests --- KeenClientTests/KeenClientTests.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/KeenClientTests/KeenClientTests.m b/KeenClientTests/KeenClientTests.m index 4b16500..1dff141 100644 --- a/KeenClientTests/KeenClientTests.m +++ b/KeenClientTests/KeenClientTests.m @@ -291,13 +291,12 @@ - (void)testEventWithDictionary { - (void)testGeoLocation { // set up a client with a location KeenClient *client = [KeenClient sharedClientWithProjectID:@"id" andWriteKey:@"wk" andReadKey:@"rk"]; - KeenClient *clientI = [[KeenClient alloc] initWithProjectID:@"id" andWriteKey:@"wk" andReadKey:@"rk"]; + [KeenClient enableGeoLocation]; CLLocation *location = [[CLLocation alloc] initWithLatitude:37.73 longitude:-122.47]; client.currentLocation = location; // add an event [client addEvent:@{@"a": @"b"} toEventCollection:@"foo" error:nil]; - [clientI addEvent:@{@"a": @"b"} toEventCollection:@"foo" error:nil]; // now get the stored event NSDictionary *eventsForCollection = [[[KeenClient getDBStore] getEventsWithMaxAttempts:3 andProjectID:client.projectID] objectForKey:@"foo"]; // Grab the first event we get back @@ -318,7 +317,6 @@ - (void)testGeoLocationDisabled { KeenClient *client = [KeenClient sharedClientWithProjectID:@"id" andWriteKey:@"wk" andReadKey:@"rk"]; KeenClient *clientI = [[KeenClient alloc] initWithProjectID:@"id" andWriteKey:@"wk" andReadKey:@"rk"]; - [KeenClient disableGeoLocation]; // add an event [client addEvent:@{@"a": @"b"} toEventCollection:@"bar" error:nil]; [clientI addEvent:@{@"a": @"b"} toEventCollection:@"bar" error:nil]; From 93206d62b8c6dc2a980728a4a26b305f3b7146bc Mon Sep 17 00:00:00 2001 From: Heitor Tashiro Sergent Date: Tue, 13 Sep 2016 11:07:06 -0500 Subject: [PATCH 3/4] Update README --- README.md | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 92414c0..ae337bb 100644 --- a/README.md +++ b/README.md @@ -300,7 +300,39 @@ The block takes in a single string parameter which corresponds to the name of th ##### Geo Location -Like any good mobile-first service, Keen supports geo localization so you can track where events happened. This is enabled by default. Just use the client as you normally would and your users will be asked to allow geo location services. All events will be automatically tagged with the current location. +Like any good mobile-first service, Keen supports geo localization so you can track where events happened. This is **disabled by default**. To enable it, use: + +Objective-C: +```objc +[KeenClient enableGeoLocation]; +``` + +Swift: +```swift +KeenClient.enableGeoLocation() +``` + +Your users will be asked to allow geo location services. If the user chooses "Allow", all events will be automatically tagged with the current location. + +###### Requesting Authorization for Location in iOS 8+ + +iOS 8 introduced a new method for requesting authorization that requires a few additional steps before location will automatically be appended to your events: + +1. Add one or both of the following keys to your Info.plist file: `NSLocationWhenInUseUsageDescription`,`NSLocationAlwaysUsageDescription` +2. Call the appropriate authorization method to authorize your app to use location services. `authorizeGeoLocationWhenInUse` and `authorizeGeoLocationAlways` were both added as of version 3.2.16 of this SDK. `authorizeGeoLocationWhenInUse` is enabled by default as long as `NSLocationWhenInUseUsageDescription` is specified in your Info.plist file, so you don't need to call it if you're going the 'When in Use' route. `authorizeGeoLocationAlways` on the other hand must be called explicitly. + +Example: + +Objective C +```objc +[KeenClient authorizeGeoLocationAlways]; +[KeenClient sharedClientWithProjectID:@"your_project_id" andWriteKey:@"your_write_key" andReadKey:@"your_read_key"]; +``` +Swift +```Swift +KeenClient.authorizeGeoLocationAlways() +KeenClient.sharedClientWithProjectID("your_project_id", andWriteKey: "your_write_key", andReadKey: "your_read_key") +``` ###### Refreshing Current Location @@ -342,26 +374,6 @@ do { } ``` -###### Requesting Authorization for Location in iOS 8+ - -iOS 8 introduced a new method for requesting authorization that requires a few additional steps before location will automatically be appended to your events: - -1. Add one or both of the following keys to your Info.plist file: `NSLocationWhenInUseUsageDescription`,`NSLocationAlwaysUsageDescription` -2. Call the appropriate authorization method to authorize your app to use location services. `authorizeGeoLocationWhenInUse` and `authorizeGeoLocationAlways` were both added as of version 3.2.16 of this SDK. `authorizeGeoLocationWhenInUse` is enabled by default as long as `NSLocationWhenInUseUsageDescription` is specified in your Info.plist file, so you don't need to call it if you're going the 'When in Use' route. `authorizeGeoLocationAlways` on the other hand must be called explicitly. - -Example: - -Objective C -```objc -[KeenClient authorizeGeoLocationAlways]; -[KeenClient sharedClientWithProjectID:@"your_project_id" andWriteKey:@"your_write_key" andReadKey:@"your_read_key"]; -``` -Swift -```Swift -KeenClient.authorizeGeoLocationAlways() -KeenClient.sharedClientWithProjectID("your_project_id", andWriteKey: "your_write_key", andReadKey: "your_read_key") -``` - ##### Upload Events to Keen IO From df7f8825455804fd02b13ba6847fc432f8a3ee98 Mon Sep 17 00:00:00 2001 From: Heitor Tashiro Sergent Date: Tue, 13 Sep 2016 11:07:11 -0500 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 731b698..effd634 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased][unreleased] +### Changed +- Changed geo location to be disabled by default. Users will now have to explicitly call `enableGeoLocation` to ask for user's location permission. #157 ## [3.5.6] - 2016-08-05 ### Fixed