Skip to content

Commit

Permalink
Merge pull request #4 from JasperEssien2/hotfix/locked-screen-alarm-ring
Browse files Browse the repository at this point in the history
Fixed bug that causes alarm to ring partially during screen lock
  • Loading branch information
JasperEssien2 committed Jul 7, 2022
2 parents ea4bfb9 + 1f44ebc commit d4f709c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import android.content.pm.PackageManager
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.RingtoneManager
import android.net.Uri
import android.os.Build
Expand Down Expand Up @@ -64,7 +65,7 @@ fun Context.showNotification(
longArrayOf(
0, 100, 200, 300
)
).setSilent(false).setOnlyAlertOnce(true)
).setSilent(false)
.setFullScreenIntent(
pendingIntent(
requestCode = 35,
Expand Down Expand Up @@ -132,10 +133,12 @@ private fun NotificationManager.buildChannel(
}

channel.enableLights(true)

val notificationSound: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM)
val audioAttributes = AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ALARM)
.setLegacyStreamType(AudioManager.STREAM_ALARM)
.build()
channel.setSound(notificationSound, audioAttributes)

Expand Down
6 changes: 4 additions & 2 deletions lib/flutter_alarm_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class FlutterAlarmNotification {

static registerPort({NotificationActionCallback? callback}) {
IsolateNameServer.registerPortWithName(
_uiReceivePort.sendPort, _buttonActionIsolateName);
_uiReceivePort.sendPort,
_buttonActionIsolateName,
);

if (callback != null) {
listenable.listen((message) {
Expand All @@ -55,7 +57,7 @@ class FlutterAlarmNotification {
/// Set a recursive alarms that sets of at a particular time
/// and repeats at an interval
/// To set configurations for this alram use [alarmConfig]
/// [nottificationBuilder] accepts fields that's pertaining to the notification
/// [notificationBuilder] accepts fields that's pertaining to the notification
/// if you need to pass data to the intent set [intentBuilder] parameter .
static Future<void> registerRepeatingAlarm({
required AlarmConfig alarmConfig,
Expand Down

0 comments on commit d4f709c

Please sign in to comment.