Skip to content

Commit 7a18958

Browse files
committed
release: SDK 1.19.2
1 parent 84d58db commit 7a18958

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+9810
-2517
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="https://static.batch.com/documentation/Readmes/logo_batch_full_178@2x.png" srcset="https://static.batch.com/documentation/Readmes/logo_batch_full_178.png 1x" width="178" height="68" alt="Batch Logo" />
1+
<img src="https://static.batch.com/documentation/Readmes/logo_batch_full_178@2x.png" srcset="https://static.batch.com/documentation/Readmes/logo_batch_full_178.png 1x" width="178" height="80" alt="Batch Logo" />
22

33
# Batch Android SDK
44

Sources/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# Recommended ignore from Gradle
1111
**/.idea/dataSources.*
1212
**/.idea/inspectionProfiles
13+
**/.idea/deploymentTargetDropDown.xml
1314
**/.idea/misc.xml
1415
**/.idea/gradle.xml
1516
**/.idea/modules.xml

Sources/.idea/codeStyles/Project.xml

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/.idea/runConfigurations/sample_tests_firebase_lab.xml

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/sdk/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ ext {
1616
}
1717

1818
android {
19-
compileSdkVersion 32
19+
compileSdkVersion 33
2020
defaultPublishConfig "release"
2121

2222
resourcePrefix "com_batchsdk_"
2323

2424
defaultConfig {
2525
minSdkVersion 15
26-
targetSdkVersion 32
26+
targetSdkVersion 33
2727
versionCode 1
28-
versionName "1.19.1"
28+
versionName "1.19.2"
2929
buildConfigField "String", SDK_VERSION, "\"$versionName\""
30-
buildConfigField "Integer", API_LEVEL, '50'
30+
buildConfigField "Integer", API_LEVEL, '51'
3131
buildConfigField "Integer", MESSAGING_API_LEVEL, '12'
3232
buildConfigField "String", WS_DOMAIN, '"ws.batch.com"'
3333

@@ -110,7 +110,7 @@ dependencies {
110110
compileOnly "com.google.android.gms:play-services-location:$playServicesVersion"
111111
compileOnly "com.google.android.gms:play-services-nearby:$playServicesVersion"
112112
compileOnly 'com.google.android.play:core:1.9.0'
113-
compileOnly "com.google.firebase:firebase-core:17.4.3"
113+
compileOnly "com.google.firebase:firebase-iid:21.1.0"
114114
compileOnly "com.google.firebase:firebase-messaging:22.0.0"
115115
compileOnly project(':sdk-stubs')
116116
compileOnly project(':sdk-processor')
@@ -124,6 +124,7 @@ dependencies {
124124

125125
androidTestImplementation 'junit:junit:4.12'
126126
androidTestImplementation "androidx.annotation:annotation:$androidXLibraryVersion"
127+
androidTestImplementation 'androidx.test:core-ktx:1.4.0'
127128
androidTestImplementation 'androidx.test:rules:1.4.0'
128129
androidTestImplementation 'androidx.test:runner:1.4.0'
129130
androidTestImplementation 'androidx.test.ext:junit:1.1.3'

Sources/sdk/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
android:theme="@style/com_batchsdk_ActionActivityTheme"
3131
android:exported="false" />
3232

33+
<activity
34+
android:name=".BatchPermissionActivity"
35+
android:theme="@style/com_batchsdk_PermissionActivityTheme"
36+
android:exported="false" />
37+
3338
<activity
3439
android:name=".debug.BatchDebugActivity"
3540
android:theme="@style/com_batchsdk_DebugActivityTheme"

Sources/sdk/src/main/java/com/batch/android/Batch.java

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ public final class Batch {
118118
*/
119119
private static boolean didLogOptOutWarning = false;
120120

121-
/**
122-
* Last notification authorization status
123-
*/
124-
private static Boolean lastNotificationAuthorizationStatus = null;
125-
126121
/**
127122
* Default placement
128123
*/
@@ -1139,6 +1134,17 @@ public static void setNotificationInterceptor(@Nullable BatchNotificationInterce
11391134
public static void refreshRegistration() {
11401135
PushModuleProvider.get().refreshRegistration();
11411136
}
1137+
1138+
/**
1139+
* Request the notification runtime permission.
1140+
* Android 13 (API 33) introduced a new runtime permission for notifications called POST_NOTIFICATIONS.
1141+
* Without this permission, apps on Android 13 cannot show notifications.
1142+
* This method does nothing on Android 12 and lower, or if your application does not target API 33 or higher.
1143+
* @param context requesting the permission
1144+
*/
1145+
public static void requestNotificationPermission(@NonNull Context context) {
1146+
PushModuleProvider.get().requestNotificationPermission(context);
1147+
}
11421148
}
11431149

11441150
// ---------------------------------------------------->
@@ -2180,7 +2186,7 @@ else if (lastStop == null && state == State.READY) {
21802186
}
21812187

21822188
// Check if the notification authorization status changed from a previous value
2183-
checkForNotificationAuthorizationChange(context);
2189+
NotificationAuthorizationStatus.checkForNotificationAuthorizationChange(context);
21842190

21852191
newIntent = null;
21862192
}
@@ -2616,44 +2622,6 @@ private static void updateVersionManagement() {
26162622
}
26172623
}
26182624

2619-
private static void checkForNotificationAuthorizationChange(@NonNull Context context) {
2620-
boolean hasNotificationAuthorization = NotificationAuthorizationStatus.canAppShowNotifications(
2621-
context,
2622-
BatchNotificationChannelsManagerProvider.get()
2623-
);
2624-
2625-
// First time, store it, as the start will send it
2626-
// If it changes, force a Push query
2627-
if (lastNotificationAuthorizationStatus == null) {
2628-
lastNotificationAuthorizationStatus = hasNotificationAuthorization;
2629-
return;
2630-
}
2631-
2632-
if (lastNotificationAuthorizationStatus != hasNotificationAuthorization) {
2633-
lastNotificationAuthorizationStatus = hasNotificationAuthorization;
2634-
Logger.internal(
2635-
"Notification Authorization changed (is now " + (hasNotificationAuthorization ? "true" : "false") + ")"
2636-
);
2637-
2638-
RuntimeManager runtimeManager = RuntimeManagerProvider.get();
2639-
boolean sdkReady = runtimeManager.runIfReady(() -> {
2640-
// Trigger a push token webservice
2641-
Registration registration = PushModuleProvider.get().getRegistration(context);
2642-
if (registration == null) {
2643-
Logger.internal(
2644-
"Notif. Authorization changed but no registration is available. Not sending update to the server."
2645-
);
2646-
return;
2647-
}
2648-
WebserviceLauncher.launchPushWebservice(runtimeManager, registration);
2649-
});
2650-
2651-
if (!sdkReady) {
2652-
Logger.internal("Notif. Authorization changed but SDK isn't ready. Not sending update to the server.");
2653-
}
2654-
}
2655-
}
2656-
26572625
/**
26582626
* Called when the lib has been updated
26592627
*

Sources/sdk/src/main/java/com/batch/android/BatchEventDataPrivateHelper.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

Sources/sdk/src/main/java/com/batch/android/BatchNotificationChannelsManager.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.batch.android;
22

3+
import android.annotation.SuppressLint;
34
import android.app.NotificationChannel;
45
import android.app.NotificationChannelGroup;
56
import android.app.NotificationManager;
@@ -81,18 +82,19 @@ String getChannelId(@Nullable BatchPushPayload payload) {
8182
return channelId;
8283
}
8384

84-
private boolean shouldRegisterDefaultChannel() {
85-
return channelOverride == null;
85+
private boolean isChannelIdOverridden() {
86+
return channelOverride != null;
8687
}
8788

88-
void registerBatchChannelIfNeeded(Context c, boolean forceIfOverridden) {
89-
if (!forceIfOverridden && !shouldRegisterDefaultChannel()) {
90-
Logger.internal(PushModule.TAG, "Channel ID overriden, not registering Batch's channel.");
89+
void registerBatchChannelIfNeeded(Context c) {
90+
if (isChannelIdOverridden()) {
91+
Logger.internal(PushModule.TAG, "Channel ID overridden, not registering Batch's channel.");
9192
return;
9293
}
9394
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
9495
Logger.internal(PushModule.TAG, "Registering default Batch notification channel");
9596
//try {
97+
@SuppressLint("WrongConstant")
9698
NotificationChannel channel = new NotificationChannel(
9799
DEFAULT_CHANNEL_ID,
98100
getBatchChannelName(),
@@ -234,6 +236,7 @@ public static boolean openSystemChannelSettings(@NonNull Context context, @NonNu
234236
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
235237
try {
236238
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
239+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
237240
intent.putExtra(Settings.EXTRA_CHANNEL_ID, channelId);
238241
intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
239242
context.startActivity(intent);

Sources/sdk/src/main/java/com/batch/android/BatchNotificationChannelsManagerPrivateHelper.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ public static String getChannelId(BatchNotificationChannelsManager manager) {
1313
return manager.getChannelId(null);
1414
}
1515

16-
public static void registerBatchChannelIfNeeded(
17-
BatchNotificationChannelsManager manager,
18-
Context context,
19-
boolean forceIfOverridden
20-
) {
21-
manager.registerBatchChannelIfNeeded(context, forceIfOverridden);
16+
public static void registerBatchChannelIfNeeded(BatchNotificationChannelsManager manager, Context context) {
17+
manager.registerBatchChannelIfNeeded(context);
2218
}
2319
}

0 commit comments

Comments
 (0)