Device Variables
Device Variable is a special kind of variable that is permanently stored on your users’ devices using AsyncStorage from React Native. Device Variables can be set to any valid JSON and you can access Device Variables from anywhere in your app.
A Device Variable will not reset to the default value the next time the app starts. Instead, it will be the same value when the app is last used. Use an App or Screen Variable to store ephemeral data.
For example, you might have a Device Variable named auth_token where you store a user’s authentication token for making API requests. Storing this data in a Device Variable will ensure that the value persists across app launches.
Creating a Device Variable
Section titled “Creating a Device Variable”To create variables, open the Variables modal from the left menu bar of the Builder.
Configuration
Section titled “Configuration”| Parameter | Description |
|---|---|
| Name | The name of the variable to be referenced. |
| Development Value | The default value when building and publishing using the Development Environment |
| Production Value | The default value when building and publishing using the Production Environment |
Updating a Device Variable
Section titled “Updating a Device Variable”Set Variable Action
Section titled “Set Variable Action”To update the value of an Device Variable, you will use the Set Variable Action from a Trigger in the Interactions tab from the right panel of the Builder.
In Custom Code
Section titled “In Custom Code”You can also work with App Variables in Files and Functions. Learn how in the Variables with Custom Code doc.