Nutrition Module
The Nutrition module provides nutrition UI navigation and nutrition data operations.
Accessing the moduleβ
After connectUser(...), access Nutrition through sdk.modules.nutrition:
guard let sdk = AzeooSDK.shared else { return }
let nutrition = sdk.modules.nutrition
UI embeddingβ
UIKitβ
let nutritionVC = nutrition.getViewController()
present(nutritionVC, animated: true)
SwiftUI (iOS 14+)β
if #available(iOS 14.0, *) {
nutrition.getView()
}
Navigation methodsβ
Use these methods to open nutrition screens:
nutrition.display(bottomSafeArea: true)
nutrition.showDiary(date: nil)
nutrition.showPlans()
nutrition.showPlan(planId: "plan-123")
nutrition.showRecipes()
nutrition.showRecipe(recipeId: 12345, recipeName: "Chicken Salad")
nutrition.showScanner()
nutrition.showMobileScanner()
nutrition.showSearch()
nutrition.showCart()
nutrition.showAddSelection()
nutrition.showAddFood()
nutrition.showAddMeal()
nutrition.showHome()
Data methodsβ
Use these methods to read or mutate nutrition data:
nutrition.getDiary(dateTimestamp: 1710460800) { result in /* ... */ }
nutrition.addFood(foodEntry: ["name": "Banana"]) { result in /* ... */ }
nutrition.updateFood(entryId: "entry-1", foodEntry: ["quantity": 2]) { result in /* ... */ }
nutrition.removeFood(entryId: "entry-1") { result in /* ... */ }
nutrition.searchFoods(query: "chicken", limit: 20) { result in /* ... */ }
nutrition.getFoodByBarcode(barcode: "3017620422003") { result in /* ... */ }
nutrition.getUserPlanData { result in /* ... */ }
nutrition.getPlansData { result in /* ... */ }
nutrition.getShoppingList { result in /* ... */ }
nutrition.addToShoppingList(item: ["name": "Eggs"]) { result in /* ... */ }
nutrition.removeFromShoppingList(itemId: "item-1") { result in /* ... */ }
Settings and stateβ
nutrition.getSettings { result in /* ... */ }
nutrition.updateSettings(settings: ["targetCalories": 2200]) { result in /* ... */ }
nutrition.getMacroGoals { result in /* ... */ }
nutrition.updateMacroGoals(macros: ["protein": 160, "carbs": 220, "fat": 70]) { result in /* ... */ }
nutrition.getState { result in /* ... */ }
nutrition.resetState()
nutrition.setBottomSafeArea(enabled: true)
Complete exampleβ
import UIKit
import AzeooSDK
final class NutritionViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
openDiary()
}
private func openDiary() {
guard let sdk = AzeooSDK.shared else { return }
let nutrition = sdk.modules.nutrition
nutrition.showDiary(date: nil) { result in
if case .failure(let error) = result {
print("showDiary failed: \(error.localizedDescription)")
}
}
}
@IBAction func showScanner(_ sender: UIButton) {
AzeooSDK.shared?.modules.nutrition.showScanner()
}
@IBAction func showRecipes(_ sender: UIButton) {
AzeooSDK.shared?.modules.nutrition.showRecipes()
}
}
Next Stepsβ
- Configuration - Customize the UI
- Client API - Low-level API reference