This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
developers:peig-api:ios [2016/10/26 09:01] 127.0.0.1 external edit |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== iOS implementation of PEIG API ====== | ||
- | |||
- | //See [[https:// | ||
- | |||
- | ===== 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: | ||
- | |||
- | * <font inherit/ | ||
- | |||
- | Session is authenticated. | ||
- | |||
- | * <font inherit/ | ||
- | |||
- | PEIG is not installed, code | ||
- | |||
- | <code objc> | ||
- | [[PeigApiLib sharedInstance] openAppStoreDetail] | ||
- | </ | ||
- | |||
- | opens ITUNES detail page. | ||
- | |||
- | * <font inherit/ | ||
- | |||
- | other exception / redirect / state. | ||
- | |||
- | Custom application errors, authentication failed! | ||
- | |||
- | * <font inherit/ | ||
- | * <font inherit/ | ||
- | * <font inherit/ | ||
- | * <font inherit/ | ||
- | * <font inherit/ | ||
- | |||
- | <font 11pt/ | ||
- | |||
- | ===== 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 <font inherit/ | ||
- | |||
- | ===== 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 // | ||
- | |||
- | {{: | ||
- | |||