A library, along with a sample project, that demonstrates some basic usage of the Automatic REST API. Right now, the library does the following:
- Downloads and parses trip data
- Downloads and parses trip's vehicle and location ('terminus') data
- Parses trip paths to
MKPolyline
object (separate subspec included)
Sweet GIF action:
Just include #import <BDKAutomatic/BDKAutomatic.h>
at the top of whatever Objective-C thing you're doing, and fire away.
BDKAutomatic *adapter = [[BDKAutomatic alloc] initWithClientId:clientId
clientSecret:clientSecret
redirectUrl:redirectUrl];
You'll need to authenticate it against a user account using the OAuth2 dance. See -[BDKAuthViewController handleAutomaticAuthenticationQueryString:]
for usage examples. Once you trade your authorization code for a legitimate BDKAutomaticToken
(which conforms to NSCopying
, by the way, so you can marshal that bad boy to Keychain or something), you can make calls on behalf of an Automatic user.
[self.automatic getTrips:^(NSError *error, NSArray *trips) {
BDKAutomaticTrip *trip = [trips firstObject];
NSLog(@"Trip started %@.", trip.startTime);
}];
If you want an MKPolyline
out of -[BDKAutomaticTrip path]
, you'll want to include the separate BDKAutomatic/MKPolylineSupport
subspec in your Podfile
, and use it like so.
#import <BDKAutomatic/MKPolyline+BDKEncodedString.h>
...
MKPolyline *mapPath = [MKPolyline polylineWithEncodedString:trip.path];
[self.mapView addOverlay:mapPath level:MKOverlayLevelAboveRoads];
You get the idea. See BDKMapViewController.m
for more goodies.
To run the example project; clone the repo, and run pod install
from the Project directory first. Then, open BDKAutomatic.xcworkspace
in the Project directory.
You'll want to copy the secret PLIST file from Project/Classes/BDKAutomaticSecrets.plist.example
to Project/Classes/BDKAutomaticSecrets.plist
and fill it out with your Automatic API client ID and client secret.
BDKAutomatic is available through CocoaPods, which is righteously awesome. To install it, simply add the following line to your Podfile.
pod 'BDKAutomatic'
If you don't want to use the "path-to-MKPolyline
" functionality, just use the subspec for the adapter.
pod 'BDKAutomatic/Adapter'
Ben Kreeger, [email protected]
BDKAutomatic is available under the MIT license. See the LICENSE file for more info.