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.

235 lines
11 KiB

//
// AMapGeoFenceManager.h
// AMapLocationKit
//
// Created by hanxiaoming on 16/12/5.
// Copyright © 2016年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AMapGeoFenceRegionObj.h"
// 以下类涉及的坐标需要使用高德坐标系坐标(GCJ02)
@protocol AMapGeoFenceManagerDelegate;
///地理围栏监听状态类型
typedef NS_OPTIONS(NSUInteger, AMapGeoFenceActiveAction)
{
AMapGeoFenceActiveActionNone = 0, ///< 不进行监听
AMapGeoFenceActiveActionInside = 1 << 0, ///< 在范围内
AMapGeoFenceActiveActionOutside = 1 << 1, ///< 在范围外
AMapGeoFenceActiveActionStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
};
///地理围栏任务状态类型
typedef NS_OPTIONS(NSUInteger, AMapGeoFenceRegionActiveStatus)
{
AMapGeoFenceRegionActiveUNMonitor = 0, ///< 未注册
AMapGeoFenceRegionActiveMonitoring = 1 << 0, ///< 正在监控
AMapGeoFenceRegionActivePaused = 1 << 1, ///< 暂停监控
};
///地理围栏管理类(since 2.3.0)
@interface AMapGeoFenceManager : NSObject
///实现了 AMapGeoFenceManagerDelegate 协议的类指针。
@property (nonatomic, weak) id<AMapGeoFenceManagerDelegate> delegate;
///需要进行通知的行为,默认为AMapGeoFenceActiveActionInside。
@property (nonatomic, assign) AMapGeoFenceActiveAction activeAction;
///指定定位是否会被系统自动暂停。默认为NO。
@property (nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
@property (nonatomic, assign) BOOL allowsBackgroundLocationUpdates;
///检测是否存在虚拟定位风险,默认为NO,即不检测。 \n如果设置为YES,检测到风险后,会通过amapGeoFenceManager:didGeoFencesStatusChangedForRegion:customID:error: 的error给出风险提示,error的格式为error.domain==AMapGeoFenceErrorDomain; error.code==AMapGeoFenceErroFailureLocating;
@property (nonatomic, assign) BOOL detectRiskOfFakeLocation;
/**
* @brief
* @param center
* @param radius 0
* @param customID IDSDK原值返回
*/
- (void)addCircleRegionForMonitoringWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius customID:(NSString *)customID;
/**
* @brief ,
* @param coordinates ,coordinates对应的内存会拷贝,
* @param count 3
* @param customID IDSDK原值返回
*/
- (void)addPolygonRegionForMonitoringWithCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSInteger)count customID:(NSString *)customID;
/**
* @brief POI地理围栏
* @param keyword |keyword和type两者至少必选其一
* @param type POI类型|keyword和type两者至少必选其一 http://lbs.amap.com/api/webservice/guide/api/search/#text
* @param city
* @param size (0,25]<=010252510
* @param customID IDSDK原值返回
*/
- (void)addKeywordPOIRegionForMonitoringWithKeyword:(NSString *)keyword POIType:(NSString *)type city:(NSString *)city size:(NSInteger)size customID:(NSString *)customID;
/**
* @brief POI围栏
* @param locationPoint
* @param aroundRadius (0,50000]30003000
* @param keyword |
* @param type POI类型|
* @param size (0,25]<=010252510
* @param customID IDSDK原值返回
*/
- (void)addAroundPOIRegionForMonitoringWithLocationPoint:(CLLocationCoordinate2D)locationPoint aroundRadius:(NSInteger)aroundRadius keyword:(NSString *)keyword POIType:(NSString *)type size:(NSInteger)size customID:(NSString *)customID;
/**
* @brief
* @param districtName citycodeadcode http://lbs.amap.com/api/webservice/guide/api/district/#district
* @param customID IDSDK原值返回
*/
- (void)addDistrictRegionForMonitoringWithDistrictName:(NSString *)districtName customID:(NSString *)customID;
/**
* @brief
* @param region
* @return
*/
- (AMapGeoFenceRegionActiveStatus)statusWithGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief customID获得所有已经注册的围栏customID传nil
* @param customID customID
* @return nil
*/
- (NSArray *)geoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief customID获得所有正在监控的围栏customID传nil
* @param customID customID
* @return nil
*/
- (NSArray *)monitoringGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief customID获得所有已经暂停的围栏customID传nil
* @param customID customID
* @return nil
*/
- (NSArray *)pausedGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief customID的围栏
* @param customID customID
* @return nil
*/
- (NSArray *)pauseGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief
* @param region
* @return NO
*/
- (BOOL)pauseTheGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief customID开始监控已经暂停的围栏
* @param customID customID
* @return
*/
- (NSArray *)startGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief
* @param region
* @return NO
*/
- (BOOL)startTheGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief
* @param region
*/
- (void)removeTheGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief customID的围栏
* @param customID customID
*/
- (void)removeGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief
*/
- (void)removeAllGeoFenceRegions;
@end
///地理围栏代理协议(since 2.3.0),该协议定义了获取地理围栏相关回调方法,包括添加、状态改变等。
@protocol AMapGeoFenceManagerDelegate <NSObject>
@required
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
/**
* @brief iOS14及以上版本使用地理围栏功能plist中配置NSLocationTemporaryUsageDescriptionDictionary字典描述Key描述地理围栏的使用场景API即可
* [locationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:@"PurposeKey" completion:^(NSError *error){
* if(completion){
* completion(error);
* }
* }]; (,)
* @param manager
* @param locationManager locationManager
* @param completion API回调结果error即可
* @since 2.6.7
*/
- (void)amapLocationManager:(AMapGeoFenceManager *)manager doRequireTemporaryFullAccuracyAuth:(CLLocationManager*)locationManager completion:(void(^)(NSError *error))completion;
#endif
@optional
/**
* @brief plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription[CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined
API即可[locationManager requestAlwaysAuthorization](,)
* @param manager
* @param locationManager locationManager
* @since 2.6.2
*/
- (void)amapGeoFenceManager:(AMapGeoFenceManager *)manager doRequireLocationAuth:(CLLocationManager*)locationManager;
/**
* @brief
* @param manager
* @param regions
* @param customID customID
* @param error
*/
- (void)amapGeoFenceManager:(AMapGeoFenceManager *)manager didAddRegionForMonitoringFinished:(NSArray <AMapGeoFenceRegion *> *)regions customID:(NSString *)customID error:(NSError *)error;
/**
* @brief
* @param manager
* @param region
* @param customID customID
* @param error
*/
- (void)amapGeoFenceManager:(AMapGeoFenceManager *)manager didGeoFencesStatusChangedForRegion:(AMapGeoFenceRegion *)region customID:(NSString *)customID error:(NSError *)error;
@end