Skip to content

Swift Migration Guide for predict.io 3.0

haseebOptini edited this page Aug 15, 2016 · 12 revisions

predict.io 3.0 is the major release of the previously known ParkTAG SDK, a delightful parking solution for iOS, that now is made available for a wide range of new uses cases. As a major release, following Semantic Versioning conventions, 3.0 introduces several changes with its new architecture.

This guide is provided in order to ease the transition of existing applications using Parktag 2.X to the latest SDK, as well as explain the new design and structure. In predict.io 3.0 instead of multiple parameters we are using PIOTripSegment object for more details click here

Instantiate SDK

To initiate the SDK and setting up delegate.

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

You should update it to:

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

Starting SDK

To start SDK.

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

You should update it to:

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

Stop SDK

To stop SDK.

 Parktag.sharedInstance().stop()

You should update it to:

 PredictIO.sharedInstance().stop()

Kick Start GPS

For kick start GPS.

 Parktag.sharedInstance().kickStartGPS()

You should update it to:

 PredictIO.sharedInstance().kickStartGPS()

Implementing Protocol

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

 ParktagDelegate

You should update it to:

 PredictIODelegate

Delegate Methods

We also changed the call back functions of SDK and detect the transport mode which is provided in SDK call back functions. Below is the list of changed function.

Vacating Parking

 func vacatingParking(location: CLLocation!)

You should update it to:

 func departing(tripSegment: PIOTripSegment!)

Vacated Parking

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

You should update it to:

 func departed(tripSegment: PIOTripSegment!)

Vacated Parking Canceled

 func vacatedParkingCanceled()

You should update it to:

 func departureCanceled()

Vehicle Parked Suspected

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

You should update it to:

 func arrivalSuspected(tripSegment: PIOTripSegment!)

Vehicle Parked

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

You should update it to:

 func arrived(tripSegment: PIOTripSegment!)

Searching Parking

 func searchingParking(location: CLLocation!)

You should update it to:

 func searchingInPerimeter(searchingLocation: CLLocation!)

Transportation Mode

You should add this

/* This method is invoked when predict.io detects transportation mode
 * @param: transportationMode: Mode of transportation
 */
 func transportationMode(transportationMode: TransportationMode)

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