-
Notifications
You must be signed in to change notification settings - Fork 25
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
Notification actions support #5
Comments
Agreed, great package. I've run into this limitation too. I tried to add support, but ran into an issue I'm not sure how to get around. After adding Actions to the Notification object I get this error: Failed to construct 'Notification': Actions are only supported for persistent notifications shown using ServiceWorkerRegistration.showNotification(). I'm using Blazor server, so not using ServiceWorkers. I think it should be possible to get this to work if you're using WASM. |
@jtsoya539 Good idea, any idea how to implement it? |
@vertonghenb Implement the Action class. public class Action
{
public string Action { get; set; }
public string Title { get; set; }
public string Icon { get; set; }
} inject [Inject]
private INotificationService _notificationService { get; set; } then, I did this (using the anonymous type here, but originally using the NotificationOptions class) var title = "Title";
var options = new
{
// Put other options here.
actions = new List<Action>
{
new Action { Action = "action1", Title = "Action1", Icon = "icon url" },
new Action { Action = "action2", Title = "Action2", Icon = "icon url" },
// You can add as much as Notification.maxActions
}
};
await _notificationService.CreateAsync(title, options); read more about Notification.maxActions however, in my environment, in order to achieve this, I had to rewrite the JavaScript side code as well. export async function create(title, options) {
const reg = await navigator.serviceWorker.getRegistration();
reg.showNotification(title, options);
} Since it uses ServiceWorker, I can't pullRequest my implementation of NotificationAction to this repository. |
Hi, @vertonghenb, Thank you very much for your project. I have a question, why https://agreeable-rock-071180b03.azurestaticapps.net/ does not work in android and the version https://web-push-book.gauntface.com/demos/notification-examples/ yes.. any difference in the code? Error: Thanks. |
Hi, @xDaniel17. I know answers to that question, so I will answer it for you. https://agreeable-rock-071180b03.azurestaticapps.net/ uses this Notification constructor, which is not supported by Android (Chrome and WebView). |
Thank you so much for your response @sho9029 ! |
@sho9029 Have you found a Solution for catching the Action Click? "notificationclick" doesnt seem to work |
@bennimoser If you use firebase, this comment may be resolve your problem. |
Hi. I am facing issue. Click event is not getting generated |
Hi @vertonghenb!
Thanks for this great package! 💯
Any chance to add support for notification actions following NotificationAction APIs?
The text was updated successfully, but these errors were encountered: