User Tools

Site Tools


developers:peig-api:ios

This is an old revision of the document!


iOS implementation of PEIG API

See DemoBank example

Description

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.

How integrate PEIG API 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):

  • 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

#import<PeigApiLib/LibServiceDelegate.h>
 
#import<PeigApiLib/ApiResult.h>

Class LibServiceDelegate has two methods:

-(void) onSuccess:(ApiResult*) result;
 
-(void) onFailed:(NSString*) error;

How authenticate with PEIG

First, import class:

#import<PeigApiLib/PeigApiLib.h>

Thereafter call method:

[[PeigApiLib sharedInstance] aducidAuthenticate:url withDelegate:delegate withDataSourceCompletionHandler:^(ApiResult* result) {
 
    } withDataSourceErrorHandler:^(NSString *error) {
 
}];

where:

  • url - is NSString, in format [protocol]://[domain]/[path]/, in DemoBank application is https://demobank.aducid.com/demobank/
  • delegate - is id<LibServiceDelegate>, typically reference to ViewController, see DemoBank, class LoginViewController.h

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.

Response ApiResult

Your code should evaluate these possible outcomes:

  • <font inherit/inherit;;black;;inherit>if [</font><font inherit/inherit;;black;;inherit>result</font><font inherit/inherit;;rgb(38, 71, 75);;inherit>isOK</font><font inherit/inherit;;black;;inherit>]</font>

Session is authenticated.

  • <font inherit/inherit;;black;;inherit>else if [</font><font inherit/inherit;;black;;inherit>result</font><font inherit/inherit;;rgb(38, 71, 75);;inherit>peigNotInstalled</font><font inherit/inherit;;black;;inherit>]</font>

PEIG is not installed, code

[[PeigApiLib sharedInstance] openAppStoreDetail]

opens ITUNES detail page.

  • <font inherit/inherit;;black;;inherit>else</font>

other exception / redirect / state.

Custom application errors, authentication failed!

  • <font inherit/inherit;;black;;inherit>result</font><font inherit/inherit;;rgb(38, 71, 75);;inherit>.exception</font>contains ADUCID exception, there are possible states:
    • <font inherit/inherit;;black;;inherit>[result notAcceptedByUser]</font>: user rejected
    • <font inherit/inherit;;black;;inherit>[result isFactorAbsent]</font>: user doesn’t have personal factor (and server requires it)
  • <font inherit/inherit;;black;;inherit>result.data</font>contains error Message / reason
  • <font inherit/inherit;;black;;inherit>[</font><font inherit/inherit;;black;;inherit>result</font><font inherit/inherit;;rgb(38, 71, 75);;inherit>doRedirect</font><font inherit/inherit;;black;;inherit>], result.</font><font inherit/inherit;;rgb(63, 110, 116);;inherit>redirect</font>contains page that could be opened using browser / contains additional content to download / display to the user.

<font 11pt/inherit;;inherit;;inherit>See ApiResult class for all details.</font>

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.

- (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>

Retrieving data when it is authenticated

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.

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 info.plist file. For DemoBank application is defined as aducid-demobank. See image below:

developers/peig-api/ios.1531226100.txt.gz · Last modified: 2018/07/10 12:35 by dskrbek