capacitor-alarm-notification
v0.0.1
Published
alarm plugin for capacitor
Downloads
3
Readme
What's this?
Capacitor plugin for alarm notification.
Current State
Android : minSdkVersion = 26(Using Notification Channel)
iOS : developing
Implementations
Android
SET_ALARM
and Notification Channel
is used.
So Min Android SDK Version = 26
iOS
Developing
Set up
Install Plugin
npm install capacitor-keep-screen-on
Sync to Capacitor project
npx cap sync android|ios
Add code (iOS)
The code is automatically added with npx cap sync.
Add code (Android)
Add the following to MainActivity.java
(Receiver is in MainActivity for the convenience of the plugin)
// import
import com.go.capacitor.alarm.notification.CapacitorAlarmNotification;
// register plugin
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
...
...
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(CapacitorAlarmNotification.class);
}});
}
}
Usage
usage
set Alarm
10 min alarm
setAlarm(60 * 10)
clear Alarm
setAlarm(0)
import { Plugins } from '@capacitor/core'
const { CapacitorAlarmNotification } = Plugins
# set Alarm
CapacitorAlarmNotification.setAlarm({
sec: 60 * 10,
sound: false, // false: vibration only, true: ring system alarm sound
title: 'Boost', // notification title
text: 'time is up' // notification text
})
// clear Alarm
CapacitorAlarmNotification.setAlarm(sec: 0)