Skip to content

Commit 013a5d8

Browse files
committed
Code review changes
1 parent 94d2456 commit 013a5d8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

AndroidSDK/src/com/leanplum/LeanplumNotificationHelper.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@
3131
import java.util.Map;
3232

3333
/**
34-
* LeanplumNotificationHelper class.
34+
* LeanplumNotificationHelper helper class for push notifications.
3535
*
3636
* @author Anna Orlova
3737
*/
3838
class LeanplumNotificationHelper {
39-
39+
/**
40+
* If notification channels are supported this method will try to create
41+
* NotificationCompat.Builder with default notification channel if default channel id is provided.
42+
* If notification channels not supported this method will return NotificationCompat.Builder for
43+
* context.
44+
*
45+
* @param context The application context.
46+
* @param isNotificationChannelSupported True if notification channels are supported.
47+
* @return NotificationCompat.Builder for provided context or null.
48+
*/
4049
// NotificationCompat.Builder(Context context) constructor was deprecated in API level 26.
4150
@SuppressWarnings("deprecation")
4251
static NotificationCompat.Builder getDefaultNotificationBuilder(Context context,
@@ -53,6 +62,17 @@ static NotificationCompat.Builder getDefaultNotificationBuilder(Context context,
5362
}
5463
}
5564

65+
/**
66+
* If notification channels are supported this method will try to create a channel with
67+
* information from the message if it doesn't exist and return NotificationCompat.Builder for this
68+
* channel. In the case where no channel information inside the message, we will try to get a
69+
* channel with default channel id. If notification channels not supported this method will return
70+
* NotificationCompat.Builder for context.
71+
*
72+
* @param context The application context.
73+
* @param message Push notification Bundle.
74+
* @return NotificationCompat.Builder or null.
75+
*/
5676
// NotificationCompat.Builder(Context context) constructor was deprecated in API level 26.
5777
@SuppressWarnings("deprecation")
5878
static NotificationCompat.Builder getNotificationBuilder(Context context, Bundle message) {

AndroidSDK/src/com/leanplum/LeanplumPushService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@ private static void showNotification(Context context, Bundle message) {
346346
}
347347
}
348348

349-
// Try to put notification on top of notification area.
349+
// Try to put a notification on top of the notification area. This method was deprecated in API
350+
// level 26. For API level 26 and above we must use setImportance(int) for each notification
351+
// channel, not for each notification message.
350352
if (Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT < 26) {
351353
builder.setPriority(Notification.PRIORITY_MAX);
352354
}

0 commit comments

Comments
 (0)