Mobile SDK's
iOS

iOS sdk

Installation

Justpass.me iOS sdk supports installation with CocoaPods. Here's how to install the sdk using CocoaPods:

  • Note: To ensure proper functionality and compatibility with the project, it is essential to use a minimum version of CocoaPods 16.2.
  1. First open the command line terminal and open the root project file directory for iOS:

    cd Macintosh HD/Users/username/Documents/example_project/ios
  2. open your pod file to add the justpass-me pod.

    open Podfile
  3. Edit the Podfile and add.

    pod 'justpass-me'
  4. Install the pods, then open your .xcworkspace file to see the project in Xcode:

    pod install --repo-update
    open {your-project}.xcworkspace

Setup

  • Note: The following steps will require that you are subscribed to the apple devleoper program. or make sure to be a member of your apple developer team.

  • Open justpass.me dashboard. head to Settings -> iOS App info and update the Apple package: <Application Identifier Prefix>.<Bundle Identifier> ( e.g. T9C4QJ8225.org.cocoapods.demo.justpass-me-Example )

  • Make sure to add webcredentials:{your-app-domain}.accounts.justpass.me to your app associated domains (opens in a new tab)

Usage

in Swift import JustPassMeFramework and instantiate JustPassMeClient with the current window. JustPassMeClient provides 2 asynchronous methods for using passkeys:

  • register: takes registrationURL and and extraClientHeaders as parameters
  • authenticate: takes authenticationURL and and extraClientHeaders as parameters

Here is a code excerpt that shows using the authenticate method on clicking the Login button

import UIKit
import JustPassMeFramework
 
class ViewController: UIViewController {
 
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    @IBAction func Login(_ sender: UIButton) {
        if #available(iOS 16.0, *) {
            Task { @MainActor in
                do {
                    guard let window = self.view.window else { fatalError("The view was not in the app's view hierarchy!") }
                    let JustPassMeClient = JustPassMeClient(presentationAnchor: window);
                    let result = try await JustPassMeClient.authenticate(authenticationURL: "https://europe-west3-justpass-me-sdk-example.cloudfunctions.net/ext-justpass-me-oidc/authenticate/");
                } catch {
                    let errorAlert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
                    errorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                    self.present(errorAlert, animated: true, completion: nil)
                }
            }
        } else {
            // Fallback on earlier versions
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
 
}

2024 © justpass.me