Skip to content

Swift Migration Guide for predict.io 3.0

haseebOptini edited this page Nov 15, 2016 · 12 revisions

predict.io 3.0 is a major release of the previously known ParkTAG SDK, an SDK used to build a parking app for iOS. The new structure of the SDK, opens up a wide range of new use cases outside parking

As a major release, following semantic versioning conventions, version 3.0 introduces several changes with its new architecture.

This guide is provided in order to ease the transition for existing applications using ParkTag 2.x to the latest SDK version, as well as explain the new design and structure.

Overview

Instantiate the SDK

To initiate the SDK and setting up the delegate you used this so far:

 var parktag: Parktag = Parktag.sharedInstance()
 parktag.delegate = self
 parktag.apiKey = "YOUR-API-KEY"

You have to update it to:

 var predictIO: PredictIO = PredictIO.sharedInstance()
 predictIO.delegate = self
 predictIO.apiKey = "YOUR-API-KEY"

Starting the SDK

To start the SDK you used this so far:

 Parktag.sharedInstance().startWithCompletionHandler({(error: NSError) -> Void in
       if error != nil {
           print("Error : \(error.description)")
       }
 })

You have to update it to:

 PredictIO.sharedInstance().startWithCompletionHandler({(error: NSError) -> Void in
       if error != nil {
           print("Error : \(error.description)")
       }
 })

Stop the SDK

To stop the SDK you used this so far:

 Parktag.sharedInstance().stop()

You have to update it to:

 PredictIO.sharedInstance().stop()

Kick Start GPS

To kick start GPS you used this so far:

 Parktag.sharedInstance().kickStartGPS()

You have to update it to:

 PredictIO.sharedInstance().kickStartGPS()

Implementing the Protocol

We've changed the protocol of our SDK. If you were implementing the old version of the protocol:

 ParktagDelegate

You have to update it to:

 PredictIODelegate

Delegate Methods

We have changed the call back functions of the SDK. Instead of multiple parameters we are now using the new PIOTripSegment object that also includes the transportation mode. Please note that the transportation mode is provided in a separate SDK callback function, For more details on the PIOTripSegment click here. Below you find the list of changed functions and how to update them.

Vacating Parking

if you used this so far:

 func vacatingParking(location: CLLocation!)

You have to update it to:

 func departing(tripSegment: PIOTripSegment!)

Vacated Parking

if you used this so far:

 func vacatedParking(location: CLLocation!, startTime: NSDate!)

You have to update it to:

 func departed(tripSegment: PIOTripSegment!)

Vacated Parking Canceled

if you used this so far:

 func vacatedParkingCanceled()

You have to update it to:

 func canceledDeparture()

Vehicle Parked Suspected

if you used this so far:

 func vehicleParkedSuspected(vacatedLocation: CLLocation!, parkedLocation: CLLocation!, vacatedTime: NSDate!, parkedTime stopTime: NSDate!)

You have to update it to:

 func suspectedArrival(tripSegment: PIOTripSegment!)

Vehicle Parked

if you used this so far:

 func vehicleParked(vacatedLocation: CLLocation!, parkedLocation: CLLocation!, vacatedTime: NSDate!, stopTime: NSDate!)

You have to update it to:

 func arrived(tripSegment: PIOTripSegment!)

Searching Parking

If you used this so far:

 func searchingParking(location: CLLocation!)

You have to update it to:

 func searchingInPerimeter(searchingLocation: CLLocation!)

Transportation Mode

To use the transportation mode, you have to add this:

 func detectedTransportationMode(transportationMode: TransportationMode)

For a complete reference of the API, please check out our API documentation and usage guide.