Skip to main content

Code Examples

By default, SPike SDK logs are sent to standard Android Logcat. If for some reason you want to read them, you can use the following code (running it before you start using SpikeSDK):
SpikeConnectionAPIv3.setLogCallback { level, message ->
    when (level) {
        LogLevel.VERBOSE -> {}
        LogLevel.DEBUG -> if(BuildConfig.DEBUG) { 
            Log.d("SpikeSDK", message)
        }
        LogLevel.WARNING -> Log.w("SpikeSDK", message)
        LogLevel.ERROR -> Log.e("SpikeSDK", message)
    }
}
If you use Background Delivery, this code should be run in your application’s onCreate() method:
class MyApplication: Application() {
    override fun onCreate() {
        super.onCreate()

        SpikeConnectionAPIv3.setLogCallback { level, message ->
            when (level) {
                LogLevel.VERBOSE -> {}
                LogLevel.DEBUG -> if(BuildConfig.DEBUG) { 
                    Log.d("SpikeSDK", message)
                }
                LogLevel.WARNING -> Log.w("SpikeSDK", message)
                LogLevel.ERROR -> Log.e("SpikeSDK", message)
            }
        }
    }
}
Also, the application should be set in AndroidManifest.xml:
<application
    android:name=".MyApplication"
    ...
>