Giter Club home page Giter Club logo

Comments (8)

katzer avatar katzer commented on May 28, 2024

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.

EnchanterIO avatar EnchanterIO commented on May 28, 2024

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.

katzer avatar katzer commented on May 28, 2024

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.

EnchanterIO avatar EnchanterIO commented on May 28, 2024

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.

katzer avatar katzer commented on May 28, 2024

Hello,

thats not possible for the moment. But its a valid use case. Will be possible in near future.

from cordova-plugin-local-notifications.

EnchanterIO avatar EnchanterIO commented on May 28, 2024

Hello,

Ok. Great, thank you.

from cordova-plugin-local-notifications.

amunters avatar amunters commented on May 28, 2024

O yes, that would be very useful for my app too!

from cordova-plugin-local-notifications.

jomarocas avatar jomarocas commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.