Use variable to get database info

@Toby

In your Firebase collection, how are you storing the barcode data? Can you provide a screenshot of your Firebase products collection showing a sample of your data that also includes the document ID.

Also, are you getting any Firebase errors in your Xcode debug console like this:

2022-12-13 07:42:23.428039+0800 Sustainable Calculator[6583:1557159] 10.4.0 - [FirebaseFirestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. The server responded with an error: 
 - URL: https://firebaseappcheck.googleapis.com/v1/projects/sustainable-calculator-a0b61/apps/1:909094431177:ios:889f3c54a65240b5e5e018:exchangeDeviceCheckToken 
 - HTTP status code: 403 
 - Response body: {
  "error": {
    "code": 403,
    "message": "Firebase App Check API has not been used in project 909094431177 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebaseappcheck.googleapis.com/overview?project=909094431177 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/firebaseappcheck.googleapis.com/overview?project=909094431177"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/909094431177",
          "service": "firebaseappcheck.googleapis.com"
        }
      }
    ]
  }
}
'

thanks,

here is the error message I’m getting

2022-12-13 18:11:34.109972+0000 Sustainable Calculator[7848:3037320] 10.4.0 - [FirebaseInAppMessaging][I-IAM130004] Failed restful api request to fetch in-app messages: seeing http status code as 403 with body as {
  "error": {
    "code": 403,
    "message": "Firebase In-App Messaging API has not been used in project 909094431177 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebaseinappmessaging.googleapis.com/overview?project=909094431177 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/firebaseinappmessaging.googleapis.com/overview?project=909094431177"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/909094431177",
          "service": "firebaseinappmessaging.googleapis.com"
        }
      }
    ]
  }
}
2022-12-13 18:11:34.162708+0000 Sustainable Calculator[7848:3037320] 10.4.0 - [FirebaseInAppMessaging][I-IAM700002] Error happened during message fetching Error Domain=NSURLErrorDomain Code=403 "(null)"
2022-12-13 18:11:34.250389+0000 Sustainable Calculator[7848:3037320] 10.4.0 - [FirebaseInAppMessaging][I-IAM130004] Failed restful api request to fetch in-app messages: seeing http status code as 403 with body as {
  "error": {
    "code": 403,
    "message": "Firebase In-App Messaging API has not been used in project 909094431177 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebaseinappmessaging.googleapis.com/overview?project=909094431177 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/firebaseinappmessaging.googleapis.com/overview?project=909094431177"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/909094431177",
          "service": "firebaseinappmessaging.googleapis.com"
        }
      }
    ]
  }
}
2022-12-13 18:11:34.303952+0000 Sustainable Calculator[7848:3037320] 10.4.0 - [FirebaseInAppMessaging][I-IAM700002] Error happened during message fetching Error Domain=NSURLErrorDomain Code=403 "(null)"
2022-12-13 18:11:37.909806+0000 Sustainable Calculator[7848:3037323] 10.4.0 - [FirebaseFirestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. (com.apple.devicecheck.error error 1.)'

So there is something wrong with the setup of your Firebase Project. Has there always been that error message in the console?