Closed cassiano-r closed 5 years ago
use ionic serve
Local Notifications support ios and android only, not support web(pwa). https://capacitor.ionicframework.com/docs/apis/local-notifications
You should try native build.
Hi. I think in principle it could be possible to implement this for web as well. What do You think? I would like to help implementing it.
Desktop notification could be done via new Notification(...)
.
https://developer.mozilla.org/en-US/docs/Web/API/notification/Notification
Sound (if the one from Notification
is not enough) could be done via new Audio(...)
.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement
I would like to develop a proof-of-concept, but first, please let me know what You think.
I think I can make a PoC based on capacitor/core/src/web/toast.ts
. Comments are welcome!
Sure, pull requests are always welcome
Hey all, just pushed a very basic implementation of local notifications of the web: https://github.com/ionic-team/capacitor/blob/master/core/src/web/local-notifications.ts
What's missing is support for actions and all the different options for notifications, such as images and sound (though not sure that stuff is even possible).
@karol-depka if you'd like to expand on what I've built here that could be easier and also very welcome!
Description of the problem:
ERROR Error: Uncaught (in promise): LocalNotifications does not have web implementation. at c (polyfills.js:3) at Function.t.reject (polyfills.js:3) at CapacitorWeb.pluginMethodNoop (web-runtime.js:31) at new HomePage (home.ts:76) at createClass (core.js:12449) at createDirectiveInstance (core.js:12284) at createViewNodes (core.js:13742) at createRootView (core.js:13631) at Object.createProdRootView [as createRootView] (core.js:14324) at ComponentFactory_.create (core.js:11236)
Affected platform
OS of the development machine
Other information:
Capacitor version:
node version:
npm version:
CocoaPods version:
Steps to reproduce:
import { Plugins } from '@capacitor/core'; const { LocalNotifications } = Plugins;
//Schedule LocalNotifications.schedule({ notifications: [ { title: "Title", body: "Body", id: 1, schedule: { at: new Date(Date.now() + 1000 * 5) }, sound: null, attachments: null, actionTypeId: "", extra: null } ] });
Link to sample project: