Latest 1.1.0
Homepage https://github.com/ProovGroup/weproov-ios-sdk
License ProovGroup License
Platforms ios 10.0
Dependencies ACEDrawingView, FLAnimatedImage, JTMaterialSpinner, MBProgressHUD, SnapKit

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

WeProovSDK is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'WeProovSDK', :git => 'https://github.com/ProovGroup/weproov-ios-sdk'

Include Framwork

Dans le build setting verifier que la variable Enable bitcode est parametrer sur no (ENABLE_BITCODE = NO)

Info.plist

Allouer à l’app les droits de mise a jour en tache de fond

Background Fetch: capabilities -> Background Mode -> Background Fetch

Ajouter les clées n’ecessaire pour avoir access a la camera et au gps dans
Info.plist

<key>NSCameraUsageDescription</key>
<string>Camera is required</string> 
<key>NSContactsUsageDescription</key>
<string>Contacts required</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location required</string>

Import

import WeProovSDK

Connection

Pour connceter le SDK avec WeProov

// permet de s'avoire si le SDK est connecté
WPUser.shared.connected
// permet de se connecter avec un token et un secret
WPUser.shared.connect(token: "<TOKEN>", secret: "<SECRET>")
// pour changer la lang default: "en"
WPUser.shared.lang = "fr"

Upload background

Allouer à l’app les droits de mise a jour en tache de fond :
Background Fetch capabilities -> Background Mode -> Background Fetch
WeProov utilise les BackgroundURLSession pour upload le rapport en background
au lancement de l’app appeler: WPReportUploader.shared.sync()
gerer l’evenement dans le AppDelegate:

    func application(_: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
        if WPReportUploader.shared.handleEventsForBackgroundURLSession(identifier: identifier, completionHandler: completionHandler) {
            return
        }

        completionHandler()
    }

Exemple:

AppDelegate


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        ...
        if !WPUser.shared.connected {
            WPUser.shared.connect(token: "<TOKEN>", secret: "<SECRET>")
        }
        WPReportUploader.shared.sync()
        ...
        return true
    }

    func application(_: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
        if WPReportUploader.shared.handleEventsForBackgroundURLSession(identifier: identifier, completionHandler: completionHandler) {
            return
        }

        completionHandler()
    }

WPUserDelegate

    func userDidConnect(user: WPUser){
        print("WeProov Connected")
    }

    /// Tells the delegate when the user failed to connect
    func userFailedToConnect(user: WPUser, error: Error?){
        print("WeProov Connect Error (error!.localizedDescription)")
    }

Custom View

Nous allons faire en sorte que des que la vue est charger nous lancer un proovcode contenue dans le viewController

class CustomViewController: UIViewController {
  // Contiens le proovCode à ouvrir 
  var proovCode:String = ""
  // downloader: permet de télécharger un rapport
  private var downloader = WPReportDownloader()
  // permet d'etre prevenue quand le rapport se termine
  private var manager: WPReportManager?

  // Initialise une vue raport qui vas etre imbriquer
  var reportView: WPReportView = WPReportView()

  override func viewDidLoad() {
      super.viewDidLoad()
      // ajoute la vue rapport an laissans la marge pour le header des iPhone X
      self.view.addSubview(reportView)
      reportView.snp.makeConstraints{make in
          make.bottom.left.right.equalTo(self.view)
          make.top.equalTo(self.view.snp.topMargin)
      }
      // ajoute comme delegate au downloader cette class
      downloader.delegate = self
  }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        // initialise la popup de telechargement
        let controller = WPReportDownloadViewController()

        // set la classe actuel comde delegate
        controller.delegate = self
        // presente la page de download
        present(controller, animated: true) { [weak self] in
            guard let sself = self else {
                return
            }
            sself.downloader.load(proovCode: sself.proovCode)
        }
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)

        // permet de fermer proprement le rapport
        manager?.closeReport()
    }
}

WPReportManagerDelegate

extension CustomViewController: WPReportManagerDelegate {
    // appelé à chaque changement de page
    func reportCurrentSectionDidChange(manager: WPReportManager, section: Int) {
        title = manager.sections[section]
    }

    // appelé quand le rapport est fermé  
    func reportDidClose(manager: WPReportManager, state: WPReportCloseState) {
        dismiss()
    }
}

WPReportDownloadViewControllerDelegate

extension CustomViewController: WPReportDownloadViewControllerDelegate {
    func reportCancelDownload() {
        // Cannot stop downloader, so create a new one
        downloader.delegate = nil
        downloader = WPReportDownloader()
        downloader.delegate = self
    }
}

WPReportDownloaderDelegate

extension CustomViewController: WPReportDownloaderDelegate {
    func reportLoading(downloader _: WPReportDownloader) {}

    // appeler lors de la progression du telechargement
    func reportLoadingProgress(downloader _: WPReportDownloader, progress: Float) {
        if let controller = presentedViewController as? WPReportDownloadViewController {
            controller.updateProgression(value: progress)
        }
    }

    // appeler lorsque le rapport est pres a etre afficher
    func reportDidLoad(downloader _: WPReportDownloader, report: WPReport) {
        if let controller = presentedViewController as? WPReportDownloadViewController {
            controller.updateProgression(value: 1)
            controller.dismiss()
        }

        var theme = WPTheme()
        // Personalise les couleurs principal du framework
        theme.reportInitialColor = UIColor(hexString: "#67BB0F9")
        theme.reportFinalColor = UIColor(hexString: "#67BB0F9")

        manager = WPReportManager(controller: self, report: report, theme: theme)
        manager?.delegate = self
        manager?.load(reportView: reportView)
    }

    // si une erreur survient 
    func reportFailedToLoad(downloader _: WPReportDownloader, error: Error?) {
        if let controller = presentedViewController as? WPReportDownloadViewController {
            controller.dismiss()
        }
        dismiss()

        print("reportFailedToLoad", error ?? "unknown error")
    }

    // permet de savoir si le la page d'une section dois etre visible ou non
    func reportCanShowSection(downloader _: WPReportDownloader, section: Int) -> Bool {
        return true
    }

    // permet de savoir si la page peremet d'importer depuis son part / profile
    // attention permet de voire tout le carnet d'adresse / parc de bien
    func reportCanShowSectionImport(downloader _: WPReportDownloader, section _: Int) -> Bool {
        return true
    }
}

Latest podspec

{
    "name": "WeProovSDK",
    "swift_version": "5.0",
    "version": "1.1.0",
    "summary": "A short description of WeProovSDK",
    "description": "A long description of WeProovSDK",
    "license": {
        "type": "ProovGroup License",
        "file": "LICENSE"
    },
    "authors": "ProovGroup",
    "homepage": "https://github.com/ProovGroup/weproov-ios-sdk",
    "source": {
        "git": "https://github.com/ProovGroup/weproov-ios-sdk.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "ios": {
        "vendored_frameworks": [
            "WeProovSDK/WeProovSDK.framework"
        ]
    },
    "pod_target_xcconfig": {
        "ENABLE_BITCODE": "NO"
    },
    "user_target_xcconfig": {
        "ENABLE_BITCODE": "NO"
    },
    "preserve_paths": "WeProovSDK/Wprv.framework",
    "dependencies": {
        "ACEDrawingView": [
            "~> 2.2"
        ],
        "FLAnimatedImage": [
            "~> 1.0"
        ],
        "JTMaterialSpinner": [
            "~> 3.0"
        ],
        "MBProgressHUD": [
            "~> 1.1"
        ],
        "SnapKit": [
            "~> 4.0"
        ]
    }
}

Pin It on Pinterest

Share This