Config
Initialization
You can initialize the SDK by specifying metadata in the AndroidManifest.xml
<meta-data android:name="snabble_app_id" android:value="YOUR_APP_ID" />
<meta-data android:name="snabble_secret" android:value="YOUR_SECRET" />
You also can initialize the SDK programmatically by specifying in the AndroidManifest.xml:
<meta-data android:name="snabble_auto_initialization_disabled" android:value="true" />
And then initialize the SDK via code.
val config = Config(
appId = YOUR_APP_ID,
secret = YOUR_SECRET,
)
Snabble.setup(application, config)
Available parameters
Parameter | Type | Default Value | Description |
---|---|---|---|
appId | String | null | The project identifier, which is used in the communication with the backend. |
secret | String | null | The secret needed for Totp token generation. |
endpointBaseUrl | String | https://api.snabble.io | The endpoint url of the Snabble backend. For example "https://api.snabble.io" for the Production environment. |
bundledMetadataAssetPath | String | null | Relative path from the assets folder which points to a bundled file which contains the metadata. This file gets initially used to initialize the sdk before network requests are made, or be able to use the sdk in the case of no network connection. Optional. If no file is specified every time the sdk is initialized we wait for a network response from the backend. It is HIGHLY recommended to provide bundled metadata to allow the SDK to function without having a network connection. |
bundledMetadataRawResId | String | 0 | Resource id of the raw file which contains the metadata. This file gets initially used to initialize the sdk before network requests are made, or be able to use the sdk in the case of no network connection. Optional. If no file is specified every time the sdk is initialized we wait for a network response from the backend. It is HIGHLY recommended to provide bundled metadata to allow the SDK to function without having a network connection. |
generateSearchIndex | Boolean | false | If set to true, creates an full text index to support searching in the product database using findByName or searchByName. Note that this increases setup time of the ProductDatabase, and it may not be immediately available offline. |
maxProductDatabaseAge | Long | 1 hour | The time that the database is allowed to be out of date. After the specified time in milliseconds the database only uses online requests for asynchronous requests. Successfully calling [ProductDatabase.update] resets the timer. The time is specified in milliseconds. The default value is 1 hour. |
maxShoppingCartAge | Long | 4 hours | The time that the shopping cart is allowed to be alive after the last modification. The time is specified in milliseconds. The default value is 4 hours. |
disableCertificatePinning | Boolean | false | If set to true, disables certificate pinning. |
initialSQL | StringList | empty list | SQL queries that will get executed in order on the product database |
vibrateToConfirmCartFilled | Boolean | false | Vibrate while adding a product to the cart, by default false. |
loadActiveShops | Boolean | false | Set to true, to load shops that are marked as pre launch and are not part of the original metadata in the backend (for example for testing shops in production before a go-live). |
checkInRadius | Float | 500 meters | The radius in which the CheckInManager tries to check in a shop. In meters. |
checkOutRadius | Float | 1000 meters | The radius in which the CheckInManager tries to stay in a shop, if already in it. If outside of this radius and the lastSeenThreshold, you will be checked out. |
lastSeenThreshold | Long | 15 minutes | The time in milliseconds which we keep you checked in at a shop. The timer will be refreshed while you are still inside the shop and only begins to run if you are not inside the checkOutRadius anymore. |
networkInterceptor | Interceptor | null | Network interceptor used for all calls made by the SDK. |
manualProductDatabaseUpdates | Boolean | false | Set to true if you want to control when the product database gets updated, otherwise the product database gets updated when checking in and if checked in when the app resumes. |