iOS SDK with UI

This document descibes steps to integrate iOS SDK with UI files.

Integration details

Repository Link: click here

Run this command (you need to have git installed.)

git clone https://dilip7@bitbucket.org/livquik/qwcore_ios_consumer.git

This will download and clone the repository on your machine.

Source Code in this repository has sample application in Objective-C to show how to integrate QuikWallet iOS SDK.

STEP 1 ) Drag and drop QWConsumer folder in your XCode project.

QWConsumer file is inside the repository you just cloned above.

STEP 2 ) Drag and drop QWCore_ios.framework in your XCode project.

Repository Link: click here download this , inside public_release folder QWCore_ios.framework is there. drag and drop in your project. You can refer QWConsumer as sample app(open in latest XCode) which has also included this framework file.

STEP 3) Initialize QWSdk

  • In your AppDelegate.m file first import QWCore_ios/QWSdk.h file

#import <QWCore_ios/QWSdk.h>

  • Optional - This step is needed only if for testing your integration, for production environment this is not needed.

Add the following line to the start of didFinishLaunchingWithOptions.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [QuikWallet setDefaultConfig:@"uat"]; // for testing purposes; not needed for live environment.

    return YES;
}

STEP 4) Usage in your ViewController.

Follow this steps

  • in viewDidLoad function of your viewController.m file
// inside ViewController.m file of your intended ViewController Screen
- (void)viewDidLoad {
    [super viewDidLoad];

    /*
      Register this Notification Receivers in viewDidLoad.
      QW_PAYMENT_SUCCESS_NOTIFICATION - triggered when payment happens successfully.
    */

    [[NSNotificationCenter defaultCenter]
     addObserver:self selector:@selector(success:) name:QW_PAYMENT_SUCCESS_NOTIFICATION object:nil];

    /*
    QW_PAYMENT_FAILURE_NOTIFICATION - triggered when some error occured while conducting a payment. 
    */
    [[NSNotificationCenter defaultCenter]
     addObserver:self selector:@selector(failure:) name:QW_PAYMENT_FRAILURE_NOTIFICATION object:nil];

    self.navigationItem.title = @"QuikWallet Consumer";
}

  • Perform an action like ; conduct a payment or show user saved cards.
// This code shows how to make a payment of 50 Rupees.
- (IBAction)showCards:(id)sender {
    NSDictionary *dict = @{

        @"mobile":@"8762070029",
        @"signature": @"55c657c645cfe150f1dad8e891366789211f0397e6b5626cb3b2c8c608390bff",
        @"partnerid": @"10",
        @"amount": @"50"
    };

    NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithDictionary:dict];

    QWConsumer *qw = [[QWConsumer alloc] init];
    [qw showCards:data :self.navigationController]; // pass reference to self.navigationController 
}

  • write listeners for success and failure notifications
// success notification listener

-(void) success:(NSNotification*)notification{
    NSLog(@"Received notification");
    NSDictionary* dict = notification.userInfo;
    NSLog(@"Success data %@", dict);

    [self.navigationController popToRootViewControllerAnimated:YES];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
                                                    message: @"Your payment was successful!"
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];

}

// failure notification listener

-(void) failure:(NSNotification*)notification{
    NSLog(@"Received notification failure %@",notification);
}

Refer sample ViewController.m file inside the repository downloaded at the beginning of document to see Show cards code.