Comments (8)
Thanks!
You have the ability to register 2 kinds of callbacks: foreground
and background
. See the example.
In future I want to rename the callbacks. foreground
is called when the app runs in foreground and the notification is triggered, e.g. ontrigger
.
background
is called when the app is running in background or not running and the user taps on the notification, e.g. onclick
.
from cordova-plugin-local-notifications.
Ow yeah sure i know about these maybe i did not make myself clear enough... i am curious if i could send a notification with some parameter in it... and then when i click the notification... as you said via the foreground or background trigger i would obtain that special parameter... and based on that parameter i would do certain action?
from cordova-plugin-local-notifications.
Each notification can be created with an unique ID. Both callbacks were called with that ID as an argument.
You could use that ID to identify your application specific data to start certain actions.
from cordova-plugin-local-notifications.
Hi katzer. Sorry, I dont know from what reason i changed my question to the parameter one... but the main question is: How can i use the
window.plugin.notification.local.add({ (with specific time) like 20minutes from now... with "navigator.notification.vibrate(2000);" ...
Your callbacks "You have the ability to register 2 kinds of callbacks: foreground and background" Works when the user opens the notification... but i need to vibrate the phone when the notification ARRIVE.
Example:
The mobile is in my pocket... the notification is set up to the 11AM ... at 11AM the phone will vibrate in the pocket... how?
from cordova-plugin-local-notifications.
Hello,
thats not possible for the moment. But its a valid use case. Will be possible in near future.
from cordova-plugin-local-notifications.
Hello,
Ok. Great, thank you.
from cordova-plugin-local-notifications.
O yes, that would be very useful for my app too!
from cordova-plugin-local-notifications.
ok i can make a alarm notification, the sound still no working, only if you use default sound, working, this is for functionality for vibrate, please comment if for you works
document.addEventListener('deviceready', function () {
var now = new Date().getTime(),
from_now = new Date(now + 5*1000);
window.cordova.plugins.notification.local.schedule({
firstAt:from_now,
title: 'title',
text: 'description',
every: 2,
},success);
window.cordova.plugins.notification.local.on("trigger", function (notification) {
vibrate();
});
}, false);
function success(){
alert('alert create');
}
function vibrate() {
//for this you need to add plugin vibrate from cordova **https://github.com/apache/cordova-plugin-vibration**
navigator.vibrate(2000);
}
and this working with default sound and vibration
from cordova-plugin-local-notifications.
Related Issues (20)
- Getting a build error after migrating our Ionic 5 app from Cordova 10 to Cordova 11 LOCAL NOTIFICATIONS HOT 8
- Android Build for Android Platfom 10.1.2 or 11.0.0 Crashes the app. HOT 16
- iOS: Location Trigger Notification No Longer Working
- Local Notifications Trigger events Not working on Android 12 HOT 1
- Android 12 (SDK 31+): Tap on notifications only opens app when notifications are grouped. HOT 50
- bug: Gradle 7 compatibility HOT 6
- Local notifications does not subscribe to events when the notification is triggered in the background or when device is Locked on IOS Device 16.1.2 OS HOT 1
- Local Notifications Subscribe to events when app is in the background IOS: Help please
- Small Icon and Trigger Notification in Android 12
- Play custom audio files on Ionic Cordova Local Notifications IOS
- Android 12+ notification permissions not requested and showing as blocked HOT 10
- Apps Now Having Problems Adding Plugin HOT 1
- Plugin get installed, app get compiled and launched on android, but notification is just not working. HOT 1
- Notification group with actions at a particular time
- When I click notification app crashes HOT 2
- request permission is never fired at all on android 13 HOT 4
- NullPointerException from isInForeground
- NPM is still at beta 2 and beta 3 has been out since 2018
- "Your use of exact alarms is causing your app to crash for some Android users" on Google Play Console. HOT 7
- Cant get custom sound to work in both Android and ios
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-local-notifications.