/SdkStateLogging_v7.kt Secret
Last active
March 10, 2022 15:15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
Sometimes the output from the SDK's Get State method can exceed Android's output length | |
restrictions. | |
Adding an `indentSpaces` to the output of JSONObjects can help bypass this restriction. | |
Additionally, you can get each of the sections independently. | |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
if (BuildConfig.DEBUG) { | |
// Enable Logging _BEFORE_ calling the SDK's configure/init method | |
MarketingCloudSdk.setLogLevel(VERBOSE) | |
MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener()) | |
// When the SDK is ready, output its state to the logs | |
MarketingCloudSdk.requestSdk { | |
// Specifically get the push state information | |
with(it.sdkState) { | |
// General Troubleshooting | |
Log.i("~#SdkState", "initConfig: ${this["initConfig"]}") | |
Log.i("~#SdkState", "initStatus: ${this["initStatus"]}") | |
Log.i("~#SdkState", "PushMessageManager: ${(this["PushMessageManager"] as JSONObject).toString(2)}") | |
Log.i("~#SdkState", "RegistrationManager: ${(this["RegistrationManager"] as JSONObject).toString(2)}") | |
// Troubleshoot InApp Messages | |
Log.i("~#SdkState", "InAppMessageManager: ${(this["InAppMessageManager"] as JSONObject).toString(2)}") | |
Log.i( | |
"~#SdkState", | |
"InApp Messages: ${((this["InAppMessageManager"] as JSONObject)["messages"] as JSONArray).toString(2)}" | |
) | |
// Get Everything | |
Log.i("~#SdkState", "InApp Events: ${(this["Event"] as JSONObject).toString(2)}") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment