Reputation: 4036
I've built an application that may notify a user after some period in time.
By "notify" I mean to play a sound using flutter_ringtone_player
plugin.
The android_alarm_manager_plus
is used to schedule a notification.
The problem is that it has stopped to work (to make a sound) after some moment in time. I suppose it is because of Flutter version upgrade or Android 13 version installed on the phone.
The oneShot
method duration is from 30 to 300 seconds I have tried.
Here is code I'm using to schedule method execution:
var dr = Duration(seconds: config.delay);
await saveShared(config);
_scheduled = await AndroidAlarmManager.oneShot(dr, helloAlarmID, playAlarm,
exact: true, wakeup: true, alarmClock: true, allowWhileIdle: true);
return _scheduled;
playAlarm
method implemented as below
static void playAlarm() async {
var config = await loadShared();
playImpl(config)
.then((_) => _scheduled = false)
.onError((error, stackTrace) {
print("failed to play notification");
print(error);
return true;
});
}
The whole NotifyModel class is here used to schedule and play notification. The AndroidManifest file.
The same code is working on
API 29
API 33
The problem is that it fails to work when built as release and installed from GooglePlay on the same Pixel 4a phone that is used to debug.
I do not have any plugin registration call in the playAlarm
or playImpl
method implementation.
The playImpl(ConfigNotify? config)
method is called from both AlarmManager and UI button click. Both FlutterRingtonePlayer.play
and FlutterRingtonePlayer.playNotification
are working properly when called form UI.
What should I check to understand the reason of the difference between debug and release application on Android 13?
[✓] Flutter (Channel stable, 3.3.1, on Ubuntu 22.04.1 LTS 5.15.0-48-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] VS Code (version 1.71.2)
I've just found the similar issue however can't get it working yet using Flutter 3.0.5
Upvotes: 0
Views: 782
Reputation: 4036
The @pragma('vm:entry-point')
annotation has to be applied to the callback function when using Flutter 3.3 and Alarm manager Plus 2.0.7
Upvotes: 2