iOS SDK

Native Swift SDK for creating blockchain-verified .facti files on iOS

Installation

CocoaPods

pod 'BlockFactSDK'
pod install

Swift Package Manager

In Xcode:

  1. File → Add Packages
  2. Enter: https://github.com/BlockFact/ios-sdk.git
  3. Select version: 2.0.0

Or in Package.swift:

dependencies: [
    .package(url: "https://github.com/BlockFact/ios-sdk.git", from: "2.0.0")
]

Quick Start

import BlockFactSDK

let blockFact = BlockFact()

// Create wallet
let wallet = try await blockFact.createWallet()
print("Wallet: \(wallet.address)")

// Register content
let result = try await blockFact.registerContent(
    image: capturedImage,
    latitude: location.coordinate.latitude,
    longitude: location.coordinate.longitude
)

print("Registered: \(result.factiUrl)")

API Reference

BlockFact

createWallet()

func createWallet() async throws -> Wallet

Creates a new Starknet wallet. Stored securely in iOS Keychain.

getWallet()

func getWallet() throws -> Wallet?

Retrieves existing wallet from Keychain.

registerContent()

func registerContent(
    image: UIImage,
    latitude: Double,
    longitude: Double,
    metadata: [String: Any] = [:]
) async throws -> RegistrationResult

Registers content on blockchain and returns .facti URL.

verifyContent()

func verifyContent(factiUrl: String) async throws -> VerificationResult

Verifies a .facti file against blockchain.

Complete Example

import UIKit
import BlockFactSDK
import CoreLocation

class CameraViewController: UIViewController {
    let blockFact = BlockFact()
    let locationManager = CLLocationManager()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        locationManager.requestWhenInUseAuthorization()
        
        Task {
            if try blockFact.getWallet() == nil {
                _ = try await blockFact.createWallet()
            }
        }
    }
    
    @IBAction func takePhoto() {
        let picker = UIImagePickerController()
        picker.sourceType = .camera
        picker.delegate = self
        present(picker, animated: true)
    }
}

extension CameraViewController: UIImagePickerControllerDelegate {
    func imagePickerController(
        _ picker: UIImagePickerController,
        didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]
    ) {
        picker.dismiss(animated: true)
        
        guard let image = info[.originalImage] as? UIImage,
              let location = locationManager.location else { return }
        
        Task {
            let result = try await blockFact.registerContent(
                image: image,
                latitude: location.coordinate.latitude,
                longitude: location.coordinate.longitude
            )
            
            print("✅ Registered: \(result.txHash)")
        }
    }
}

Models

Wallet

struct Wallet {
    let address: String
    let publicKey: String
    let privateKey: String
}

RegistrationResult

struct RegistrationResult {
    let factiUrl: String
    let factiCid: String
    let txHash: String
    let sessionId: String
}

VerificationResult

struct VerificationResult {
    let valid: Bool
    let metadata: [String: Any]
    let blockNumber: Int
    let timestamp: String
}

Permissions

Add to Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to verify photo authenticity</string>

<key>NSCameraUsageDescription</key>
<string>We need camera access to take photos</string>

Requirements

  • • iOS 13.0+
  • • Swift 5.0+
  • • Xcode 12.0+

🎉 100% Free to Use

No API keys, no usage limits, no fees. Free to use for any purpose.