periodic_alarm

Last updated:

0 purchases

periodic_alarm Image
periodic_alarm Images
Add to Cart

Description:

periodic alarm

Getting Started #
Android installation steps #
In your android/app/build.gradle, make sure you have the following config:
android {
compileSdkVersion 33
[...]
defaultConfig {
[...]
multiDexEnabled true
}
}
copied to clipboard
After that, add the following to your AndroidManifest.xml within the <manifest></manifest> tags:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- For apps with targetSDK=31 (Android 12) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
copied to clipboard
Next, within the <application></application> tags, add:
<service
android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
<receiver
android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmBroadcastReceiver"
android:exported="false"/>
<receiver
android:name="dev.fluttercommunity.plus.androidalarmmanager.RebootBroadcastReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
copied to clipboard
Finally, add your audio asset(s) to your project like usual.
How to use #
Add to your pubspec.yaml:
flutter pub add periodic_alarm
copied to clipboard
First, you have to initialize the periodic_alarm service in your main function:
await PeriodicAlarm.init()
copied to clipboard
Then, you have to define your alarm settings:
final alarmSettings = AlarmSettings(
id: id,
dateTime: dateTime,
assetAudioPath: 'assets/alarm.mp3',
loopAudio: true,
fadeDuration: 3.0,
notificationTitle: 'This is the title',
notificationBody: 'This is the body',
enableNotificationOnKill: true,
monday: true,
tuesday : true,
wednesday : true,
thursday : true,
friday : true,
saturday : true,
sunday : true,
active : true,

);
copied to clipboard
And finally set the alarm:
await PeriodicAlarm.setOneAlarm(alarmModel: alarmModel)
copied to clipboard



Property
Type
Description




id
int
Unique identifier of the alarm.


alarmDateTime
DateTime
The date and time you want your alarm to ring.


assetAudio
String
The path to you audio asset you want to use as ringtone. Can be local asset or network URL.


loopAudio
bool
If true, audio will repeat indefinitely until it is stopped.


fadeDuration
double
Duration, in seconds, over which to fade the alarm volume. Set to 0 by default, which means no fade.


notificationTitle
String
The title of the notification triggered when alarm rings if app is on background.


notificationBody
String
The body of the notification.


enableNotificationOnKill
bool
Whether to show a notification when application is killed to warn the user that the alarm he set may not ring. Enabled by default.

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.