Passio Nutrition-AI
  • Nutrition-AI SDK Overview
  • Guides
    • Nutrition AI SDK
      • SDK Key and minimum requirements
      • Installation
      • Configure the SDK
      • Use Cases
        • Food recognition
        • Nutrition data
        • Barcode scanning
        • Nutrition Facts scanning
        • Search, Food Icons, RefCode
        • Speech recognition
        • Nutrition Advisor
        • Suggestions and Meal Plans
        • User created foods and reports
    • iOS SDK Docs
      • Before getting started
      • Getting the ml models to the device
      • Run the demos first
      • Adding Passio SDK into your project
      • Initialize and configure the SDK
      • Start/Stop food detection
      • Food Recognition Delegate
      • Migration from SDK 1.4.X to 2.x
      • SDK API
      • Quick Start Guide
        • Installation
        • Configure the SDK (UIKit)
        • Recognise food using image
        • Food Details
    • Android SDK Docs
      • Getting started
        • Include the library
        • Camera
        • SDK Initialization and Configuration
        • Food detection session
        • Visual, Barcode and Packaged Food detection
        • Nutritional Database
        • Sandbox app
      • Troubleshooting on Android
      • Migration from SDK version 1.4.x to 2.x
      • Quick Start Guide
        • Importing the Android SDK to a project
        • Configure SDK and handle the result
        • RecognizeImageRemote
        • Food Details
    • React Native SDK Docs
      • Getting Started
        • Installation
        • SDK Initialization and Configuration
      • API Reference
        • configure & requestCameraAuthorization
        • recognizeImageRemote
        • searchForFood & searchForFoodSemantic
        • startFoodDetection
          • FoodDetectionEvent
        • fetchFoodItemForProductCode
        • fetchFoodItemForRefCode
        • fetchFoodItemForDataInfo
        • startNutritionFactsDetection
        • fetchFoodItemForPassioID
        • recognizeSpeechRemote
        • Fetch Nutrients
        • onDowloadingPassioModelCallBacks
        • detectFoodFromImageURI
        • addToPersonalization
        • updateLanguage
        • fetchHiddenIngredients
        • fetchVisualAlternatives
        • fetchPossibleIngredients
      • Properties
        • PassioFoodItem
        • PassioFoodDataInfo
        • PassioFoodAmount
        • PassioIngredient
        • PassioNutrients
        • UnitMass
        • ServingUnit
        • ServingSize
        • PassioSearchResult
        • NutritionFacts
        • PassioNutritionPreview
        • PassioSpeechRecognitionModel
        • PassioLogAction
        • PassioAdvisorFoodInfo
        • FoodCandidates
        • FoodDetectionEvent
        • NutritionDetectionEvent
        • DetectedCandidate
        • BarcodeCandidate
        • PackagedFoodCode
        • AmountEstimate
        • ImagesInfo
        • PassioStatus
        • FoodDetectionEvent
        • NutritionFacts
        • PassioMealPlan
        • PassioMealPlanItem
      • Nutriton Advisor
        • initConversation
        • sendMessage
        • sendImage
        • Guide
          • useNutritionAdvisor
        • Properties
          • PassioAdvisorResponse
          • PassioAdvisorMessageResultStatus
          • PassioAdvisorResultStatus
      • Quick Start Guide
        • Installation
        • Configure the SDK
        • RecognizeImageRemote
        • Food Detail
      • Guide
        • Integrate SDK Setup
        • Integrate Quick Scan
        • Integrate Food Search
        • Integrate Food Editor with Recipe
        • Integrate MealPlan
        • Integrate Suggestions
        • Integrate recognizeImageRemote
      • Components
        • DetectionCameraView
        • PassioIconView
      • Changelog
      • More
        • Display Macro Chart
          • MockFood
          • Utils PassioNutrient
        • Display Micro Progress
        • Getting nutrition value for a FoodItem
        • Getting nutrition value for a Recipe
        • Recalculate the nutrition value based on serving size options.
      • Migrations
        • Migrating from SDK 2.X to version 3.X
        • Structure Migrations From SDK 3.X to SDK 2.X
        • [Deprecated] Migrating from SDK 1.X to version 2.X
        • [Deprecated] Getting Started (v1)
          • Installation
          • SDK Initialization and Configuration
          • Start food detection
          • FoodDetectionEvent
          • Nutritional Database
      • Troubleshooting on RN
      • V2
        • Getting Started
          • Installation
          • SDK Initialization and Configuration
          • Start food detection
          • FoodDetectionEvent
        • RN SDK API
          • Properties
            • PersonalizedAlternative
            • FoodSearchResult
            • PassioNutrient
            • FoodDetectionEvent
            • DownloadModelCallBack
            • UPCProduct
            • ServingUnit
            • PassioStatus
            • PassioIDAttributes
            • PassioIDEntityType
            • PassioFoodItem
            • PassioRecipe
            • ServingSize
            • Measurement
            • UnitMass
            • NutritionFacts
        • Food Image
        • Search Food Item
        • Quick Scan
        • Multi Scan
        • MealPlan
        • Recipe
      • How do I Integrate a Passio SDK in EXPO?
    • Flutter SDK Docs
      • Getting Started
    • Before You Continue
    • Setup For Android
    • Initialize and configure the SDK
  • Fundamentals
    • Nutrition-AI Developer FAQ
      • Nutrition Data
      • Supported Phones
      • Security
      • Testing Volume Estimation
      • Testing Nutrition-AI SDK
      • Nutrition-AI Test Methodology
    • Nutrition API - Mobile SDK interoperability
      • JSON Response parsing
  • Versions
    • 3.2.4
      • SDK Key and minimum requirements
      • Installation
      • Configure the SDK
      • Use Cases
        • Food recognition
        • Nutrition data
        • Barcode scanning
        • Nutrition Facts scanning
        • Search, Food Icons, RefCode
        • Speech recognition
        • Nutrition Advisor
        • Suggestions and Meal Plans
        • User created foods and reports
    • 3.2.2
      • SDK Key and minimum requirements
      • Installation
      • Configure the SDK
      • Use Cases
        • Food recognition
        • Nutrition data
        • Barcode scanning
        • Nutrition Facts scanning
        • Search, Food Icons, RefCode
        • Speech recognition
        • Nutrition Advisor
        • Suggestions and Meal Plans
        • User created foods and reports
    • 3.2.0
      • SDK Key and minimum requirements
      • Installation
      • Configure the SDK
      • Use Cases
        • Food recognition
        • Nutrition data
        • Barcode scanning
        • Nutrition Facts scanning
        • Search, Food Icons, RefCode
        • Speech recognition
        • Nutrition Advisor
        • Suggestions and Meal Plans
    • 3.1.4
      • SDK Key and minimum requirements
      • Installation
      • Configure the SDK
      • Use Cases
        • Food recognition
        • Nutrition data
        • Barcode scanning
        • Search, Food Icons, RefCode
        • Speech recognition
        • Nutrition Advisor
        • Suggestions and Meal Plans
Powered by GitBook
On this page
Export as PDF
  1. Guides
  2. iOS SDK Docs
  3. Quick Start Guide

Configure the SDK (UIKit)

  • To configure the SDK using SDK key, we need to provide a SDK license key. Obtain your Passio key from the Passio developer portal.

  • To configure the SDK using Proxy URL, the SDK key is not required. The SDK will be on remoteOnly mode in that case. You need to provide following things when configuring the SDK using Proxy URL:

    • Proxy URL - Base url of the target proxy endpoint

    • Proxy headers - Required headers to all of the requests

  • Create a new or open your existing project in Xcode and import the framework inside the View Controller

import PassioNutritionAISDK
  • Define reference of SDK inside your View Controller

private let passioSDK = PassioNutritionAI.shared
  • Configure the SDK using PassioConfiguration shown in below code. Call configurePassioSDK() when you need to configure SDK e.g. inside viewDidLoad() function.

// Using SDK key

func configurePassioSDK() {
    
    passioSDK.statusDelegate = self
    
    let PASSIO_KEY = "YOUR_PASSIO_KEY"
    var passioConfig = PassioConfiguration(key: PASSIO_KEY)
    passioConfig.remoteOnly = true

    passioSDK.configure(passioConfiguration: passioConfig) { status in
        print("Mode = \(status.mode)")
        print("Missing files = \(String(describing: status.missingFiles))")
    }
}
// Using Proxy URL

func configurePassioSDK() {
    
    passioSDK.statusDelegate = self
    
    var passioConfig = PassioConfiguration()
    // Set the base URL of the target proxy endpoint
    passioConfig.proxyUrl = "https://yourdomain.com/nutrition/"
    // Set headers as per your requirements
    passioConfig.proxyHeaders = ["header" : "value"] 

    passioSDK.configure(passioConfiguration: passioConfig) { status in
        print("Mode = \(status.mode)")
        print("Missing files = \(String(describing: status.missingFiles))")
    }
}

The models required for the SDK to run local recognition can take some time for the first download. If the local recognition is not needed, setting the remoteOnly to true on the PassioConfiguration process will skip the download of the models. Remote recognition functions like recognizeImageRemote or searchForFood will still work.

When the SDK is configured without SDK key (using Proxy URL), the SDK will be remoteOnly.

  • Implement the PassioStatusDelegate protocol to receive configuration status updates. While the files are being downloaded, we can show in UI how many files are remanning for the download.

extension ImageSelectionVC: PassioStatusDelegate {
    
    func passioStatusChanged(status: PassioStatus) {
        print("Status changed: \(status)")
        configureUI(status: status)
    }
    
    func passioProcessing(filesLeft: Int) {
        print("Files to download: \(filesLeft)")
    }
    
    func completedDownloadingAllFiles(filesLocalURLs: [FileLocalURL]) {
        print("All files downloaded")
    }
    
    func completedDownloadingFile(fileLocalURL: FileLocalURL, filesLeft: Int) {
        print("File downloaded: \(fileLocalURL)")
    }
    
    func downloadingError(message: String) {
        print("Downloading error: \(message)")
    }
}
  • Update the UI based on the configuration status. The isReadyForDetection status indicated that the SDK is setup successfully and it is ready to use. The implementation of self.askForCapturePermission() method will be covered in the next section

func configureUI(status: PassioStatus) {
    
    DispatchQueue.main.async {
    
        switch status.mode {
        
        case .isReadyForDetection:
            // The SDK is ready for detection. Hide the status view.
            self.statusView.isHidden = true  
            // This will be covered in the next section
            self.askForCapturePermission()
            
        case .isBeingConfigured:
            self.statusLabel.text = "Configuraing SDK..."
            
        case .failedToConfigure:
            self.statusLabel.text = "SDK failed to configure!"
            
        case .isDownloadingModels:
            self.statusLabel.text = "SDK is downloading files..."
            
        case .notReady:
            self.statusLabel.text = "SDK is not ready!"
            
        @unknown default:
            self.statusLabel.text = "Unknown passio status!"
        }
    }
}
PreviousInstallationNextRecognise food using image

Last updated 4 months ago