Praveen JP Praveen JP - 4 years ago 76
AngularJS Question

How to set vibration for local notification using ionic & cordova?

Could anyone tell how to set vibration in local notification for every notification i want to get vibrate in my mobile.

Local Notification Sample Code:

$cordovaLocalNotification.schedule({
id : remId,
title : name.innerHTML,
text : note.value,
at : alertDate
});


Vibrate Code:

$cordovaVibration.vibrate(200);


Please help me.. if is it possible, please give me a good solution for me.

Thank You!

Answer Source

Use the vibration plugin: cordova-plugin-vibration

Adding vibration is as simple as:

navigator.vibrate(1500);

Coupled with a notification, you can do something like this:

$cordovaLocalNotification.add({

        id: "12345",
        message: "Test",
        title: "Test",
        autoCancel: false,
        sound: null,
        date: new Date(),

    }).then(function () {

        navigator.vibrate(1500);
}); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download