This is an old revision of the document!
See DemoBank example
Integration of PEIG API for iOS platform is implemented by using framework in targeted application. Framework, named as PeigApiLib.framework, is part of the package. This framework is archived as ZIP file. Must be extracted on OSX system, because contains symlinks (symlinks doesn't work on Windows system).
It is recommended to use Xcode 6.4 for using PeigApiLib framework.
Framework PeigApiLib.framework must be included into Xcode project, in project settings, choose Build Phases, section Link Binary With Libraries, see below image.
Framework contains next important classes (public headers):
In the source code, use the following import
#import<PeigApiLib/LibServiceDelegate.h> #import<PeigApiLib/ApiResult.h>
Class LibServiceDelegate has two methods:
-(void) onSuccess:(ApiResult*) result; -(void) onFailed:(NSString*) error;
First, import class:
#import<PeigApiLib/PeigApiLib.h>
Thereafter call method:
[[PeigApiLib sharedInstance] aducidAuthenticate:url withDelegate:delegate withDataSourceCompletionHandler:^(ApiResult* result) { } withDataSourceErrorHandler:^(NSString *error) { }];
where:
LoginViewController implements LibServiceDelegate and methods:
-(void) onSuccess:(ApiResult *) result { ... } -(void) onFailed:(NSString *) error { ... }
See DemoBank application, class LoginViewController and other, eg. CHService. To the evaluate ApiResult - see PEIG API documentation.
Your code should evaluate these possible outcomes:
if [result isOK]
Session is authenticated.
else if [result peigNotInstalled]
PEIG is not installed, code
[[PeigApiLib sharedInstance] openAppStoreDetail]
opens ITUNES detail page.
else
other exception / redirect / state.
Custom application errors, authentication failed!
<font 11pt/inherit;;inherit;;inherit>See ApiResult class for all details.</font>
PeigApiLib works with URI scheme. It is important to forward URi request from PEIG to PeigApiLib. Please, see class THAppDelegate in DemoBank application.
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url { [[PeigApiLibsharedInstance]handleOpenURL:url]; returnYES; }
Method handleOpenURL is defined in protocol class <font inherit/inherit;;black;;inherit>UIApplicationDelegate.</font>
In case ApiResult is “OK” and mobile application is authenticated, use this session to contact your application server by using PeigApiLib library.
You can use GET or POST operations. See PeigApiLib class.
- (void) getAducidOperation:(NSString*)url withParameters:(id)params withDelegate:(id<LibServiceDelegate>)delegate withDataSourceCompletionHandler:(void (^) (ApiResult*))successDataHandler withDataSourceErrorHandler:(void (^)(NSString*))failureDataHandler; - (void) postAducidOperation:(NSString*)url withParameters:(id)params withDelegate:(id<LibServiceDelegate>)delegate withDataSourceCompletionHandler:(void (^) (ApiResult*))successDataHandler withDataSourceErrorHandler:(void (^)(NSString*))failureDataHandler;
url - target page or method URL, e.g. https://demobank.aducid.com/demobank/payment
params - reference to object with parameters, e.g. NSDictionary object in DemoBank application, class CHService
delegate - reference to delegate for callback when data is loaded
Please, have a look at class PaymentViewController in DemoBank application. There is the example how to use POST request.
Check your setup, test if you get error response from the server.
PEIG sends response back to mobile application via URI scheme. Please, define URI scheme for your mobile application in info.plist file. For DemoBank application is defined as aducid-demobank. See image below: