This is swift project example to connect VNPTSmartCA SDK using Swift Language.

Overview

Example source code to integrate with VNPTSmartCA iOS SDK

To run the example project, clone repository, and run pod install

Requirements

Installation

VNPT SmartCA iOS SDK is available through CocoaPods. To install it, simply add the following line to your Podfile.

pod 'VNPTSmartCAiOSSDK'

At a minimum, VNPT SmartCA iOS SDK is designed to work with iOS 9.0 or the newest.

Configure Steps

Step 1: Config file pList

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLName</key>
    <string></string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>partnerSchemeId</string>
    </array>
  </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>vnptsmartca</string>
  <string>vnptsmartcademo</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
  • CFBundleURLTypes: Add scheme value. Note: partnerSchemeId provided by VNPT SmartCA. It's clientId.
  • LSApplicationQueriesSchemes: Add the scheme as vnptsmartca and vnptsmartcademo.

Step 2: Import SDK in AppDelegate instance

import VNPTSmartCAiOSSDK // You need import before using

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    VNPTSmartCATransaction.receiveBackLink(url: url, sourceApp: sourceApplication!)
    return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
    VNPTSmartCATransaction.receiveBackLink(url: url, sourceApp: "")
    return true
}

Note: To iOS 13 or the newest, you need import SDK in SceneDelegate.swift file

import VNPTSmartCAiOSSDK // You need import before using

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    VNPTSmartCATransaction.receiveBackLink(url: URLContexts.first!.url, sourceApp: "")
}

Step 3: Update layout and pass required param to open VNPT SmartCA App

Note:

  • NotificationCenter registration VNPTSMARTCA NOTIFICATION KEYS should be removed when the ViewControllers relocating or dismissing completed
  • Notification keys: <VNPTSmartCA>NotificationCenterReceived
  • Before start open VNPT SmartCA app, you need specific environment to integrate by VNPTSmartCATransaction.setEnvironment function. Have two choices: VNPTSmartCATransaction.ENVIRONMENT.DEMO and VNPTSmartCATransaction.ENVIRONMENT.PRODUCTION.
import VNPTSmartCAiOSSDK // You need import before using

override func viewDidLoad() {
    //STEP 1: addObserver Notification
    NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: "<VNPTSmartCA>NotificationCenterReceived"), object: nil)
    NotificationCenter.default.addObserver(self, selector: #selector(self.NotificationCenterTokenReceived), name:NSNotification.Name(rawValue: "<VNPTSmartCA>NotificationCenterReceived"), object: nil)
    
    //STEP 2: INIT TRANSACTION BASIC INFO AS CLIENT ID AND TRAN ID
    let tranInfo: NSMutableDictionary = NSMutableDictionary()

    tranInfo["clientId"] = "partnerSchemeId" // You need pass your client ID replace for 'partnerSchemeId'.
    tranInfo["tranId"] = "transactionId" // You need pass your transaction ID replace for 'transactionId'.
    
    VNPTSmartCATransaction.setEnvironment(_environment: VNPTSmartCATransaction.ENVIRONMENT.DEMO)
    VNPTSmartCATransaction.createTransactionInformation(info: tranInfo)
    
    //STEP 3: INIT LAYOUT - ADD BUTTON OPEN VNPTSMARTCA
    let buttonOpen = UIButton()
    buttonOpen.frame = CGRect(x: 20, y: 200, width: 260, height: 40)
    buttonOpen.setTitle("Open VNPT SmartCA", for: .normal)
    buttonOpen.setTitleColor(UIColor.white, for: .normal)
    buttonOpen.titleLabel!.font = UIFont.systemFont(ofSize: 15)
    buttonOpen.backgroundColor = UIColor.blue
    
    buttonOpen.addTarget(self, action: #selector(self.openApp), for: .touchUpInside)
    self.view.addSubview(buttonOpen)
}

@objc func openApp() {
    VNPTSmartCATransaction.handleOpen()
}
// You can listen return event from VNPTSmartCA app in here
@objc func NotificationCenterTokenReceived(notify: NSNotification) {
    let response: NSMutableDictionary = notify.object! as! NSMutableDictionary
        
    let _statusStr = "\(response["status"] as! String)"
    let _message = response["message"]
    
    if (_statusStr == "0") {
        print("Status code: \(_statusStr)")
        print("Message:", _message as! String)
    } else {
        
    }
}

Request param

Param Description
tranId When you request create a signature transaction to VNPT SmartCA System by API, you'll receive tranId.
clientId When you request integrate with VNPT SmartCA System. You'll receive a clientId.

Response status code table

Code Description
0 Success
1 User rejected
60000 Credential not exist
60001 Credential not match identity
60002 Credential no result
60003 Credential status invalid
61000 Credential assign key failed
62000 Signature transaction not found
62001 Signature transaction not match identity
62002 Signature transaction expired
62003 Signature transaction not waiting
62010 Signature data request invalid format
63000 Credential sign signer authen failed
63001 Credential sign init hash signer failed
63002 Credential sign file upload failed
64000 Credential sign file not support file type
64001 Credential acceptance generate file failed
64002 Credential acceptance transaction exist

Author

VNPT SmartCA Development Team

Copyright©

Copyright (c) 2021 VNPTSmartCA.

Version

1.0.2

Contact - Support

email: [email protected]

You might also like...
Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API.
RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API.

RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API. The goal for development was to have a Swift SDK to get

Home-assistant-swift-sdk - Used to integrate the Home Assistant APIs with your Swift-based apps.

home-assistant-swift-sdk This open-source library allows you to interact with a Home Assistant instance in your Swift-based (e.g., iOS, macOS, etc.) a

 Official Appwrite Swift SDK 🦅🍎
Official Appwrite Swift SDK 🦅🍎

Appwrite Swift SDK This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check previous releases. This is the Swift S

Swift SDK for Blockfrost.io API
Swift SDK for Blockfrost.io API

Swift5 API client for Blockfrost Swift 5 SDK for Blockfrost.io API. Installation • Usage • API Endpoints Installation Swift package manager dependenci

WalletConnect Swift SDK v2

Wallet Connect v.2 - Swift Swift implementation of WalletConnect v.2 protocol for native iOS applications. Requirements iOS 13 XCode 13 Swift 5 Usage

MpesaSDK - Swift SDK for the M-Pesa API (Mozambique)
MpesaSDK - Swift SDK for the M-Pesa API (Mozambique)

M-Pesa SDK Swift package for M-Pesa API (Mozambique) Ready Methods/APIs C2B B2B

MetaWear-Swift-Combine-SDK - Build iOS and macOS apps controlling MetaWear Bluetooth Low Energy wearables without C++ or CoreBluetooth expertise
Swift SDK for Apache Kafka

SwiftKafka A swift implementation of Kafka for producing and consuming from event streams. This works by wrapping the librdkafka C library. Swift vers

Releases(1.0.0)
Owner
null
Native iOS port of KDE Connect

Welcome to KDE Connect iOS 2021's Testing Repository! This project is inteded to be the iOS version of the group of applications called KDE Connect, w

KDE GitHub Mirror 292 Dec 27, 2022
Zilla connect is an easy, fast and secure way for your users to buy now and pay later from your app

Zilla Checkout iOS SDK Zilla connect is an easy, fast and secure way for your us

null 0 Jan 19, 2022
Px-mobile-sdk-demo-app - PerimeterX Mobile SDK - Demo App

About PerimeterX PerimeterX is the leading provider of application security solu

PerimeterX 1 Nov 20, 2022
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter 45 Nov 29, 2022
Sample project with local swift package linked NDI SDK.

NDISwiftPackage Sample project with local swift package linked NDI SDK. Preparation Install NDA SDK on your mac. Software Developer Kit Make package c

Naruki Chigira 4 Dec 20, 2022
An SDK project to facilitate connectivity with an IBM Cloudant Database

Create an infinite scrolling iOS application in Swift, backed by a NoSQL databas

Floren Cabrera F.:  de Teresa 0 Jan 15, 2022
Example project which uses Machine Learning frameworks to detect things

ML_IOS Example project which uses Machine Learning frameworks to detect things. Features Object Detection Text Detection Face Detection Audio Detectio

Simranjeet 2 Dec 31, 2021
SingleEntry in SwiftUI using the Capture SDK

SingleEntrySwiftUI for iOS Simple iOS app with SwiftUI for showing the use of Capture SDK. IMPORTANT When using/installing CocoaPods in a new project,

Taif Al Musabe 2 Jun 4, 2022
Sample app to demonstrate the integration code and working of Dyte SDK for iOS, using Objective-C.

iOS sample app (using Objective-C) by dyte Sample app to demonstrate the usage of Dyte iOS SDK Explore the docs » View Demo · Report Bug · Request Fea

Dyte 8 Nov 26, 2021
This repository is for the iOS sample application using ARGear SDK.

ARGear sample application for iOS (c) Copyright 2021 Seerslab. All rights reserved. This repository contains an iOS sample application that uses ARGea

ARGear 2 Apr 5, 2022