Could anyone tell how to set vibration for local notification in 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.
Thank You!
How about playing sound?, please update if you have found a solutions
Hi ,
I was fiddling with this stuff and have some solutions .
@praveenjp
for the vibration part :
Try using cordova vibration plugin that you have used already.
and call this vibration code from with the event that is raised as a result of notification:
cordova.plugins.notification.local.on(“trigger”, function(notification) {
$cordovaVibration.vibrate(200);
});
@samdeniyi
you can play sound by following this syntax:
$cordovaLocalNotification.schedule({
id:1234,
title:“Stretch!”,
at:trigger_time,
sound:“file://alert_android.mp3”,
icon: “res://icon”,
smallIcon:“res://ic_stat_stretch”,
text:“blah blah.”
})
using this syntax make sure that you keep the file within www folder at the same hirarchy as js or img
let me know if it works.
regards,
Indrajit
@indrajit87
hi, Thanks for your response…!
KimB
April 10, 2016, 10:50pm
5
indrajit87:
at:trigger_time,
Hi @indrajit87 , i tried what you did but it didn’t work.
I downloaded the plugin and localnotification, tried the example there was given.
here is what I did.
$cordovaLocalNotification.schedule({
id: 1,
text: ‘Hello World’,
at:trigger_time,
every: ‘minute’
}).then(function (result) {
counter++;
navigator.vibrate(3000);
$cordovaLocalNotification.update({
id: 1,
badge: counter,
});
});
I checked my phone setting and even tried the navigator.vibration(time) as well. Have i missed something?
UPDATE:
nvm, I got it. It was my setting, I need to turn it on to get the vibration to work.