|ReleasedLast Release||Nov 2016|
Maintained by Seva Billevich.
|Apps WeekApps This Week||5|
|Test WeekTests This week||1|
|LOCLines of Code||0|
As an example, you are welcome to use our Template Project from Aviasales-iOS-SDK repo.
The easiest way is to use CocoaPods. It takes care of all required frameworks and third party dependencies:
pod 'AviasalesSDK', '~> 2.0.0'
We recommend to import
AviasalesSDK.h in each file where you use objects or protocols from SDK.
AviasalesSDK object before interaction with SDK like this:
AviasalesSDKInitialConfiguration *configuration = [AviasalesSDKInitialConfiguration configurationWithAPIToken:@"Your api token here" APILocale:[NSLocale currentLocale].localeIdentifier partnerMarker:@"Your partner marker here"]; [AviasalesSDK setupWithConfiguration:configuration];
Don't forget to replace two placeholders in this example with the actual values.
Specify search parameters using any object that confirms to
JRSDKSearchInfo protocol. Simple implementation of this protocol available in
JRSDKConfigurableSearchInfo interface, but feel free to create your own if needed. Look at the example below.
Create simple object that describes new search:
JRSDKConfigurableSearchInfo *searchInfo = [[JRSDKConfigurableSearchInfo alloc] init];
Set necessary parameters for the search (adults = 2 and travelClass = Business means that two adults would like to travel in business class):
searchInfo.adults = 2; searchInfo.travelClass = JRSDKTravelClassBusiness;
Set travel dates and airports (using airports storage from the SDK):
JRSDKConfigurableTravelSegment *firstTravelSegment = [[JRSDKConfigurableTravelSegment alloc] init]; firstTravelSegment.departureDate = [NSDate date]; firstTravelSegment.originAirport = [[AviasalesSDK sharedInstance].airportsStorage findAnythingByIATA:@"LED"]; firstTravelSegment.destinationAirport = [[AviasalesSDK sharedInstance].airportsStorage findAnythingByIATA:@"MOW"];
Save that travel segment to the search info:
searchInfo.travelSegments = [NSOrderedSet orderedSetWithObject:firstTravelSegment];
That's it. Search info is ready for search.
To perform search request use
SearchPerformer received from the SDK and send search info to it. Don't forget to store this performer somewhere during the search process.
JRSDKSearchPerformer *searchPerformer = [[AviasalesSDK sharedInstance] createSearchPerformer];
To retrieve live and final search results set delegate (
JRSDKSearchPerformerDelegate) to this search performer:
searchPerformer.delegate = self;
This delegate requires to implement three methods: first one needed to receive live search results
- (void)searchPerformer:(JRSDKSearchPerformer *)searchPerformer didFinishRegularSearch:(id<JRSDKSearchInfo>)searchInfo withResult:(id<JRSDKSearchResult>)result;
Second needed to receive error if it occures during the search
- (void)searchPerformer:(JRSDKSearchPerformer *)searchPerformer didFailSearchWithError:(NSError *)error connection:(JRServerAPIConnection *)connection;
And the third one needed to understand when the process is finished. After its call, you can release search performer because it is not recyclable.
- (void)searchPerformer:(JRSDKSearchPerformer *)searchPerformer didFinalizeSearchWithInfo:(id<JRSDKSearchInfo>)searchInfo error:(NSError *)error;
Start search performing:
[searchPerformer performSearchWithSearchInfo:searchInfo includeResultsInEnglish:YES];
Search result is provided with
||this parameter is necessary in purchase process|
||tickets that found exactly between requested airports|
||tickets that found between cities (metropolitan areas) that is near to requested airports|
AviasalesSDKPurchasePerformer is object used to perform ticket purchase. Each ticket contains different prices, you should use one of them as an input parameter.
Create performer using price and searchId that was returned with the search result.
- (instancetype)initWithPrice:(id <JRSDKPrice>)price searchId:(NSString *)searchId;
and start purchase using a method
- (void)performWithDelegate:(id <AviasalesSDKPurchasePerformerDelegate>)delegate;
Open link received by delegate in browser to provide user purchase form.
Aviasales SDK allows you to generate additional revenue by displaying advertisements to your users.
AviasalesSDKAdsManager object received like:
to load information for the waiting screen
- (void)loadAdsViewForWaitingScreenWithSearchInfo:(id <JRSDKSearchInfo>)searchInfo completion:(AviasalesSDKAdsManagerCompletion)completion;
or for the search results list with your search info.
- (void)loadAdsViewForSearchResultsWithSearchInfo:(id <JRSDKSearchInfo>)searchInfo completion:(AviasalesSDKAdsManagerCompletion)completion;
After appropriate method call you will receive
AviasalesSDKAdsView with ads.
|Name||How to retrieve object||Description|
||Finds airport by IATA, provides a list of airports|
||Finds airports by string|
||Finds nearest airports to the current user.|
||Loads and displays advertisement according to search parameters|
||Util methods that help you to work with SDK objects|