naal_alarm

Last updated:

0 purchases

naal_alarm Image
naal_alarm Images
Add to Cart

Description:

naal alarm

Flutter background alarm trigger #
A flutter plugin for Android to launch app from background at specific time just like stock alarm app in Android
Installation
naal_alarm: ^1.0.0
# or
flutter pub add naal_alarm
copied to clipboard
Initialization
void main() {
// Very important to call before initialize since it
// ensures the binding is available and ready before
// any native call
WidgetsFlutterBinding.ensureInitialized();

// initialize Required for alarm events to bind with flutter method channel
FlutterAlarmBackgroundTrigger.initialize();

runApp(const MyApp());
}

copied to clipboard
Create instance
var alarmPlugin = FlutterAlarmBackgroundTrigger();
copied to clipboard
Set Alarm
alarmPlugin.addAlarm(
// Required
DateTime.now().add(Duration(seconds: 10)),

//Optional
uid: "YOUR_APP_ID_TO_IDENTIFY",
payload: {"YOUR_EXTRA_DATA":"FOR_ALARM"},

// screenWakeDuration: For how much time you want
// to make screen awake when alarm triggered
screenWakeDuration: Duration(minutes: 1)
)
copied to clipboard
Receive event when alarm trigger
alarmPlugin.requestPermission().then((isGranted){
if(isGranted){
alarmPlugin.onForegroundAlarmEventHandler((alarm){
// Perform your action here such as navigation
// This event will be triggered on both cases,
// when app is in foreground or background!
print(alarm.id)
})
}
})
copied to clipboard
Additional methods #
Request permission to draw over other apps
Future<bool> requestPermission()
copied to clipboard
Add
Future<AlarmItem> addAlarm(
DateTime time,
{
String? uid,
Map<String, dynamic>? payload,
Duration screenWakeDuration
}
)
copied to clipboard
Get alarm by uid
Future<List<AlarmItem>> getAlarmByUid(String uid)
copied to clipboard
Get all scheduled alarms
Future<List<AlarmItem>> getAllAlarms()
copied to clipboard
Get single alarm
Future<AlarmItem> getAlarm(int id)
copied to clipboard
Get alarm by payload
Future<List<AlarmItem>> getAlarmByPayload(Map<String, dynamic> payload)
copied to clipboard
Get alarm by time
Future<List<AlarmItem>> getAlarmByTime(DateTime time)
copied to clipboard
Alarm trigger event
void onForegroundAlarmEventHandler(OnForegroundAlarmEvent alarmEvent)
copied to clipboard
Delete single alarm
Future<void> deleteAlarm(int id)
copied to clipboard
Delete by payload
Future<void> deleteAlarmsByPayload(Map<String, dynamic> payload)
copied to clipboard
Delete by time
Future<void> deleteAlarmsByTime(DateTime dateTime)
copied to clipboard
Delete by uid
Future<void> deleteAlarmsByUid(String uid)
copied to clipboard
Delete all scheduled alarms
Future<void> deleteAllAlarms()
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.