Skip to content

Commit

Permalink
Merge pull request #2731 from dimagi/pushNotificationsNewCategory
Browse files Browse the repository at this point in the history
Adds a new notification channel for push notifications
  • Loading branch information
shubham1g5 authored Nov 20, 2023
2 parents 170f638 + b375af2 commit b0b712b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@
<string name="notification_channel_user_session_description" cc:translatable="true">Notification containing information around current user session like when the current session is scheduled to expire</string>
<string name="notification_channel_server_communication_title" cc:translatable="true">Server Communications</string>
<string name="notification_channel_server_communication_description" cc:translatable="true">Notifications for status of any background server communication happening at the moment like CommCare App updates, log submission etc.</string>
<string name="notification_channel_push_notfications_title" cc:translatable="true">Priority notifications from Server</string>
<string name="notification_channel_push_notfications_description" cc:translatable="true">Notifications sent from server directly to notify user of priority tasks</string>

<!--Recovery Measures-->
<string name="recovery_measure_reinstall_method" cc:translatable="true">Choose Reinstall Method</string>
Expand Down Expand Up @@ -451,6 +453,6 @@
<string name="dependency_missing_dialog_go_to_store" cc:translatable="true">Install from Store</string>
<string name="dependency_missing_dialog_playstore_not_found" cc:translatable="true">No Play Store found on your device</string>
<string name="fcm_notification">FCM Notification</string>
<string name="fcm_default_notification_channel">notification-channel-server-communications</string>
<string name="fcm_default_notification_channel">notification-channel-push-notifications</string>
<string name="app_with_id_not_found">Required CommCare App is not installed on device</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/org/commcare/CommCareNoficationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class CommCareNoficationManager {
public static final String NOTIFICATION_CHANNEL_ERRORS_ID = "notification-channel-errors";
public static final String NOTIFICATION_CHANNEL_USER_SESSION_ID = "notification-channel-user-session";
public static final String NOTIFICATION_CHANNEL_SERVER_COMMUNICATIONS_ID = "notification-channel-server-communications";
public static final String NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID = "notification-channel-push-notifications";

/**
* Handler to receive notifications and show them the user using toast.
Expand Down Expand Up @@ -188,6 +189,11 @@ public void createNotificationChannels() {
R.string.notification_channel_server_communication_title,
R.string.notification_channel_server_communication_description,
NotificationManager.IMPORTANCE_LOW);

createNotificationChannel(NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID,
R.string.notification_channel_push_notfications_title,
R.string.notification_channel_push_notfications_description,
NotificationManager.IMPORTANCE_DEFAULT);
}

@TargetApi(Build.VERSION_CODES.O)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void showNotification(RemoteMessage.Notification notification) {
contentIntent = PendingIntent.getActivity(this, 0, i, 0);

NotificationCompat.Builder fcmNotification = new NotificationCompat.Builder(this,
CommCareNoficationManager.NOTIFICATION_CHANNEL_SERVER_COMMUNICATIONS_ID)
CommCareNoficationManager.NOTIFICATION_CHANNEL_PUSH_NOTIFICATIONS_ID)
.setContentTitle(notificationTitle)
.setContentText(notificationText)
.setContentIntent(contentIntent)
Expand Down

0 comments on commit b0b712b

Please sign in to comment.