diff --git a/packages/masamune_notification/lib/functions/send_notification_functions_action.dart b/packages/masamune_notification/lib/functions/send_notification_functions_action.dart index 10f67c0aa..b40815522 100644 --- a/packages/masamune_notification/lib/functions/send_notification_functions_action.dart +++ b/packages/masamune_notification/lib/functions/send_notification_functions_action.dart @@ -18,6 +18,8 @@ class SendNotificationFunctionsAction this.tokens, this.topic, this.channel, + this.badgeCount, + this.sound = PushNotificationSound.defaultSound, this.data, }) : assert( tokens != null || topic != null, @@ -58,6 +60,16 @@ class SendNotificationFunctionsAction /// PUSH通知の送信先(トークン) final ModelToken? tokens; + /// Number of badges to display in PUSH notifications. + /// + /// PUSH通知で表示するバッジの数。 + final int? badgeCount; + + /// Sound of PUSH notifications. + /// + /// PUSH通知のサウンド。 + final PushNotificationSound sound; + @override String get action => "send_notification"; @@ -69,6 +81,8 @@ class SendNotificationFunctionsAction if (channel != null) "channel_id": channel, if (data != null) "data": data, if (tokens != null) "token": tokens!.value else "topic": topic, + if(badgeCount != null) "badge": badgeCount, + if (sound != PushNotificationSound.none) "sound": sound.value, }; } diff --git a/packages/masamune_notification/lib/masamune_notification.dart b/packages/masamune_notification/lib/masamune_notification.dart index 7f939b181..680d649dc 100644 --- a/packages/masamune_notification/lib/masamune_notification.dart +++ b/packages/masamune_notification/lib/masamune_notification.dart @@ -32,3 +32,4 @@ part 'src/push_notification.dart'; part 'src/push_notification_masamune_adapter.dart'; part 'src/push_notification_value.dart'; part 'src/push_notification_logger_event.dart'; +part 'src/push_notification_sound.dart'; diff --git a/packages/masamune_notification/lib/models/push_notification_schedule.dart b/packages/masamune_notification/lib/models/push_notification_schedule.dart index d2c8f2f33..20287b335 100644 --- a/packages/masamune_notification/lib/models/push_notification_schedule.dart +++ b/packages/masamune_notification/lib/models/push_notification_schedule.dart @@ -3,6 +3,7 @@ // Package imports: import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:masamune/masamune.dart'; +import 'package:masamune_notification/masamune_notification.dart'; import 'package:masamune_scheduler/masamune_scheduler.dart'; part 'push_notification_schedule.m.dart'; @@ -181,6 +182,8 @@ class ModelServerCommandPushNotificationSchedule String? topic, ModelToken? tokens, Uri? link, + int? badgeCount, + String? sound, }) = _ModelServerCommandPushNotificationSchedule; const ModelServerCommandPushNotificationSchedule._() @@ -238,6 +241,16 @@ class ModelServerCommandPushNotificationSchedule /// 通知から遷移するリンク。 Uri? get link => throw UnimplementedError(); + /// Number of badges to display in PUSH notifications. + /// + /// PUSH通知で表示するバッジの数。 + int? get badgeCount => throw UnimplementedError(); + + /// Sound of PUSH notifications. + /// + /// PUSH通知のサウンド。 + String? get sound => throw UnimplementedError(); + /// Command Name. /// /// コマンド名。 @@ -248,6 +261,8 @@ class ModelServerCommandPushNotificationSchedule static const String _kTitleKey = "title"; static const String _kTextKey = "text"; static const String _kChannelIdKey = "channelId"; + static const String _kSoundKey = "sound"; + static const String _kBadgeCountKey = "badgeCount"; static const String _kDataKey = "data"; static const String _kTopicKey = "topic"; static const String _kTokenKey = "token"; @@ -277,6 +292,8 @@ class ModelServerCommandPushNotificationSchedule }, _kTokenKey: tokens?.value, _kTopicKey: topic, + if (sound != null) _kSoundKey: sound, + if (badgeCount != null) _kBadgeCountKey: badgeCount, }; } @@ -300,6 +317,8 @@ class _ModelServerCommandPushNotificationSchedule this.topic, this.tokens, this.link, + this.badgeCount, + this.sound, }) : super._(); @override @@ -325,6 +344,12 @@ class _ModelServerCommandPushNotificationSchedule @override final ModelToken? tokens; + + @override + final int? badgeCount; + + @override + final String? sound; } /// Abstract class for defining a document with a schedule for PUSH notifications. diff --git a/packages/masamune_notification/lib/src/push_notification.dart b/packages/masamune_notification/lib/src/push_notification.dart index b297dc950..a4f94aebb 100644 --- a/packages/masamune_notification/lib/src/push_notification.dart +++ b/packages/masamune_notification/lib/src/push_notification.dart @@ -208,6 +208,8 @@ class PushNotification extends MasamuneControllerBase send({ required String title, @@ -216,6 +218,8 @@ class PushNotification extends MasamuneControllerBase