From 71536130803b9c3dfcfb53d38ff435a2b5eca11b Mon Sep 17 00:00:00 2001 From: emawby Date: Tue, 7 Dec 2021 15:27:02 -0800 Subject: [PATCH 1/2] don't set backgroundImageLayout if device is Android 12 or higher --- .../src/main/java/com/onesignal/GenerateNotification.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java b/OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java index 11aa14f4da..c6cf553551 100644 --- a/OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java +++ b/OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java @@ -767,9 +767,13 @@ private static void createSummaryIdDatabaseEntry(OneSignalDbHelper dbHelper, Str // Keep 'throws Throwable' as 'onesignal_bgimage_notif_layout' may not be available // This maybe the case if a jar is used instead of an aar. private static void addBackgroundImage(JSONObject fcmJson, NotificationCompat.Builder notifBuilder) throws Throwable { - // Required to right align image - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) + // Not adding Background Images to API Versions < 16 or >= 31 + if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || + android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + OneSignal.Log(OneSignal.LOG_LEVEL.VERBOSE, + "Cannot use background images in notifications for device on version: " + android.os.Build.VERSION.SDK_INT); return; + } Bitmap bg_image = null; JSONObject jsonBgImage = null; From 338da7df5e2593de18310e515189657e58a18b0e Mon Sep 17 00:00:00 2001 From: emawby Date: Tue, 7 Dec 2021 15:37:33 -0800 Subject: [PATCH 2/2] bumping SdkVersions from 30 to 31 to check for Android 12 --- Examples/OneSignalDemo/app/build.gradle | 4 ++-- OneSignalSDK/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/OneSignalDemo/app/build.gradle b/Examples/OneSignalDemo/app/build.gradle index f148dcee32..95361f75ca 100644 --- a/Examples/OneSignalDemo/app/build.gradle +++ b/Examples/OneSignalDemo/app/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' apply plugin: 'com.android.application' android { - compileSdkVersion 30 + compileSdkVersion 31 defaultConfig { minSdkVersion 16 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" multiDexEnabled true diff --git a/OneSignalSDK/build.gradle b/OneSignalSDK/build.gradle index 024b41090a..8bb3a47424 100644 --- a/OneSignalSDK/build.gradle +++ b/OneSignalSDK/build.gradle @@ -4,8 +4,8 @@ buildscript { ext { buildVersions = [ - compileSdkVersion: 30, - targetSdkVersion: 30 + compileSdkVersion: 31, + targetSdkVersion: 31 ] androidGradlePluginVersion = '3.6.2' googleServicesGradlePluginVersion = '4.3.2'