You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
5.8 KiB

3 years ago
//
// BMKGeoFenceManager.h
// BMKLocationKit
//
// Created by baidu on 2017/3/2.
// Copyright © 2017年 baidu. All rights reserved.
//
#import "BMKGeoFenceRegion.h"
@protocol BMKGeoFenceManagerDelegate;
///地理围栏监听状态类型
typedef NS_OPTIONS(NSUInteger, BMKGeoFenceActiveAction)
{
BMKGeoFenceActiveActionNone = 0, ///< 不进行监听
BMKGeoFenceActiveActionInside = 1 << 0, ///< 在范围内
BMKGeoFenceActiveActionOutside = 1 << 1, ///< 在范围外
BMKGeoFenceActiveActionStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
};
///BMKGeoFence errorDomain
FOUNDATION_EXPORT NSErrorDomain const _Nonnull BMKGeoFenceErrorDomain;
///地理围栏错误码
typedef NS_ENUM(NSInteger, BMKGeoFenceErrorCode) {
BMKGeoFenceErrorUnknown = 1, ///< 未知错误
BMKGeoFenceErrorInvalidParameter = 2, ///< 参数错误
BMKGeoFenceErrorFailureConnection = 3, ///< 网络连接异常
BMKGeoFenceErrorFailureAuth = 4, ///< 鉴权失败
BMKGeoFenceErrorNoValidFence = 5, ///< 无可用围栏
BMKGeoFenceErroFailureLocating = 6, ///< 定位错误
};
///地理围栏管理类
@interface BMKGeoFenceManager : NSObject
///实现了 BMKGeoFenceManagerDelegate 协议的类指针。
@property (nonatomic, weak, nullable) id<BMKGeoFenceManagerDelegate> delegate;
///需要进行通知的行为,默认为BMKGeoFenceActiveActionInside。
@property (nonatomic, assign) BMKGeoFenceActiveAction activeAction;
///指定定位是否会被系统自动暂停。默认为NO。
@property (nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
@property (nonatomic, assign) BOOL allowsBackgroundLocationUpdates;
/**
* @brief
* @param center
* @param radius 0
* @param type
* @param customID IDSDK原值返回
*/
- (void)addCircleRegionForMonitoringWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius coorType:(BMKLocationCoordinateType)type customID:(NSString * _Nullable)customID;
/**
* @brief ,
* @param coordinates ,coordinates对应的内存会拷贝,
* @param count 3
* @param type
* @param customID IDSDK原值返回
*/
- (void)addPolygonRegionForMonitoringWithCoordinates:(CLLocationCoordinate2D * _Nonnull)coordinates count:(NSInteger)count coorType:(BMKLocationCoordinateType)type customID:(NSString * _Nullable)customID;
/**
* @brief customID获得指定的围栏customID传nil
* @param customID customID
* @return nil
*/
- (NSArray * _Nullable)geoFenceRegionsWithCustomID:(NSString * _Nullable)customID;
/**
* @brief
* @param region
*/
- (void)removeTheGeoFenceRegion:(BMKGeoFenceRegion * _Nonnull)region;
/**
* @brief customID的围栏
* @param customID customID
*/
- (void)removeGeoFenceRegionsWithCustomID:(NSString * _Nullable)customID;
/**
* @brief
*/
- (void)removeAllGeoFenceRegions;
@end
///地理围栏代理协议,该协议定义了获取地理围栏相关回调方法,包括添加、状态改变等。
@protocol BMKGeoFenceManagerDelegate <NSObject>
@optional
/**
* @brief app store关于新的后台定位的审核机制app store要求如果开发者只配置了使用期间定位plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription时delegate中调用后台定位api[locationManager requestAlwaysAuthorization]NSLocationWhenInUseUsageDescription使delegate中实现逻辑
* @param manager BMKGeoFenceManager
* @param locationManager CLLocationManager
* @since 1.7.0
*/
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager doRequestAlwaysAuthorization:(CLLocationManager * _Nonnull)locationManager;
/**
* @brief
* @param manager
* @param regions
* @param customID customID
* @param error
*/
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager didAddRegionForMonitoringFinished:(NSArray <BMKGeoFenceRegion *> * _Nullable)regions customID:(NSString * _Nullable)customID error:(NSError * _Nullable)error;
/**
* @brief
* @param manager
* @param region
* @param customID customID
* @param error
*/
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager didGeoFencesStatusChangedForRegion:(BMKGeoFenceRegion * _Nullable)region customID:(NSString * _Nullable)customID error:(NSError * _Nullable)error;
@end