Skip to content

Commit

Permalink
Increment plugin version to 3.0.0-dev.4 with some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gdelataillade committed Nov 22, 2023
1 parent e9b4a4e commit d58f103
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.0-dev.4
* [iOS] Remove notification sound.
* Throw exception if alarm settings are invalid.
* Improve README.

## 3.0.0-dev.3
* Update README.
* Add minor improvements.
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ assetAudio | `String` | The path to you audio asset you want to use as rin
loopAudio | `bool` | If true, audio will repeat indefinitely until alarm is stopped.
vibrate | `bool` | If true, device will vibrate indefinitely until alarm is stopped. If [loopAudio] is set to false, vibrations will stop when audio ends.
volume | `double` | Sets system volume level (0.0 to 1.0) at [dateTime]; reverts on alarm stop. Defaults to current volume if null.
when alarm is stopped.
fadeDuration | `double` | Duration, in seconds, over which to fade the alarm volume. Set to 0.0 by default, which means no fade.
notificationTitle | `String` | The title of the notification triggered when alarm rings if app is on background.
notificationTitle | `String` | The title of the notification triggered when alarm rings.
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.
androidFullScreenIntent | `bool` | Whether to turn screen on when android alarm notification is triggered. Enabled by default.

Note that if `notificationTitle` and `notificationBody` are both empty, iOS will not show the notification and Android will show an empty notification.

If you enabled `enableNotificationOnKill`, you can chose your own notification title and body by using this method before setting your alarms:
```Dart
await Alarm.setNotificationOnAppKillContent(title, body)
Expand All @@ -85,7 +86,7 @@ To avoid unexpected behaviors, if you set an alarm for the same time as an exist

## 📱 Example app

Don't hesitate to check out the example's code, and take a look at the app:
Don't hesitate to check out the [example's code](https://github.com/gdelataillade/alarm/tree/main/example), and take a look at the app:

![home](https://github.com/gdelataillade/alarm/assets/32983806/695736aa-b55f-4050-8b0d-274b0d46714a)
![edit](https://github.com/gdelataillade/alarm/assets/32983806/05329836-9fbe-462c-aa1e-dce0fa70f455)
Expand All @@ -101,8 +102,8 @@ Don't hesitate to check out the example's code, and take a look at the app:
| While playing other media| ✅ | ✅ | ✅ | ✅
| App killed | 🤖 | 🤖 | 🤖 | ✅

✅ : iOS and Android
🤖 : Android only.
✅ : iOS and Android.\
🤖 : Android only.\
Silenced: Means that the notification is not shown directly on the top of the screen. You have to go in your notification center to see it.

## ❓ FAQ
Expand Down Expand Up @@ -134,6 +135,12 @@ While periodic alarms can be implemented on Android, this is not feasible for iO

Related issue [here](https://github.com/gdelataillade/alarm/issues/47#issuecomment-1820896276).

### Why was my app rejected by the App Store for guideline issues?

The rejection may relate to plugin's background audio functionality, essential for alarm apps. Clarify in your submission that background activity is crucial for your alarm app to notify users effectively. Ensure compliance with Apple's guidelines on background processes.

For more guidance, see: [App Store Rejection Issues](https://github.com/gdelataillade/alarm/discussions/87).

## ⚙️ Under the hood

### Android
Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _ExampleAlarmHomeScreenState extends State<ExampleAlarmHomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('alarm 3.0.0-dev.3')),
appBar: AppBar(title: const Text('alarm 3.0.0-dev.4')),
body: SafeArea(
child: alarms.isNotEmpty
? ListView.separated(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.0-dev.3"
version: "3.0.0-dev.4"
async:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/SwiftAlarmPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin {
let content = UNMutableNotificationContent()
content.title = title
content.body = body
content.sound = UNNotificationSound.default
content.sound = nil

let trigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(delayInSeconds), repeats: false)
let request = UNNotificationRequest(identifier: "alarm-\(id)", content: content, trigger: trigger)
Expand Down
25 changes: 20 additions & 5 deletions lib/alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ class Alarm {
/// If you set an alarm for the same [dateTime] as an existing one,
/// the new alarm will replace the existing one.
static Future<bool> set({required AlarmSettings alarmSettings}) async {
if (!alarmSettings.assetAudioPath.contains('.')) {
throw AlarmException(
'Provided asset audio file does not have extension: ${alarmSettings.assetAudioPath}',
);
}
alarmSettingsValidation(alarmSettings);

for (final alarm in Alarm.getAlarms()) {
if (alarm.id == alarmSettings.id ||
Expand Down Expand Up @@ -95,6 +91,25 @@ class Alarm {
return false;
}

static void alarmSettingsValidation(AlarmSettings alarmSettings) {
if (!alarmSettings.assetAudioPath.contains('.')) {
throw AlarmException(
'Provided audio path is not valid: ${alarmSettings.assetAudioPath}',
);
}
if (alarmSettings.volume != null &&
(alarmSettings.volume! < 0 || alarmSettings.volume! > 1)) {
throw AlarmException(
'Volume must be between 0 and 1. Provided: ${alarmSettings.volume}',
);
}
if (alarmSettings.fadeDuration < 0) {
throw AlarmException(
'Fade duration must be positive. Provided: ${alarmSettings.fadeDuration}',
);
}
}

/// When the app is killed, all the processes are terminated
/// so the alarm may never ring. By default, to warn the user, a notification
/// is shown at the moment he kills the app.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: alarm
description: A simple Flutter alarm manager plugin for both iOS and Android.
version: 3.0.0-dev.3
version: 3.0.0-dev.4
homepage: https://github.com/gdelataillade/alarm

environment:
Expand Down

0 comments on commit d58f103

Please sign in to comment.