As I understand, firebase functions execute in the Google Functions Execution Environment.
This means that functions are executed in a single instance. According to this document:
A new function instance is only started in two cases:
- When you deploy your function
- When a new function instance is automatically created to scale up to the load, or occasionally to replace an existing instance.
My question is:
Is it possible to get this instance id, inside firebase functions?
Firebase Instance ID provides a unique identifier for each app instance and a mechanism to authenticate and authorize actions (example: sending FCM messages). Instance ID is stable except when: App deletes Instance ID. App is restored on a new device. User uninstalls/reinstall the app.
In a nutshell: Call FirebaseInstanceId. getInstance(). getToken() to reveive the current device token.
An instance ID is a string reported by a device's enumerator (its bus driver) and distinguishes a device from other devices of the same type on a computer. An instance ID contains serial number information, if supported by the underlying bus, or some kind of location information.
To retrieve the FirebaseInstanceId you need to implement the Firebase In-App messaging SDK and make sure your app connects to Firebase. Once the app is connected to Firebase it will add the FirebaseInstanceId to the Android log once the App is run.
There is no formally exposed instance ID. Normally it would not matter which instance is running your code, and your code shouldn't depend on running in a particular instance
If you need to tag a particular instance for some reason, you could generate your own UUID and store it in a global variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With