Provider minimum requirement
You provide recipes and use Mealz to push it to a retailer. For example, a food delivery service that works with multiple grocery stores.
ProviderKey - base64 key to set information
This will be provided by Mealz during implementation. This will include information such as PROD vs UAT & your unique company identifier.
If you just want to play around, you can use the sample Mealz Store:
val providerKey = "ewoJInByb3ZpZGVyX2lkIjogIjE0IiwKCSJwbGF1c2libGVfZG9tYWluZSI6ICJtaWFtLnRlc3QiLAoJIm1pYW1fb3JpZ2luIjogIm1pYW0iLAoJIm9yaWdpbiI6ICJtaWFtIiwKCSJtaWFtX2Vudmlyb25tZW50IjogIlVBVCIKfQ"
which you'll see decodes from base 64 to this:
{
"provider_id": "14",
"plausible_domaine": "miam.test",
"miam_origin": "miam",
"origin": "miam",
"miam_environment": "UAT"
}
Your keys will be provided by our Development team
Basic implementation
There are several options to configure to handle authless users. The below is a basic implementation where the Mealz initialization process will only start after the user is logged in and has selected a valid store.
First, to init Mealz we need your application context and your provider key
Two keys will have been sent to you: one for development and one for production.
import ai.mealz.core.Mealz
import ai.mealz.core.init.sdkRequirement
import android.content.Context
object MealzManager {
private var isInitialized = false
private val PROVIDER_KEY = "YOUR_KEY"
public fun initialize(applicationContext: Context) {
if (isInitialized) return
Mealz.Core {
sdkRequirement {
key = PROVIDER_KEY
context = applicationContext
}
}
isInitialized = true
}
}
User setup
Here is how to pass the user ID to the SDK, directly within the host app:
// existingUserId is your user id, type String is expected
Mealz.user.updateUserId(userId = existingUserId)
Here is an example on how to inform the SDK whenever the user login state changes. We recommend using Observables or EventListeners to that end.
import ai.mealz.core.Mealz
class MealzAuth() {
init {
// CODE
OBSERVABLE_ON_USER_OBJECT.collect { user ->
Mealz.shared.user.updateUserId(userId = user.id)
}
}
// CODE
}
To get full list of user features check User configurations.
Store setup
For Mealz to work properly, your user must be connected to a specific store so we can accurately provide recipes with available ingredients. To add the store that the user is currently at, you can use this code:
// From anywhere
import ai.mealz.core.Mealz
// STORE_ID_IN_HOST_APP is your store id, type String is expected
Mealz.user.setStoreWithMealzId(storeId = STORE_ID_IN_HOST_APP)
You can also set a callback to redirect to your Store Selector, more information here.
Congratulations, Mealz is good to go 🥳