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

Only alert once option #2035

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ A notification does have a set of configurable properties.
| lockscreen | | | |
| mediaSession | | | |
| number | | | |
| onlyAlertOnce | x | - | Android only. 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 | | | |
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