SDK

Android Native:


1. Download SDK Files. 

2. Add Client ID in VNPassRequestModels.java

3. Add Client Secret in VNPassRequestModels.java

4. Add Redirect URL in VNPassRequestModels.java

5. Choose the Environment, Whether it is staging or production.

6. In the activity from where VN Pass Authentication is required, copy the "Adding Custom Scheme and Host" section to the AndroidManifest file to that particular activity, and make the launch mode as singleTask. (android:launchMode="singleTask").

7. In the modules Build.gradle file, copy the "Adding Custom Scheme Variables" section to the defaultConfig.

8. Change "URI_SCHEME" and "scheme" value to your app name. 

This is a mandatory step to avoid conflicting with other apps in the future.



9. Check whether the project has Kotlin enabled. If not, open app level Build.gradle and copy "Enable Kotlin Version" and "Enable Kotlin Dependency" to respective place. Also in the modules Build.gradle, copy "Enable Kotlin Dependency" section to the dependencies.

10. In the Activity from where VNPass Authentication is triggered, copy the section "Callback to handle VNPass callback". 

A global search can be made for the term "//VNPASS" which will display the modifications that are required to be made.


 

iOS Native


1. Download SDK Files

2. Setup the Framework. 

                      - Create LocalPods folder if not already created.

                      - Add VNPASSClient folder in LocalPods folder.

                      - Add pod 'VNPassClient', :path => "LocalPods/VNPassClient" to your podfile.

3. Open AppDelegate and add the following: 

                      - import VNPassClient

4. In didFinishLaunchingWithOptions, add the below:

VNPASSRouter.shared.spConfig = SPConfig(redirectUriLogin: "client redirect url",
                                         scope: "client login scope",
                                         state: "RANDOM 24 alpha numeric",  //Randomly Generated Code 24 alpha numeric.
                                         successSchemeURL: "UUUUU://", //client success url scheme.
                                         failSchemeURL: "CCCCC://", //client failure url scheme.
                                         signingScope: "urn:safelayer:eidas:sign:process:document") // client signing scope.
VNPASSRouter.shared.environmentConfig = VNPassConfig(clientID: "your client id", clientSecret: "your client secret", env: .production)
env (environment can be : .production or .qa or .dev)
func application(_: UIApplication, handleOpen url: URL) -> Bool {
    print("<><><><> appDelegate URL : (url.absoluteString)")
    if url.absoluteString.contains(HandleURLScheme.externalURLSchemeSuccess()) {
        if let topViewController = UserInterfaceInfo.topViewController() {
            if let webViewController = topViewController as? VNPassWebViewController {
                webViewController.forceReload()
            }
        }
        return true
    }

    else if url.absoluteString.contains(HandleURLScheme.externalURLSchemeFail()) {
        guard let webViewController = UserInterfaceInfo.topViewController() as? VNPassWebViewController  else {
            return false
        }
        webViewController.foreceStop()
        let alertController = UIAlertController(title: "Failed to login with VN PASS Login", message: "Try again later", preferredStyle: .actionSheet)
        let okAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default) {
            _ in
            NSLog("OK Pressed")
            webViewController.navigationController?.popViewController(animated: true)
        }
        alertController.addAction(okAction)
        self.window?.rootViewController?.present(alertController, animated: true, completion: nil)
        return false
    }

    return true
}


 5. Add VNPass scheme in your project info.plist in LSApplicationQueriesSchemes (Already added in this sample). 

for Production: vnpass
for QA: vnpassstg
for DEV: vnpassdev


6. After pressing login with VNPASS button, choose the prefered environment to login through UIAlertController and from this action a trace can be done to show how it works. 

7. From application(_: UIApplication, handleOpen url: URL) -> Bool in AppDelegate 

Apply a force to current webview to reload or stop loading incase of success or failure.



This sample contains three view controllers :

           -- ViewController.swift (main screen which contains login button and UIAlertController to select required environment).

           -- UserProfileViewController.swift (Just simple view to show user profile details and it contains sign document scneario as well).

           -- VNPassWebViewController.swift (Resposible for handling webView requests to generate vnpass code to use it for token generation).


8. For the Signing Flow, the following steps is required: 

1. It should be a valid PDF document, and the sample code for downloading the pdf file is given.

2. A valid token should be generated for the signing process.

3. The valid pdf document should then be uploaded to VNPASS.

4. After the upload, a request for signing should be sent. The following can then be selected: 

       Signature type: Advanced or Qualified

       The page which signature will be placed

       Signature coordinates and Signature size

9. testSignData.json is a very important file as this is the signing information which should be passed to VNPASS and it is expected to be recieved from the backend. It is also required to be reconfigured to add SP's own app scheme.

This sample supports dark mode as well.



For visitor integration: SP need to use the below scopes to their first authentication call to retrieve the unifiedID and profileType attribute of the user: 

 scope=urn:vn:digitalid:profile:general urn:vn:digitalid:profile:general:profileType urn:vn:digitalid:profile:general:unifiedId

Was this helpful?

Thank you!

Hotline Hotline