5. Initializing the SDK
Authenticator (MetricAuthenticator)
The MetricAuthenticator
class is used to provide authentication
keys to the SDK. For the Metric SDK, the ClientAuthenticator
variant is used.
In your Application
class (typically named App
), you should call the Metric.init(...)
method to initialize the SDK. Here's an example:
class App : Application() {
override fun onCreate() {
super.onCreate()
Metric.init(
metricSettings = BasicMetricSettings(
applicationContext = this,
authenticator = {
ClientAuthenticator(
clientKey = "...",
secretKey = "..."
)
},
environment = Environment.Dev
)
)
}
}
In this code snippet:​
clientKey
andsecretKey
are authentication keys that you need to obtain (you would typically retrieve these from your Metric SDK account).
Environment​
The environment
parameter in the Metric.init(...)
call specifies the environment your app is operating in:
Environment.Dev:
This indicates the development environment. Use this when you're testing and debugging your app.Environment.Prod:
This indicates the production environment. When you're ready to release your app to users, use this environment setting.
info