Explore Categories

 

 PDF

iOS Platform

This topic explains the prerequisites, the process of including and using Tally Authentication Library in the iOS application project, and the available API/methods.

Prerequisites

Tally Authentication Library uses Keychain to store login credentials locally. Mobile application developers should use the same provisioning profile across different versions of the application.

This allows the previously stored data to be used/consumed seamlessly while upgrading the application.

Tally Authentication Library Directory Structure

The directory structure of the Tally Authentication Library for iOS is shown below:

The library for iOS is contained in the TallyAuthenticationLibrary directory. This directory will further contain one file and five subdirectories. To support a specific mode (debug/release) and specific environment of execution (device/simulator), there are four subdirectories. Each subdirectory contains a specific TallyAuthenticationLibrary.a file.

Directory

Features

Description

Tally Authentication Library

Images

It contains all the images required by the Tally Authentication Library.

Add these images to the application project.

TallyAuthenticationLibrary.h

Add this .h file to the application project.

Debug-iphoneos

TallyAuthenticationLibrary.a

Use this .a file in the application which is running on a physical device in debug mode.

Debug-iphonesimulator

Use this .a file in the application running on a simulator (simulating iPhone 4 and above) in debug mode.

Release-iphoneos

Use this .a file in the application running on a physical device in release mode.

Release-iphonesimulator

Use this .a file in the application running on a simulator (simulating iPhone 4 and above) in release mode.

Including the Library in iOS Project

  1. Drag and drop the folder Images from the TallyAuthenticationLibrary directory to the application project.
    • Select the check box Copy item into destination group’s folder .
    • Select the check box Select add to targets .
  2. Drag and drop the TallyAuthenticationLibrary.h file to the project.
    • Select the check box Copy item into destination group’s folder .
    • Select the check box Select Add to targets .
  3. Add the file TallyAuthenticationLibrary.a from the corresponding folder to the project as per the environment (device/simulator) and mode (debug/release). To add the file:
    • Select the application project to go to the project editor.
    • Select the application target to go to the target editor.
    • Select the build phases tab .
    • Disclose the Link Binary with Libraries phase , and click the plus button in that phase.
    • Select Add Other…
    • Select the static library, and add it to the phase, to link the application to the static library.

Using the Library in iOS Development

  1. Include the following statement in the implementation file of the class where the user authentication functionality is to be added.

#import “TallyAuthenticationLibrary.h”

       2. Implement the following TallyAuthenticationDelegate protocol methods

  • Specify that the interface implements TallyAuthenticationDelegate .

@interface BaseClassName : NSObject < TallyAuthenticationDelegate >

  • Implement AuthenticationSuccessful delegate.

This delegate is called when the user is successfully authenticated.

//Implement cancel authentication library delegate method

-( void )AuthenticationSuccessful:( NSDictionary *)pAuthenticationDetails

{

NSLog ( @”User authentication successful with the following details” );

NSLog ( @” Tally.Net ID %@” , [pAuthenticationDetails objectForKey : @”TallyNetID” ]);

NSLog ( @”Library version %@” ,[pAuthenticationDetails objectForKey : @”LibraryVersion” ]);

NSLog( @”Session %@” , [pAuthenticationDetails objectForKey : @”SessionID” ]);

NSLog( @”Online mode %@” ,[pAuthenticationDetails objectForKey : @”OnlineMode” ]);

}

  • Implement AuthenticationCancelled delegate.

This delegate is called when the user cancels the authentication process by tapping Cancel .

//Implement cancel authentication library delegate method

-( void )AuthenticationCancelled:( NSDictionary *)pAuthenticationDetails

{

NSLog ( @”User cancelled authentication. Last known status details are as follows” );

NSLog ( @”Error code is %@” ,[pAuthenticationDetails objectForKey : @”ErrorCode” ];

NSLog ( @”ErrorDescription is %@” ,[pAuthenticationDetails +

objectForKey : @”ErrorDescription” ]);

NSLog ( @”Library version is %@” , [pAuthenticationDetails +

objectForKey : @”LibraryVersion” ]);

NSLog ( @”Online mode is %@” , [pAuthenticationDetails objectForKey : @”OnlineMode” ]);

}

Note: When the AuthenticationSuccessful/AuthenticationCancelled delegates are called:

♦ The login screen is removed from the UIWindow.

♦ Tally Authentication Library sets the original UIViewController as the present UIViewController.

♦ Application developers need to set the new screen (UIViewController) in these delegates.

3. Create an object of the class TallyAuthenticationLibrary .

TallyAuthenticationLibrary * AuthObj = [[ TallyAuthenticationLibrary alloc] init ];

//Assuming the class which instantiated this objected has implemented the Authentication Library delegate

[AuthObj SetDelegate : self ];

                                                                                                         OR

TallyAuthenticationLibrary * AuthObj = [[ TallyAuthenticationLibrary alloc]

initWithDelegate : self ];

4. Set the developer mode to yes when the application is in testing phase.

[AuthObj SetDeveloperMode : YES ];

5. Set the online mode before displaying the login screen.

[AuthObj SetOnlineMode : YES ];

                                                                   OR

[AuthObj SetOnlineMode : NO ];

6. Call the ShowLoginScreen method to display the login screen.

This method returns yes if the login screen is displayed successfully or it returns no .

if ([AuthObj ShowLoginView ])

{

if ([AuthObj ShowLoginView ])

{

NSLog ( @”Login Screen displayed Successfully” );

}

else

{

NSLog( @”Displaying login screen failed, make sure you have set the delegate” );

}

NSLog( @”Login Screen displayed Successfully” );

}

Else

{

NSLog ( @”Displaying login screen failed, make sure you have set the delegate” );

}

  Note:    The login screen is not displayed if the  AuthenticationLibraryDelegate  is not set. 

This library contains the following keys from which you can extract the details of authentication:

Dictionary Key

Purpose

Status

To check if the authentication process is successful or not.

1 – Success

0 – Failure

TallyNetID

Tally.NET ID is the value used to authenticate the user.

SessionID

Session ID is obtained from Tally.NET Server after successful authentication. If the authentication process fails, the value of session ID is empty.

OnlineMode

To check if the authentication is carried out in online or offline mode.

True – Online

False – Offline

LibraryVersion

To get the current version of the Tally Authentication Library.

ErrorCode

To get the error code for authentication failure.

ErrorDescription

To get the description of authentication failure .

API/Methods Provided

API/Methods of TallyAuthenticationLibrary are listed below:

API/Methods

Purpose

-(void)SetOnlineMode:(BOOL) pMode

To set the mode of operation, online or offline.

Default mode of authentication is online.

-(void)SetDelegate: (id<TallyAuthenticationDelegate>)pDelegate

To set the authentication delegate.

On authentication success or cancellation, delegate from this protocol is called.

-(BOOL)ShowLoginScreen

To display the login screen.

Yes – Success

No – Failure

 

TallyHelpwhatsAppbanner
Is this information useful?
YesNo
Helpful?
/* */