diff --git a/Analytics/Classes/Internal/SEGBluetooth.m b/Analytics/Classes/Internal/SEGBluetooth.m index 41ebf4ed4..034e9f78a 100644 --- a/Analytics/Classes/Internal/SEGBluetooth.m +++ b/Analytics/Classes/Internal/SEGBluetooth.m @@ -1,8 +1,6 @@ #import "SEGBluetooth.h" #import -const NSString *SEGCentralManagerClass = @"CBCentralManager"; - @interface SEGBluetooth () diff --git a/Analytics/Classes/Internal/SEGSegmentIntegration.m b/Analytics/Classes/Internal/SEGSegmentIntegration.m index 6fb263ab8..2ee5c64d3 100644 --- a/Analytics/Classes/Internal/SEGSegmentIntegration.m +++ b/Analytics/Classes/Internal/SEGSegmentIntegration.m @@ -99,7 +99,9 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics self.httpClient = analytics.httpClient; self.apiURL = [NSURL URLWithString:@"https://api.segment.io/v1/import"]; self.userId = [self getUserId]; - self.bluetooth = [[SEGBluetooth alloc] init]; + if (self.configuration.shouldUseBluetooth) { + self.bluetooth = [[SEGBluetooth alloc] init]; + } self.reachability = [SEGReachability reachabilityWithHostname:@"google.com"]; [self.reachability startNotifier]; self.cachedStaticContext = [self staticContext]; @@ -236,7 +238,7 @@ - (NSDictionary *)liveContext context[@"network"] = ({ NSMutableDictionary *network = [[NSMutableDictionary alloc] init]; - if (self.bluetooth.hasKnownState) + if (self.bluetooth && self.bluetooth.hasKnownState) network[@"bluetooth"] = @(self.bluetooth.isEnabled); if (self.reachability.isReachable) { diff --git a/Analytics/Classes/SEGAnalytics.h b/Analytics/Classes/SEGAnalytics.h index 2dc04d146..56d4a7993 100644 --- a/Analytics/Classes/SEGAnalytics.h +++ b/Analytics/Classes/SEGAnalytics.h @@ -31,7 +31,9 @@ typedef NSMutableURLRequest * (^SEGRequestFactory)(NSURL *); @property (nonatomic, copy, readonly) NSString *writeKey; /** - * Whether the analytics client should use location services. If `YES` and the host app hasn't asked for permission to use location services then the user will be presented with an alert view asking to do so. `NO` by default. + * Whether the analytics client should use location services. + * If `YES` and the host app hasn't asked for permission to use location services then the user will be presented with an alert view asking to do so. `NO` by default. + * If `YES`, please make sure to add a description for `NSLocationAlwaysUsageDescription` in your `Info.plist` explaining why your app is accessing Location APIs. */ @property (nonatomic, assign) BOOL shouldUseLocationServices; @@ -51,6 +53,12 @@ typedef NSMutableURLRequest * (^SEGRequestFactory)(NSURL *); */ @property (nonatomic, assign) BOOL trackApplicationLifecycleEvents; + +/** + * Whether the analytics client should record bluetooth information. If `YES`, please make sure to add a description for `NSBluetoothPeripheralUsageDescription` in your `Info.plist` explaining explaining why your app is accessing Bluetooth APIs. `NO` by default. + */ +@property (nonatomic, assign) BOOL shouldUseBluetooth; + /** * Whether the analytics client should automatically make a screen call when a view controller is added to a view hierarchy. Because the underlying implementation uses method swizzling, we recommend initializing the analytics client as early as possible (before any screens are displayed), ideally during the Application delegate's applicationDidFinishLaunching method. */ diff --git a/Analytics/Classes/SEGAnalytics.m b/Analytics/Classes/SEGAnalytics.m index 7537c5fad..d12c4cb0d 100644 --- a/Analytics/Classes/SEGAnalytics.m +++ b/Analytics/Classes/SEGAnalytics.m @@ -46,6 +46,7 @@ - (instancetype)init if (self = [super init]) { self.shouldUseLocationServices = NO; self.enableAdvertisingTracking = YES; + self.shouldUseBluetooth = NO; self.flushAt = 20; _factories = [NSMutableArray array]; [_factories addObject:[SEGSegmentIntegrationFactory instance]]; diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 6e4821ccf..e63919c3b 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Analytics (3.3.0) + - Analytics (3.4.0) - Expecta (1.0.5) - Nimble (4.1.0) - Nocilla (0.10.0) @@ -16,10 +16,10 @@ DEPENDENCIES: EXTERNAL SOURCES: Analytics: - :path: "../" + :path: ../ SPEC CHECKSUMS: - Analytics: 5ebaf07a5067e730ca749c184f04db7752724e97 + Analytics: 3efde438f4f1e03f20525a0552784551a2e6037f Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19 Nocilla: ae0a2b05f3087b473624ac2b25903695df51246a diff --git a/Example/Pods/Local Podspecs/Analytics.podspec.json b/Example/Pods/Local Podspecs/Analytics.podspec.json index 3763c3c92..b0f7122f0 100644 --- a/Example/Pods/Local Podspecs/Analytics.podspec.json +++ b/Example/Pods/Local Podspecs/Analytics.podspec.json @@ -1,6 +1,6 @@ { "name": "Analytics", - "version": "3.3.0", + "version": "3.4.0", "summary": "The hassle-free way to add analytics to your iOS app.", "description": "Analytics for iOS provides a single API that lets you\nintegrate with over 100s of tools.", "homepage": "http://segment.com/", @@ -12,7 +12,7 @@ }, "source": { "git": "https://github.com/segmentio/analytics-ios.git", - "tag": "3.3.0" + "tag": "3.4.0" }, "social_media_url": "https://twitter.com/segment", "platforms": { diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 6e4821ccf..e63919c3b 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,5 +1,5 @@ PODS: - - Analytics (3.3.0) + - Analytics (3.4.0) - Expecta (1.0.5) - Nimble (4.1.0) - Nocilla (0.10.0) @@ -16,10 +16,10 @@ DEPENDENCIES: EXTERNAL SOURCES: Analytics: - :path: "../" + :path: ../ SPEC CHECKSUMS: - Analytics: 5ebaf07a5067e730ca749c184f04db7752724e97 + Analytics: 3efde438f4f1e03f20525a0552784551a2e6037f Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19 Nocilla: ae0a2b05f3087b473624ac2b25903695df51246a diff --git a/Example/Pods/Target Support Files/Analytics/Info.plist b/Example/Pods/Target Support Files/Analytics/Info.plist index 3ac477e66..ebdce2510 100644 --- a/Example/Pods/Target Support Files/Analytics/Info.plist +++ b/Example/Pods/Target Support Files/Analytics/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.3.0 + 3.4.0 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Tests/Tests.m b/Example/Tests/Tests.m index b36afa22e..23a08047d 100644 --- a/Example/Tests/Tests.m +++ b/Example/Tests/Tests.m @@ -17,6 +17,7 @@ expect(analytics.configuration.writeKey).to.equal(@"QUI5ydwIGeFFTa1IvCBUhxL9PyW5B0jE"); expect(analytics.configuration.shouldUseLocationServices).to.equal(@NO); expect(analytics.configuration.enableAdvertisingTracking).to.equal(@YES); + expect(analytics.configuration.shouldUseBluetooth).to.equal(@NO); }); });