This SDK make easier the usage of Xee API on iOS devices. It is written in Swift
- Example
- Requirements
- Installation
- Setup
- Authentication
- Vehicles
- Users
- Signals
- Privacies
- Trips
- Authorizations
- Issues
- Author
- License
To run the example project, clone the repo, and run pod install
from the Example directory first.
This SDK works for iOS with a version >= 8.0
XeeSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'XeeSDK'
and launch command
pod install
Create an application on our developer space to get credentials, see how to create an app
In your AppDelegate, import the SDK
import XeeSDK
next, in the didFinishLaunchingWithOptions
method, create a XeeConfig object with all the informations of your app, then give it to the ConnectManager singleton :
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let xeeConfig = XeeConfig(withClientID: "<App Client ID>",
SecretKet: "<App Secret Key>",
Scopes: ["<App Scope list>"],
RedirectURI: "<App Redirect URI>",
Environment: <App Environment>)
XeeConnectManager.shared.config = xeeConfig
return true
}
Example :
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let xeeConfig = XeeConfig(withClientID: "0123456789abcdefghijklmnopqrstuvwxyz",
SecretKet: "0123456789abcdefghijklmnopqrstuvwxyz",
Scopes: ["account.read", "vehicles.read", "vehicles.signals.read", "vehicles.locations.read", "vehicles.trips.read"],
RedirectURI: "xee-sdk-example://app",
Environment: .XeeEnvironmentCLOUD)
XeeConnectManager.shared.config = xeeConfig
return true
}
then add this line in the open url
method:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
XeeConnectManager.shared.openURL(URL: url)
return true
}
Don't forget to add the redirectURI in your URL Schemes ("xee-sdk-example", in this example) :
You're ready !
Note that we'll keep this SDK up to date to provide you all the endpoints availables on the 4th version of the API
Add the XeeConnectManagerDelegate protocol to your view controller
Call the connect method of the connectManager singleton when you want the user create an account.
XeeConnectManager.shared.delegate = self
XeeConnectManager.shared.createAccount()
Add the XeeConnectManagerDelegate protocol to your view controller
Call the connect method of the connectManager singleton when you want the user logs in order to get a valid access token.
XeeConnectManager.shared.delegate = self
XeeConnectManager.shared.connect()
Add the XeeConnectManagerDelegate protocol to your view controller
Call the disconnect method of the connectManager singleton when you want the user disconnect.
XeeConnectManager.shared.delegate = self
XeeConnectManager.shared.disconnect()
Four cases:
extension YourViewController : XeeConnectManagerDelegate {
func didSuccess(token: XeeToken) {
// Success
}
func didFail(WithError error: Error) {
// Fail
}
func didCancel() {
// Cancel
}
func didDisconnected() {
// Disconnected
}
}
If there is no access token or if it's not valid, the SDK will open safari inside the application in order to authenticate with OAuth2. Once safari call back your app, the didSuccess method will be called.
Everything about your vehicles
Set a vehicle for an user with a specified device_id and pin code
XeeRequestManager.shared.associateVehicle(WithXeeConnectId: <XeeConnect ID>, PinCode: <Pin Code>, completionHandler: { (error, vehicle) in
// Your code here
})
Returns vehicles corresponding to specified user id
XeeRequestManager.shared.getVehicles(WithUserID: <User ID or nil for "me">, completionHandler: { (error, vehicules) in
// Your code here
})
Delete the pairing between a vehicle and a device
// TODO
Returns a vehicle corresponding to specified id
XeeRequestManager.shared.getVehicle(WithVehicleID: <Vehicle ID>, completionHandler: { (error, vehicule) in
// Your code here
})
Update a vehicle with a specified ID
XeeRequestManager.shared.updateVehicle(WithVehicle: <XeeVehicle object>, completionHandler: { (error, vehicle) in
// Your code here
})
Returns the vehicle status of the vehicle
XeeRequestManager.shared.getStatus(WithVehicleID: <Vehicle ID>, completionHandler: { (error, status) in
// Your code here
})
Access to your profile
Returns a user corresponding to specified id, me is the current user
XeeRequestManager.shared.getUser(WithUserID: <User ID or nil for "me">, completionHandler: { (error, user) in
// Your code here
})
Update an user with a specified ID
XeeRequestManager.shared.updateUser(WithUser: <XeeUser object>, completionHandler: { (error, user) in
// Your code here
})
Signals of Vehicles (CAN signals, GPS and Accelerometer)
Retrieves the accelerometers data of a vehicle in a given date range
// TODO
Retrieves the device data of a vehicle in a given time range
// TODO
Retrieves the locations of a vehicle in a given date range
// TODO
Retrieves signals for a vehicle in a given date range
// TODO
Operations about privacies
Stop an existing privacy session
XeeRequestManager.shared.stopPrivacy(ForVPrivacyID: <Privacy ID>, completionHandler: { (error, privacy) in
// Your code here
})
Returns vehicles privacies between 2 dates inclusive
XeeRequestManager.shared.getPrivacies(ForVehicleID: <Vdehicle ID>, From: <Date or nil>, To: <Date or nil>, Limit: <Int or nil>, completionHandler: { (error, privacies) in
// Your code here
})
Creates a new privacy session on this vehicle
XeeRequestManager.shared.startPrivacy(ForVehicleID: <Vehicle ID>, completionHandler: { (error, privacy) in
// Your code here
})
Access to the trips of the vehicles
Returns trip corresponding to specified trip id
XeeRequestManager.shared.getTrip(WithTripID: <Trip ID>, completionHandler: { (error, trip) in
// Your code here
})
Returns trips locations by redirecting to the signals api with the good date range
XeeRequestManager.shared.getLocations(WithTripID: <Trip ID>, completionHandler: { (error, locations) in
// Your code here
})
Returns trips signals by redirecting to the signals api with the good date range
XeeRequestManager.shared.getSignals(WithTripID: <Trip ID>, completionHandler: { (error, signals) in
// Your code here
})
Returns trips corresponding to specified vehicle id. Request by date is inclusive. For example if a trip starts from 15:00 and ends at 16:00. A request from 15:15 to 15:45 will return this trip.
XeeRequestManager.shared.getTrips(WithVehicleID: <Vehicle ID>, completionHandler: { (error, trips) in
// Your code here
})
Manage oAuth authorizations
Revokes the specified authorization
// TODO
Returns authorizations corresponding to specified user id
// TODO
We're working hard to provide you an issue free SDK, but we're just humans so we can do mistakes.
If you find something, feel free to fill an issue or/and fork the repository to fix it !
Xee, jbdujardin@xee.com
XeeSDK is available under the Apache License 2.0. See the LICENSE file for more info.