Skip to content

Commit

Permalink
Proximity SDK 1.0 with telemetry and CL permissions support
Browse files Browse the repository at this point in the history
  • Loading branch information
chwastek committed Jul 26, 2018
1 parent 5a87ea6 commit e25aaab
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 65 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2018-07-26

### Added:
- Enforcing Core Location Services permissions — in order to report enter/exit events, your apps need either WhenInUse (to work when the app is active) or Always (to work in background as well) permission.
- Proximity SDK now supports telemetry reporting to Estimote Cloud.

### Changed:
- Errors related to the SDK initialization, zone observation, and Location Services are more descriptive.
- `EPXProximityZoneContext` is not a protocol anymore, but a class (so you can use it nicely within your Swift apps).
- Swift classes have no `EPX` prefixes.
- Parameters and naming in `ProximityZone`'s `init` and event callbacks now follows a clearer convention, and is consistent with the Android version.

### Removed:
- `EPXDeviceAttachment` class.
- DeskObservers sample apps - from now on please use [app templates](https://cloud.estimote.com/#/apps/add) as a reference instead.

## [0.14.0] - 2018-06-19
>**Warning: Breaking changes - new, tag based API!**
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@

NS_ASSUME_NONNULL_BEGIN


/**
Estimote Cloud credentials encapsulated in a value object. To acquire App ID & App Token go to
https://cloud.estimote.com/#/apps.
*/
NS_SWIFT_NAME(CloudCredentials)
@interface EPXCloudCredentials : NSObject

/**
App ID generated in Estimote Cloud.
*/
@property (nonatomic, strong, readonly) NSString *appID;
@property(nonatomic, strong, readonly) NSString *appID;

/**
App Token generated in Estimote Cloud.
*/
@property (nonatomic, strong, readonly) NSString *appToken;
@property(nonatomic, strong, readonly) NSString *appToken;

/**
Init is disabled for this class.
Expand All @@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
New is disabled for this class.
*/
+ (instancetype)new NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;

/**
Designated initializer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT NSString * const EPXProximityObserverErrorDomain;
FOUNDATION_EXPORT NSString *const EPXProximityObserverErrorDomain;

/**
Possible errors invoked with Proximity Observer's error block.
Expand All @@ -29,7 +29,7 @@ typedef NS_ENUM(NSUInteger, EPXProximityObserverError) {

/* Fetching tags from Cloud failed. */
EPXProximityObserverErrorFetchingTagsFailed,

/* Fetching attachments from Cloud failed. */
EPXProximityObserverErrorFetchingAttachmentsFailed,

Expand All @@ -41,12 +41,16 @@ typedef NS_ENUM(NSUInteger, EPXProximityObserverError) {

/* Couldn't use motion detection. */
EPXProximityObserverErrorMotionDetectionFailed,

/* Core Location Services interferred with monitoring */
EPXProximityObserverErrorMonitoringNotPermitted
};

/**
Observes and reports proximity of Estimote devices.
Observes and reports proximity of Estimote devices.
Uses Estimote Monitoring under the hood. Encapsulates it under tag-based beacon identification and callback blocks.
*/
NS_SWIFT_NAME(ProximityObserver)
@interface EPXProximityObserver : NSObject

/**
Expand All @@ -57,16 +61,15 @@ typedef NS_ENUM(NSUInteger, EPXProximityObserverError) {
/**
New is disabled for this class.
*/
+ (instancetype)new NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;

/**
Convenience initializer. Calls designated initializer with default configuration.
@param credentials Cloud Credentials object used to authorize requests sent to Estimote Cloud.
@param errorBlock Block invoked whenever error occurs. The parameter is an NSError object, with
domain equal to EPXProximityObserverErrorDomain and code from EPXProximityObserverError enum.
*/
- (instancetype)initWithCredentials:(EPXCloudCredentials *)credentials
errorBlock:(void (^)(NSError *error))errorBlock;
- (instancetype)initWithCredentials:(EPXCloudCredentials *)credentials onError:(void (^)(NSError *error))errorBlock;

/**
Designated initializer.
Expand All @@ -77,7 +80,7 @@ typedef NS_ENUM(NSUInteger, EPXProximityObserverError) {
*/
- (instancetype)initWithCredentials:(EPXCloudCredentials *)credentials
configuration:(EPXProximityObserverConfiguration *)configuration
errorBlock:(void (^)(NSError *error))errorBlock;
onError:(void (^)(NSError *error))errorBlock;

/**
Start observing and calling callbacks on provided proximity zones:
Expand All @@ -89,7 +92,7 @@ typedef NS_ENUM(NSUInteger, EPXProximityObserverError) {
Note: at the moment, Proximity SDK supports monitoring only 100 devices per zone. If more devices have their attachments
matching the key, value defined in the zone, the first 100 are monitored.
@param zones Zones to be observed.
*/
- (void)startObservingZones:(NSArray<EPXProximityZone *> *)zones;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,32 @@ NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, EPXLogLevel) {
/* Mute all logs. */
EPXLogLevelNone = 0,

/* Log errors only. */
EPXLogLevelError = 1,

/* Log errors and warnings. */
EPXLogLevelWarning = 2,

/* Log errors, warnings and regular messages. */
EPXLogLevelInfo = 3,
EPXLogLevelInfo = 3
};

/**
Used to customize Proximity Observer behaviour.
*/
NS_SWIFT_NAME(ProximityObserverConfiguration)
@interface EPXProximityObserverConfiguration : NSObject

/**
Creates a default Proximity Observer configuration object.
*/
@property (nonatomic, strong, readonly, class) EPXProximityObserverConfiguration *defaultConfiguration;
@property(nonatomic, strong, readonly, class) EPXProximityObserverConfiguration *defaultConfiguration;

/**
Logger level. Defines which logs generated by Estimote Proximity SDK are printed to the Xcode's console.
*/
@property (nonatomic, assign, readwrite) EPXLogLevel logLevel;
@property(nonatomic, assign, readwrite) EPXLogLevel logLevel;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@

NS_ASSUME_NONNULL_BEGIN


/**
Represents range of a proximity where enter/exit events should occur.
Note:
Due to BLE signal instability the actual place where notifications occur will differ.
The `meanTriggerDistance` value defines the desired mean of distance at which events occur.
The distance is rounded up to decimeters. Don't expect decimeter accuracy; this is only for simplification
of EPXProximityRange objects comparison.
*/
NS_SWIFT_NAME(ProximityRange)
@interface EPXProximityRange : NSObject

/**
Distance in meters where enter/exit events should occur passed in initializer rounded to decimeters (to 0.1).
*/
@property (nonatomic, assign, readonly) double desiredMeanTriggerDistance;
@property(nonatomic, assign, readonly) double desiredMeanTriggerDistance;

/**
Convenience factory for near range. Returns range with meanTriggerDistance set to 1m.
It's a class property instead of class method to enable good-looking Swift code.
*/
@property (nonatomic, copy, readonly, class) EPXProximityRange *nearRange;
@property(nonatomic, copy, readonly, class) EPXProximityRange *nearRange;

/**
Convenience factory for far range. Returns range with meanTriggerDistance set to 5m.
It's a class property instead of class method to enable good-looking Swift code.
*/
@property (nonatomic, copy, readonly, class) EPXProximityRange *farRange;
@property(nonatomic, copy, readonly, class) EPXProximityRange *farRange;

/**
Init is disabled for this class.
Expand All @@ -53,14 +53,14 @@ NS_ASSUME_NONNULL_BEGIN
/**
New is disabled for this class.
*/
+ (instancetype)new NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;

/**
Designated initializer.
@param desiredMeanTriggerDistance Distance in meters where enter/exit events should occur rounded to decimeters (to 0.1).
It has to be a non-negative number.
@return Initialized object. Nil if passed desiredMeanTriggerDistance is negative.
*/
- (nullable instancetype)initWithDesiredMeanTriggerDistance:(double)desiredMeanTriggerDistance NS_DESIGNATED_INITIALIZER;
Expand All @@ -70,11 +70,11 @@ NS_ASSUME_NONNULL_BEGIN
@param desiredMeanTriggerDistance Distance in meters where enter/exit events should occur rounded to decimeters (to 0.1).
It has to be a non-negative number.
@return Initialized object. Nil if passed desiredMeanTriggerDistance is negative.
*/
+ (nullable instancetype)customRangeWithDesiredMeanTriggerDistance:(double)desiredMeanTriggerDistance
NS_SWIFT_NAME(custom(desiredMeanTriggerDistance:));
NS_SWIFT_NAME(custom(desiredMeanTriggerDistance:));

#pragma mark isEqual overrides
- (BOOL)isEqualToRange:(EPXProximityRange *)otherRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
Note: at the moment, Proximity SDK supports monitoring only 100 devices per zone. If more devices have their attachments
matching the key, value defined in the zone, the first 100 are monitored.
*/
NS_SWIFT_NAME(ProximityZone)
@interface EPXProximityZone : NSObject

/**
Expand All @@ -40,19 +41,19 @@ NS_ASSUME_NONNULL_BEGIN
Register block to be called when user enters proximity of Estimote devices with matching tag.
Beacon identification is tag-based (see https://github.com/Estimote/iOS-SDK/blob/sdk_5/README.md for more info).
*/
@property (nonatomic, copy, readwrite, nullable) void (^onEnterAction)(id<EPXProximityZoneContext> zoneContext);
@property (nonatomic, copy, readwrite, nullable) void (^onEnter)(EPXProximityZoneContext * zoneContext);

/**
Block to be called when user exits proximity of Estimote devices with matching tag.
Beacon identification is tag-based (see https://github.com/Estimote/iOS-SDK/blob/sdk_5/README.md for more info).
*/
@property (nonatomic, copy, readwrite, nullable) void (^onExitAction)(id<EPXProximityZoneContext> zoneContext);
@property (nonatomic, copy, readwrite, nullable) void (^onExit)(EPXProximityZoneContext * zoneContext);

/**
Block to be called each time a new beacon is detected in user's range and each time a beacon disappears
from user's range.
*/
@property (nonatomic, copy, readwrite, nullable) void (^onChangeAction)(NSSet<id<EPXProximityZoneContext>> *zoneContexts);
@property (nonatomic, copy, readwrite, nullable) void (^onContextChange)(NSSet<EPXProximityZoneContext *> *zoneContexts);

/**
Init is unavailable.
Expand All @@ -66,10 +67,10 @@ NS_ASSUME_NONNULL_BEGIN
/**
Designated initilizer.
@param range Range where the action should be reported.
@param tag Tag name assigned to the zone.
@param range Range where the action should be reported.
*/
- (instancetype)initWithRange:(EPXProximityRange *)range tag:(NSString *)tag NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTag:(NSString *)tag range:(EPXProximityRange *)range NS_DESIGNATED_INITIALIZER;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

NS_ASSUME_NONNULL_BEGIN

@class EPXDeviceAttachment;

NS_SWIFT_NAME(ProximityZoneContext)
/**
Interface providing all contextual data about a Proximity Zone.
*/
@protocol EPXProximityZoneContext <NSObject>
NS_SWIFT_NAME(ProximityZoneContext)
@interface EPXProximityZoneContext: NSObject

/**
Identifier of a device that is the zone's source.
Expand All @@ -32,7 +30,22 @@ NS_SWIFT_NAME(ProximityZoneContext)
/**
Dictionary of attachments assigned in Cloud to that zone's source.
*/
@property (nonatomic, readonly, nullable) NSArray<EPXDeviceAttachment *> *attachments;
@property (nonatomic, readonly) NSDictionary<NSString *, NSString *> *attachments;

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/**
Designated initializer.
@param deviceIdentifier Zone's source.
@param tag Zone's tag name.
@param attachments Dicitionary of attachments.
@return Initialized object.
*/
- (instancetype)initWithDeviceIdentifier:(NSString *)deviceIdentifier
tag:(NSString *)tag
attachments:(NSDictionary<NSString *, NSString *> *)attachments NS_DESIGNATED_INITIALIZER;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,9 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#endif
#if __has_feature(modules)
@import CoreLocation;
@import ObjectiveC;
@import Foundation;
#endif

#import <EstimoteProximitySDK/EstimoteProximitySDK.h>

#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
Expand All @@ -187,20 +184,6 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));



@class EPXDeviceAttachment;

SWIFT_CLASS("_TtC20EstimoteProximitySDK28ProximityZoneContextInternal")
@interface ProximityZoneContextInternal : NSObject <EPXProximityZoneContext>
@property (nonatomic, copy) NSString * _Nonnull deviceIdentifier;
@property (nonatomic, copy) NSString * _Nonnull tag;
@property (nonatomic, copy) NSArray<EPXDeviceAttachment *> * _Nullable attachments;
@property (nonatomic, readonly) NSUInteger hash;
@property (nonatomic, readonly, copy) NSString * _Nonnull description;
- (BOOL)isEqual:(id _Nullable)object SWIFT_WARN_UNUSED_RESULT;
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
@end



#if __has_attribute(external_source_symbol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ FOUNDATION_EXPORT const unsigned char EstimoteProximitySDKVersionString[];
#import "EPXProximityZone.h"
#import "EPXProximityRange.h"
#import "EPXCloudCredentials.h"
#import "EPXDeviceAttachment.h"
#import "EPXProximityZoneContext.h"
Binary file modified EstimoteProximitySDK/EstimoteProximitySDK.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import <Foundation/Foundation.h>

@class EPXProximityZone;
@class EPXDeviceAttachment;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Loading

0 comments on commit e25aaab

Please sign in to comment.