This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
developers:peig-api:ios [2019/08/01 10:03] tjotov removed |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== iOS implementation of PEIG API ====== | ||
| - | |||
| - | ===== Description ===== | ||
| - | |||
| - | Integration of PEIG API for iOS platform is implemented by using framework in targeted application. Framework, named as // | ||
| - | |||
| - | It is recommended to use Xcode 6.4 for using PeigApiLib framework. | ||
| - | |||
| - | ===== How integrate PEIG API framework ===== | ||
| - | |||
| - | Framework // | ||
| - | |||
| - | {{ : | ||
| - | |||
| - | Framework contains next important classes (public headers): | ||
| - | |||
| - | * PeigApiLib.h - Contains main method for call ADUCID authentication and for another ADUCID operations | ||
| - | * LibServiceDelegate.h - Allow send message to another object, that ADUCID authentication (or another operation) is completed, Success or Failed | ||
| - | * ApiResult.h - Class manages ADUCID authentication result | ||
| - | |||
| - | In the source code, use the following import | ||
| - | |||
| - | <code objc> | ||
| - | # | ||
| - | |||
| - | # | ||
| - | </ | ||
| - | |||
| - | Class LibServiceDelegate has two methods: | ||
| - | |||
| - | <code objc> | ||
| - | -(void) onSuccess: | ||
| - | |||
| - | -(void) onFailed: | ||
| - | </ | ||
| - | |||
| - | ===== How authenticate with PEIG ===== | ||
| - | |||
| - | First, import class: | ||
| - | |||
| - | <code objc> | ||
| - | # | ||
| - | </ | ||
| - | |||
| - | Thereafter call method: | ||
| - | |||
| - | <code objc> | ||
| - | [[PeigApiLib sharedInstance] aducidAuthenticate: | ||
| - | |||
| - | } withDataSourceErrorHandler: | ||
| - | |||
| - | }]; | ||
| - | </ | ||
| - | |||
| - | where: | ||
| - | |||
| - | * url - is NSString, in format < | ||
| - | * delegate - is < | ||
| - | |||
| - | LoginViewController implements LibServiceDelegate and methods: | ||
| - | |||
| - | <code objc> | ||
| - | -(void) onSuccess: | ||
| - | ... | ||
| - | } | ||
| - | |||
| - | -(void) onFailed: | ||
| - | ... | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | See DemoBank application, | ||
| - | |||
| - | ===== Response ApiResult ===== | ||
| - | |||
| - | Your code should evaluate these possible outcomes: | ||
| - | |||
| - | <code objc> | ||
| - | if [result isOK] | ||
| - | </ | ||
| - | |||
| - | Session is authenticated. | ||
| - | |||
| - | <code objc> | ||
| - | else if [result peigNotInstalled] | ||
| - | </ | ||
| - | |||
| - | PEIG is not installed, code | ||
| - | |||
| - | <code objc> | ||
| - | [[PeigApiLib sharedInstance] openAppStoreDetail] | ||
| - | </ | ||
| - | |||
| - | opens ITUNES detail page. | ||
| - | |||
| - | <code objc> | ||
| - | else | ||
| - | </ | ||
| - | |||
| - | other exception / redirect / state. | ||
| - | |||
| - | Custom application errors, authentication failed! | ||
| - | |||
| - | * <code objc> | ||
| - | * <code objc> | ||
| - | * <code objc> | ||
| - | * <code objc> | ||
| - | * <code objc> | ||
| - | |||
| - | See ApiResult class for all details. | ||
| - | |||
| - | ===== Handle result from PEIG ===== | ||
| - | |||
| - | PeigApiLib works with URI scheme. It is important to forward URi request from PEIG to PeigApiLib. Please, see class THAppDelegate in DemoBank application. | ||
| - | |||
| - | <code objc> | ||
| - | - (BOOL)application: | ||
| - | |||
| - | { | ||
| - | |||
| - | [[PeigApiLibsharedInstance]handleOpenURL: | ||
| - | |||
| - | returnYES; | ||
| - | |||
| - | } | ||
| - | </ | ||
| - | |||
| - | Method handleOpenURL is defined in protocol class **UIApplicationDelegate**. | ||
| - | |||
| - | ===== Retrieving data when it is authenticated ===== | ||
| - | |||
| - | In case ApiResult is “OK” and mobile application is authenticated, | ||
| - | |||
| - | You can use GET or POST operations. See PeigApiLib class. | ||
| - | |||
| - | <code objc> | ||
| - | - (void) getAducidOperation: | ||
| - | |||
| - | - (void) postAducidOperation: | ||
| - | </ | ||
| - | |||
| - | **url** | ||
| - | |||
| - | **params** | ||
| - | |||
| - | **delegate** | ||
| - | |||
| - | Please, have a look at class PaymentViewController in DemoBank application. There is the example how to use POST request. | ||
| - | |||
| - | ==== Try to get data if it is not authenticated ==== | ||
| - | |||
| - | Check your setup, test if you get error response from the server. | ||
| - | |||
| - | ===== How PEIG starts mobile application ===== | ||
| - | |||
| - | PEIG sends response back to mobile application via URI scheme. Please, define URI scheme for your mobile application in // | ||
| - | |||
| - | {{: | ||
| - | |||