Wakeup/Alarm Clock PhoneGap/Cordova Plugin
Platform Support
This plugin supports PhoneGap/Cordova apps running on both iOS and Android.
Version Requirements
This plugin is meant to work with Cordova 3.5.0+.
Installation
Automatic Installation using PhoneGap/Cordova CLI (iOS and Android)
- Make sure you update your projects to Cordova iOS version 3.5.0+ before installing this plugin.
cordova platform update ios
cordova platform update android
- Install this plugin using PhoneGap/Cordova cli:
cordova plugin add https://github.com/EltonFaust/cordova-plugin-wakeuptimer-ef.git
Usage
window.wakeuptimer.bind(
function (result) {
if (result.type == 'set') {
console.log('wakeup alarm set: ', result);
} else if (result.type == 'wakeup') {
console.log('wakeup alarm detected: ', result);
} else if (result.type == 'stopped') {
console.log('alarm stopped: ', result);
} else {
console.log('wakeup unhandled: ', result);
}
},
function (error) {}
);
window.wakeuptimer.wakeup(
successCallback, errorCallback,
{
alarms: [
{
type: 'onetime',
time: { hour: 14, minute: 30 },
extra: { message: 'json containing app-specific information to be posted when alarm triggers' },
},
{
type: 'daylist',
time: { hour: 14, minute: 30 },
days: [ 'monday', 'wednesday', 'friday' ],
extra: { message: 'json containing app-specific information to be posted when alarm triggers' },
},
]
}
);
window.wakeuptimer.checkAlarmPerm(
function (allowed) {
console.log('Alarm permission already granted? ', allowed ? 'yes' : 'no');
},
errorCallback,
);
window.wakeuptimer.openAppAlarmSettings(
function (opened) {
console.log('App notification settings opened? ', opened ? 'yes' : 'no');
},
errorCallback,
);
window.wakeuptimer.checkNotificationPerm(
function (allowed) {
console.log('Notification permission already granted? ', allowed ? 'yes' : 'no');
},
errorCallback,
);
window.wakeuptimer.requestNotificationPerm(
function (allowed) {
console.log('Notification permission was granted? ', allowed ? 'yes' : 'no');
},
errorCallback,
);
window.wakeuptimer.openAppNotificationSettings(
function (opened) {
console.log('App notification settings opened? ', opened ? 'yes' : 'no');
},
errorCallback,
);
window.wakeuptimer.shouldRequestNotificationPermRat(
function (should) {
console.log('Should show why the permission is important before requesting again? ', should ? 'yes' : 'no');
},
errorCallback,
);
window.wakeuptimer.checkAutoStartPrefs(
function (hasAutoStartPreferences) {
if (hasAutoStartPreferences) {
console.log('Auto Start preference available!');
}
},
function (error) { }
);
window.wakeuptimer.openAutoStartPrefs(
function (openedPreferences) {
if (openedPreferences) {
console.log('Auto Start preference opened');
}
},
function (error) { }
);
window.wakeuptimer.stop(function () {}, function (error) {});
window.wakeuptimer.configure(
function () {
console.log('wakeup startup service configured!');
},
function (error) { },
{
streamingUrl: 'http://hayatmix.net/;yayin.mp3.m3u',
streamingOnlyWifi: true,
ringtone: ringtoteUrl,
volume: 100,
streamType: window.cordova.plugins.NativeRingtones.(STREAM_ALARM | STREAM_MUSIC),
notificationText: "Wakeup it's %time%",
}
);
window.cordova.plugins.NativeRingtones.getRingtone(
(nativeRingtones ) => {
window.wakeuptimer.configure(
function () { }, function (error) { },
{
ringtone: nativeRingtones[0].Url,
}
);
},
function (error) {}, 'alarm'
);
Log Debug
adb logcat -s "WakeupStartService" -s "WakeupReceiver" -s "WakeupPlugin" -s "WakeupBootReceiver" -s "WakeupAutoStartHelper"