[Deprecated] Migrating from SDK 1.X to version 2.X

Introduction

This is a reference for upgrading from react-native-passio-sdk v1.x.x to v2.x.x

API Changes

  • Changed configuration of FoodDetectionConfig in PassioSDK

  • Renamed OCR to PackagedFood in PassioSDK

  • PassioSDK.searchForFood now returns a passioID and name

  • Removing PassioSDK.getAttributesForName

  • Added PassioSDK.getAttributesForPassioID

  • Refactor PassioIconView

  • Nutrients in the FoodItem have been refactored from Number to UnitMass

Changed configuration of FoodDetectionConfig in PassioSDK

In this version, we rename detectOCR with detectPackagedFood into Food Detection Configuration.

 const config: FoodDetectionConfig = {
      detectBarcodes: true,
      detectPackagedFood: true,
      detectNutritionFacts: true,
    }

Renamed OCR to PackageFood

Renamed method of fetchAttributesForOCR to fetchPassioIDAttributesForPackagedFood

fetchPassioIDAttributesForPackagedFood(packagedFoodCode:PackagedFoodCode):
Promise<PassioIDAttributes | null>

PassioSDK.searchForFood now returns a passioID and name

This method now returns passioID and name into the array of objects. Previously this method returned the name of the array only

searchForFood(searchQuery: string): Promise<FoodSearchResult[]> 

Removing PassioSDK.getAttributesForName

getAttributesForName(name: string): Promise<PassioIDAttributes | null>

The following API you have used to get attributes from passioID instead of name.

Added PassioSDK.getAttributesForPassioID

This method is to get the attributes using passioID.

getAttributesForPassioID( passioID: PassioID ):
Promise<PassioIDAttributes | null>

Refactor PassioIconView

In V2, PassioIconView shows the food icon from the server, Previously this view displays food icon from the assets.

   <PassioIconView
       style={styles.icon}
       config={{
         passioID: passioID,
         iconSize: IconSize.PX90,
         passioIDEntityType: 'item',
       }}
     />

Nutrients in the FoodItem have been refactored from Number to UnitMass

In V2, change the nutrient data type number to UnitMass, UnitMass object which includes the unit and value.

The following list of nutrients has changed the number to UnitMass.

 calories?: UnitMass
 carbs?: UnitMass
 fat?: UnitMass
 protein?: UnitMass
 saturatedFat?: UnitMass
 transFat?: UnitMass
 monounsaturatedFat?: ServingUnit
 polyunsaturatedFat?: UnitMass
 cholesterol?: UnitMass
 sodium?: UnitMass
 fiber?: UnitMass
 sugar?: UnitMass
 sugarAdded?: UnitMass
 vitaminD?: UnitMass
 calcium?: UnitMass
 iron?: UnitMass
 potassium?: UnitMass
 vitaminC?: UnitMass
 alcohol?: UnitMass
 sugarAlcohol?: UnitMass
 vitaminB12?: UnitMass
 vitaminB12Added?: UnitMass
 vitaminB6?: UnitMass
 vitaminE?: UnitMass 
 vitaminEAdded?: UnitMass
 phosphorus?: UnitMass
 iodine?: UnitMass

If at any point you need help from the Passio team, please reach out to us at support@passiolife.com

Last updated