Aftership iOS SDK
AfterShip API SDK for iOS
Compatible with Aftership API v4
This project is looking for maintainers
If you would like to be a maintainer of this project, please reach out through our public slack channel Slack AfterShip-SDKs to express your interest. Thanks in advance for your help!
Installation
The recommended approach for installing Aftership iOS SDK is via the CocoaPods.
via CocoaPods
pod 'Aftership-iOS-SDK', '~> 1.1.9'
via source code
Developer can download source code here and integrate it with your project. Note that this project depends on RestKit for network and RXPromise for tests. Developers have to also include them for compilation.
Usage
Aftership iOS SDK is essentially a collection of requests to consume Aftership APIs. Before execute any request, a client must be prepared:
AftershipClient *client = [AftershipClient clientWithApiKey:@"YOUR_API_KEY"];
and then execute requests with it:
AftershipGetAllCouriersRequest *request = [AftershipGetAllCouriersRequest requestWithCompletionBlock:^(AftershipAbstractRequest *request,
AftershipGetCouriersResponse *response,
NSError *error) {
if(error)
{
//handle failure
} else
{
//handle results
}
}];
[client executeRequest:request];
Tracking
Create tracking
AftershipTracking *newTracking = [[AftershipTracking alloc] init];
newTracking.trackingNumber = [NSString stringWithFormat:@"1111111111"];
newTracking.slug = @"dhl";
newTracking.emails = @[@"123@123.com"];
newTracking.title = @"new tracking 1";
AftershipCreateTrackingRequest *request = [AftershipCreateTrackingRequest requestWithTracking:newTracking completionBlock:^(AftershipCreateTrackingRequest *request, AftershipTracking *tracking, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSLog(@"%@", tracking);
}
}];
[client executeRequest:request];
Get tracking
AftershipGetTrackingRequest *request = [AftershipGetTrackingRequest requestWithTrackingNumber:@"1111111111" slug:@"dhl" completionBlock:^(AftershipGetTrackingRequest *request, AftershipTracking *tracking, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSLog(@"%@", tracking);
}
}];
[client executeRequest:request];
Get trackings
AftershipGetTrackingsRequest *request = [AftershipGetTrackingsRequest requestWithCompletionBlock:^(AftershipGetTrackingsRequest *request, AftershipGetTrackingsResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSLog(@"%@", response.trackings);
}
}];
[client executeRequest:request];
Delete tracking
AftershipDeleteTrackingRequest *request = [AftershipDeleteTrackingRequest requestWithTrackingNumber:@"1111111111" slug:@"dhl" completionBlock:^(AftershipDeleteTrackingRequest *request, AftershipTracking *tracking, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSLog(@"%@", tracking);
}
}];
[client executeRequest:request];