TestParktagPods2 0.7.0

TestParktagPods2 0.7.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年6月

ParktagPod维护。



  • 作者
  • ahaseebchina01

示例

要运行示例项目,先克隆仓库,然后从示例目录运行 pod install

需求

集成步骤

1. Add SDK files to your project: File -> Add Files to "YourApp.xcodeproject"
        * Find and select the folder that contains the SDK
        * Make sure that Copy items into destination folder (if needed) is checked
        * Set Folders to Create groups for any added folders
        * Select the target that you want to add the SDK to
2. Verify that libParkTAG.a has been added to the Link Binary With Libraries Build Phase for the target you want to use the SDK with
        * Select your Project in the Project Navigator
        * Select the target you want to enable the SDK for
        * Select the Build Phases tab
        * Open the Link Binary With Libraries Phase

如果没有列出库文件,请将它们从您的“项目导航器”拖放到“链接二进制库”阶段。

将 CoreMotion、CoreLocation、CoreTelephony、AdSupport、AVFoundation、CoreBluetooth、SystemConfiguration 和 ExternalAccessory 框架库添加到您的“链接二进制库”构建阶段。

1. Select your Project in the Project Navigator
2. Select the target you want to enable the SDK for
3. Select the Build Phases tab
4. Open the Link Binary With Libraries Phase
5. Click the + to add a new library
6. Find CoreLocation in the list and add it

对于 CoreTelephony、CoreMotion、AdSupport、AVFoundation、CoreBluetooth、SystemConfiguration 和 ExternalAccessory 框架,重复步骤 5 和 6。

入门

为了即使应用处于后台也能接收到位置更新,您需要在您的应用中启用后台位置更新。您只需在“必要的后台模式”下添加“应用注册位置更新”即可。您可以通过文本编辑器编辑 plist 文件并添加以下代码,或者使用 Xcode 添加所需的背景模式。

此外,对于 iOS 8,您还需要在您的 info.plist 文件中添加两个键,即 NSLocationAlwaysUsageDescription 和 NSLocationWhenInUseUsageDescription。这些键将包含 iOS 显示位置服务权限警告时显示的文本。


<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>

此外,对于 iOS 8,您还需要在您的 info.plist 文件中添加一个键,即 NSLocationAlwaysUsageDescription。该键应包含在 iOS 显示应用位置服务权限警告时显示的文本字符串。

<key>NSLocationAlwaysUsageDescription</key>
<string>Data stays secure on your phone. GPS will help you find parking. Vacancy will be posted anonymously.</string>

实现 SDK

// implement ParktagDelegate in your AppDelegate and instantiate ParkTAG SDK

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Following code sample instantiate ParkTAG SDK and sets delegate method

Parktag *parktag = [Parktag sharedInstance];
parktag.delegate = self;
parktag.apiKey = @"YOUR-API-KEY";
}


/**
* Starts the ParkTag Tracker if delegate and API-Key is set, otherwise returns Error
* @param handler: The argument to the completion handler block is an error object that contains
* the description of the error in case an error is encountered while starting the ParkTAG tracker.
* If the tracker is started successfully, the error object is set to nil.
*/

- (IBAction)startParktag:(id)sender {
[[Parktag sharedInstance] startWithCompletionHandler:^(NSError *error) {
if (error) {
NSLog(@"Error : %@", [error description]);
}
}];
}

// Stop ParkTAG Tracker

- (IBAction)stopParktag:(id)sender {
[[Parktag sharedInstance] stop];
}

// Manually activate GPS for short period of time

-(IBAction)kickStartGPS:(id)sender {
[[Parktag sharedInstance] kickStartGPS];
}

/*
* This method adds a GeoFence of specified radius around the location
* @param identifier: GeoFence identifier
* @param location: Center location of the GeoFence
* @param radius: The distance (measured in meters) from the center geographic region to the edge of the circular boundary.
*/

- (BOOL)addFence:(NSString *)identifier center:(CLLocation *)location radius:(CLLocationDistance)radius {
Parktag *parktag = [Parktag sharedInstance];
return [parktag addFence:identifier center:location radius:radius];
}

/*
* This method returns the status of the tracker i.e. if it is active or otherwise
*
* TrackerStatus
* Discussion: Represents the current tracker state
* TrackerStatusActive : Tracker is in a working, active state
* TrackerStatusLocationServicesDisabled : Tracker is not in a working state as the location services are disabled
* TrackerStatusInsufficientPermission : Tracker is not in a working state as the permissions to use location services are not provided by the user
* TrackerStatusInActive : Tracker has not been started. It is in inactive state
*/

- (TrackerStatus)trackerStatus {
Parktag *parktag = [Parktag sharedInstance];
return [parktag trackerStatus];
}

// An alphanumeric string that uniquely identifies a device to the tracker

- (NSString *)deviceIdentifier {
Parktag *parktag = [Parktag sharedInstance];
return [parktag deviceIdentifier];
}

委托方法

@optional

/*
* This method is invoked when ParkTAG detects that user is about to vacate his parking
* spot and is approaching to his vehicle (this feature is currently in beta state)
* @param location: The Location where ParkTAG identified the parking, which is about to be vacated
*/
- (void)vacatingParking:(CLLocation *)location;

/*
* This method is invoked when ParkTAG detects that user has just vacated
* a parking spot and have started a new trip
* @param location:  The Location where ParkTAG identified start of the trip
* @param startTime: Start time of trip
*/
- (void)vacatedParking:(CLLocation *)location startTime:(NSDate *)startTime;

/*
* This method is invoked when ParkTAG detects that recently vacated vehicle is not a Car
*/
- (void)vacatedParkingCanceled;

/*
* This method is invoked when ParkTAG suspects that user has just parked his vehicle
* Most of the time, it is followed by a confirmed vehicleParked event
* If you need only confirmed parked events, use vehicleParked method (below) instead
* @param location:  The Location where vehicle is parked
* @param startTime: Start time of trip
* @param stopTime:  Stop time of trip
*/
- (void)vehicleParkedSuspected:(CLLocation *)location startTime:(NSDate *)startTime stopTime:(NSDate *)stopTime;

/*
* This method is invoked when ParkTAG detects that user has just parked his vehicle
* @param location:  The Location where vehicle is parked
* @param startTime: Start time of trip
* @param stopTime:  Stop time of trip
*/
- (void)vehicleParked:(CLLocation *)location startTime:(NSDate *)startTime stopTime:(NSDate *)stopTime;

/*
* This method is invoked when ParkTAG user is looking for a free parking
* @param location:  The Location where ParkTAG identified that user is searching for parking
*/
- (void)searchingParking:(CLLocation *)location;

/*
* This is invoked when new location information is received from Location manager
* Implemented this method if you need raw GPS data, instead of creating new location manager
* It is not recommended using multiple location managers in a single app
* @param location:  New location received from GPS
*/
- (void)didUpdateLocation:(CLLocation *)location;

安装

TestParktagPods2 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中。

pod "TestParktagPods2"

作者

haseebOptini,[email protected]

许可证

TestParktagPods2 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。