Skip to content

Commit

Permalink
Merge pull request #1495 from OneSignal/sunset_background_image_layout
Browse files Browse the repository at this point in the history
Don't set backgroundImageLayout if device is Android 12 or higher
  • Loading branch information
emawby authored Dec 9, 2021
2 parents 54e4b0f + 338da7d commit f968db4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Examples/OneSignalDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions OneSignalSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buildscript {

ext {
buildVersions = [
compileSdkVersion: 30,
targetSdkVersion: 30
compileSdkVersion: 31,
targetSdkVersion: 31
]
androidGradlePluginVersion = '3.6.2'
googleServicesGradlePluginVersion = '4.3.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f968db4

Please sign in to comment.