Skip to content

Commit

Permalink
Increment plugin version to 4.0.0-dev.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdelataillade committed Aug 25, 2024
1 parent 558df0d commit a897f00
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.0.0-dev.1
* Add notification action stop button.

## 3.1.5
* [Android] Fix volume/focus post-alarm.
* Export `AlarmSettings` class in `Alarm` class.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ final alarmSettings = AlarmSettings(
notificationTitle: 'This is the title',
notificationBody: 'This is the body',
enableNotificationOnKill: Platform.isIOS,
notificationActionSettings: const NotificationActionSettings(
hasStopButton: true,
),
);
```

Expand All @@ -66,7 +69,7 @@ notificationTitle | `String` | The title of the notification triggered whe
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.
notificationActionSettings | `NotificationActionSettings` | Settings for notification action buttons (only stop at the moment).
notificationActionSettings | `NotificationActionSettings` | Settings for notification action buttons (only stop at the moment). Won't work on iOS if app was killed. Disabled by default.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class AlarmService : Service() {
return START_NOT_STICKY
}

// Only Android 12+ ?
val id = intent.getIntExtra("id", 0)
val action = intent.getStringExtra(AlarmReceiver.EXTRA_ALARM_ACTION)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class NotificationHandler(private val context: Context) {
}
}

// TODO: Add wake lock with loop param
fun buildNotification(
title: String,
body: String,
Expand Down
1 change: 1 addition & 0 deletions example/lib/screens/edit_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class _ExampleAlarmEditScreenState extends State<ExampleAlarmEditScreen> {
enableNotificationOnKill: Platform.isIOS,
notificationActionSettings: const NotificationActionSettings(
hasStopButton: true,
stopButtonText: 'Stop the alarm',
),
);
return alarmSettings;
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 @@ -81,7 +81,7 @@ class _ExampleAlarmHomeScreenState extends State<ExampleAlarmHomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('alarm 3.1.5')),
appBar: AppBar(title: const Text('alarm 4.0.0-dev.1')),
body: SafeArea(
child: alarms.isNotEmpty
? ListView.separated(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/shortcut_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _ExampleAlarmHomeShortcutButtonState
bool showMenu = false;

Future<void> onPressButton(int delayInHours) async {
var dateTime = DateTime.now();
var dateTime = DateTime.now().add(Duration(hours: delayInHours));
double? volume;

if (delayInHours != 0) {
Expand Down
2 changes: 0 additions & 2 deletions ios/Classes/SwiftAlarmPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin {
audioURL = documentsDirectory.appendingPathComponent(assetAudio)
}

NSLog("[SwiftAlarmPlugin] Audio URL: \(audioURL)")

do {
return try AVAudioPlayer(contentsOf: audioURL)
} catch {
Expand Down
6 changes: 3 additions & 3 deletions ios/Classes/services/AlarmStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class AlarmStorage {
alarms.append(alarm)
} catch {
// If decoding fails, print the error
print("[AlarmStorage] Failed to decode AlarmSettings: \(error)")
NSLog("[AlarmStorage] Failed to decode AlarmSettings: \(error)")
}
} else {
print("[AlarmStorage] Failed to convert String to Data")
NSLog("[AlarmStorage] Failed to convert String to Data")
}
} else {
print("[AlarmStorage] Value is not of type String")
NSLog("[AlarmStorage] Value is not of type String")
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions ios/Classes/services/NotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class NotificationManager: NSObject, UNUserNotificationCenterDelegate {
}
}

// MARK: - UNUserNotificationCenterDelegate

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
handleAction(withIdentifier: response.actionIdentifier, for: response.notification)
completionHandler()
Expand Down
2 changes: 2 additions & 0 deletions lib/model/alarm_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class AlarmSettings {
final bool androidFullScreenIntent;

/// Settings for the notification actions.
///
/// Won't work on iOS if app was killed. Disabled by default.
final NotificationActionSettings notificationActionSettings;

/// Returns a hash code for this `AlarmSettings` instance using
Expand Down
11 changes: 1 addition & 10 deletions lib/src/ios_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ class IOSAlarm {
static Future<void> handleMethodCall(MethodCall call) async {
final arguments = call.arguments as Map<String, dynamic>;
final id = arguments['id'] as int?;
if (id == null) return;

await Alarm.reload(id);

switch (call.method) {
case 'alarmStoppedFromNotification':
Alarm.updateStream.add(id);
default:
throw MissingPluginException('not implemented');
}
if (id != null) await Alarm.reload(id);
}

/// Calls the native function `setAlarm` and listens to alarm ring state.
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.1.5
version: 4.0.0-dev.1
homepage: https://github.com/gdelataillade/alarm

environment:
Expand Down

0 comments on commit a897f00

Please sign in to comment.