Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android changes: Modified behavior of the push notifications and added a new features. #11

Conversation

Jacob-Cuevas
Copy link

@Jacob-Cuevas Jacob-Cuevas commented Aug 10, 2023

Description

This PR adds the changes for the following issues:

  • Issue Do-not-disturb support #2 : Added logic to request access to the user about modify the DO NOT DISTURB settings of the phone. Once the app has access then it will be able to redirect the user to the phone settings and let him add the "CORES Mobile" app to the exception rule of the phone, giving us the chance to override the sound and vibration settings on the phone when a push notification is received (logic implemented in the issue Custom sounds in the normal and critical push notifications #6).

  • Issue Notification grouping #3 : Added logic to create a notification grouper that will be displayed when there is more than 1 notification displayed in the Notification Drawer. This grouper will remove the existing and the incoming notifications to display a single item with the content of all of them.

  • Issue Remove notifications from OS tray when they are read in the Inbox page of CM #4 : Added a new function in the plugin to let the CORES Mobile app invoke it to remove notification from the notification drawer by a specific ID.

  • Issue Open Inbox Preview page #5 : Modified the listeners used to catch when a notification is received, pressed or dismissed to be able to open the "Inbox Preview" page of the CORES Mobile app and display the content of the notification.

  • Issue Custom sounds in the normal and critical push notifications #6 : Modified the function used to set behavior (sound, vibration and tap behavior) of the push notifications to flex them according to the type of the push notification received. There are 2 types:

    • Normal Notifications. These will have the default behavior of a notification but their vibration and sound will be flexed according to the payload received by Firebase.
    • Critical Notifications. These notification will modify the sound/vibration settings of the phone to ALWAYS be displayed on screen, play a sound and vibrate no matter if the phone is in silent mode or the "Do not disturb" option is enabled. The sound and vibration will be also determined by the payload received by Firebase. The sound settings can be modified in the "Inbox Settings" inside the CORES Mobile app.

Also, this PR includes a fix for the issue https://github.com/havesource/cordova-plugin-push/issues/214 of the original repository of this plugin: Fixes the white icon displayed in the notification drawer when a push notification is received and displayed in the phone. Since there is no default icon, we are using the CORES Mobile icon that was added in the Android project when it is compilated.

Related Issue

#2
#3
#4
#5
#6

Motivation and Context

These changes are a result of the features requested by T4M.

How Has This Been Tested?

These changes were tested using a real device with the following specs:

  • Device: Pixel 6a
  • Android version: 13

Screenshots (if appropriate):

IMG_0569.mov
 - Open the DND settings from the Inbox settings of the CORES Mobile app.
IMG_0570.mov
IMG_0573.mov
 - When the notification drawer has an item and new notifications are received.
IMG_0571.mov
IMG_0574.mov
IMG_0577.mov
 - Remove the notification opened in the CORES Mobile app from the notification grouper.
IMG_0575.mov
  • Issue Open Inbox Preview page #5 :

    • Tapped a single/grouped notification when the app is in:
      • Foreground: The user will be redirected to the Inbox page.
IMG_0578.mov
      - Background: The app will be returned to foreground and the user will be redirected to the Inbox page.
IMG_0581.mov
      - Closed: The app will be closed and the "Inbox Preview" page will be displayed to render the content of the pressed notification.
IMG_0582.mov
IMG_0583.mov
IMG_0586.MOV
 - Critical notification (pending video).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…er that will be created to replace the received notifications to have them all in a single item.

Android logic.
…ge of the CORES Mobile app when a notification is pressed (single or the notification grouper).

Android logic.
…push notifications according to the type defined in their payload (normal and critical notifications).

Android logic.
…n or the notification grouper by an ID provided by CORES Mobile app.
Copy link

@ElliotNB ElliotNB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes! There are so many CORES references scattered throughout this entire plugin that I don't see how we're ever going to be able to make a pull request to the upstream repo or pull down recent updates from the upstream repo. Is there not a low-effort way to minimize all this intermingling of CORES Mobile with the Push Plugin?

@Jacob-Cuevas
Copy link
Author

@ElliotNB at the moment we can avoid the use of the corespayload object to get the notificationd_id value from the received notification, but the problem will be the custom variables that we are adding in the data that is sent to the CORES Mobile app. Let me think in a long term solution to be able to have this logic isolated.

@Jacob-Cuevas Jacob-Cuevas merged commit 01b93b3 into TransformativeMed:master Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants