Skip to content

Commit

Permalink
Added onlyAlertOnce option
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevuono committed Aug 21, 2024
1 parent de438bf commit 98b8090
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
67 changes: 34 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,41 +94,42 @@ A notification does have a set of configurable properties.
<i>The table is not complete regarding the support.</i>


| Property | Android | iOS | Comment |
| Property | Android | iOS | Comment |
| :------------ | :-------| :-- | :------------------------ |
| actions | | | |
| attachments | | | |
| autoClear | | | |
| badge | | | |
| channel | x | - | Don't use it, it is not functional. Since Android 8: Channel-ID of the chanel. In the future it will be renamed to channelId |
| clock | | | |
| color | | | |
| data | | | |
| defaults | | | |
| foreground | | | |
| group | | | |
| groupSummary | | | |
| icon | | | |
| iconType | | | |
| id | | | |
| launch | | | |
| led | | | |
| lockscreen | | | |
| mediaSession | | | |
| number | | | |
| priority | | | |
| progressBar | x | - | Natively not supported by iOS, [see Stackoverflow](https://stackoverflow.com/questions/48500532/progress-view-in-local-notification/48500734#48500734) |
| silent | | | |
| smallIcon | | | |
| actions | | | |
| attachments | | | |
| autoClear | | | |
| badge | | | |
| channel | x | - | Don't use it, it is not functional. Since Android 8: Channel-ID of the chanel. In the future it will be renamed to channelId |
| clock | | | |
| color | | | |
| data | | | |
| defaults | | | |
| foreground | | | |
| group | | | |
| groupSummary | | | |
| icon | | | |
| iconType | | | |
| id | | | |
| launch | | | |
| led | | | |
| lockscreen | | | |
| mediaSession | | | |
| number | | | |
| onlyAlertOnce | x | - | Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing (see [documentation](https://developer.android.com/reference/android/app/Notification.Builder#setOnlyAlertOnce(boolean))). |
| priority | | | |
| progressBar | x | - | Natively not supported by iOS, [see Stackoverflow](https://stackoverflow.com/questions/48500532/progress-view-in-local-notification/48500734#48500734) |
| silent | | | |
| smallIcon | | | |
| sound | (x) | (x) | Property available but not useable. Cannot used to play a sound file. In Android it's only possible up to Android 7.1. Since Android 8, the channels take precedence and a channel would have to be created with a sound file, but this is not implemented yet. In iOS it would be possible, but must be implemented too. |
| sticky | | | |
| summary | | | |
| text | | | |
| timeoutAfter | | | |
| title | | | |
| trigger | | | |
| vibrate | | | |
| wakeup | | | |
| sticky | | | |
| summary | | | |
| text | | | |
| timeoutAfter | | | |
| title | | | |
| trigger | | | |
| vibrate | | | |
| wakeup | | | |

For their default values see:

Expand Down
2 changes: 1 addition & 1 deletion src/android/notification/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public Notification build() {
builder = findOrCreateBuilder()
.setDefaults(options.getDefaults())
.setExtras(extras)
.setOnlyAlertOnce(false)
.setOnlyAlertOnce(options.isOnlyAlertOnce())
.setChannelId(options.getChannel())
.setContentTitle(options.getTitle())
.setContentText(options.getText())
Expand Down
9 changes: 9 additions & 0 deletions src/android/notification/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,15 @@ MediaSessionCompat.Token getMediaSessionToken() {
return session.getSessionToken();
}

/**
* Gets if the notification shall only alert once.
*
* @return true if the notification shall only alert once.
*/
public boolean isOnlyAlertOnce(){
return options.optBoolean("onlyAlertOnce", false);
}

/**
* Strips the hex code #FF00FF => FF00FF
*
Expand Down
1 change: 1 addition & 0 deletions www/local-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports._defaults = {
lockscreen : true,
mediaSession : null,
number : 0,
onlyAlertOnce : false,
priority : 0,
progressBar : false,
silent : false,
Expand Down

0 comments on commit 98b8090

Please sign in to comment.