Capacitor plugin for alarm notification.
Android : minSdkVersion = 26(Using Notification Channel)
iOS : developing
SET_ALARM
and Notification Channel
is used.
So Min Android SDK Version = 26
Developing
npm install capacitor-alarm-notification
npx cap sync android|ios
The code is automatically added with npx cap sync.
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);
}});
}
}
10 min alarm
setAlarm(60 * 10)
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)