From 9b6fd7d50cf4d4501021a51fdae612ceb7f83f3a Mon Sep 17 00:00:00 2001 From: Bill Mote Date: Thu, 29 Sep 2022 09:59:56 -0400 Subject: [PATCH] Updated for Android 13 support --- .gitignore | 2 ++ app/build.gradle | 4 ++-- app/src/main/AndroidManifest.xml | 4 +++- .../learningapp/BaseLearningApplication.kt | 11 ++++++++++- .../marketingcloud/learningapp/screens/InboxViewer.kt | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 8123afb..156cfa5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ .project .settings .classpath +.jekyll* +_site/ # Ignore firebase file so we don't accidentally add it to git google-services.json \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 9c71ad2..52b7d08 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,12 +5,12 @@ apply plugin: 'androidx.navigation.safeargs' apply plugin: 'com.google.gms.google-services' android { - compileSdkVersion 29 + compileSdkVersion 33 defaultConfig { applicationId "com.salesforce.marketingcloud.learningapp" minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index be18f0a..c0182cc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,9 @@ android:supportsRtl="true" android:theme="@style/MyTheme.DayNight" tools:ignore="GoogleAppIndexingWarning"> - + diff --git a/app/src/main/java/com/salesforce/marketingcloud/learningapp/BaseLearningApplication.kt b/app/src/main/java/com/salesforce/marketingcloud/learningapp/BaseLearningApplication.kt index 5914605..00f81e4 100644 --- a/app/src/main/java/com/salesforce/marketingcloud/learningapp/BaseLearningApplication.kt +++ b/app/src/main/java/com/salesforce/marketingcloud/learningapp/BaseLearningApplication.kt @@ -41,7 +41,7 @@ import com.salesforce.marketingcloud.messages.iam.InAppMessage import com.salesforce.marketingcloud.messages.iam.InAppMessageManager import com.salesforce.marketingcloud.sfmcsdk.* -const val LOG_TAG = "MCSDK" +const val LOG_TAG = "~#MCLearningApp" abstract class BaseLearningApplication : Application(), UrlHandler { @@ -51,8 +51,17 @@ abstract class BaseLearningApplication : Application(), UrlHandler { super.onCreate() if (BuildConfig.DEBUG) { + // Only log for DEBUG builds MarketingCloudSdk.setLogLevel(MCLogListener.VERBOSE) MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener()) + SFMCSdk.requestSdk { sdk -> + sdk.mp { push -> + push.registrationManager.registerForRegistrationEvents { + // Log the registration on successful sends to the MC + Log.i(LOG_TAG, "Registration: $it") + } + } + } } // You MUST initialize the SDK in your Application's onCreate to ensure correct diff --git a/app/src/main/java/com/salesforce/marketingcloud/learningapp/screens/InboxViewer.kt b/app/src/main/java/com/salesforce/marketingcloud/learningapp/screens/InboxViewer.kt index 31c7e00..db0f2c1 100644 --- a/app/src/main/java/com/salesforce/marketingcloud/learningapp/screens/InboxViewer.kt +++ b/app/src/main/java/com/salesforce/marketingcloud/learningapp/screens/InboxViewer.kt @@ -43,7 +43,7 @@ class InboxViewer : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View { - webView = WebView(context) + webView = WebView(requireContext()) webView.settings.javaScriptEnabled = true return webView }