user13579316
user13579316

Reputation: 171

How to create alarm app in flutter for ios

What I want is to set a time and run background process (dart) at that specific time, just like any basic alarm app. I searched a lot, but I couldn't find anything useful for iOS. I need it to be in dart, because I can't use platform channel.

Upvotes: 7

Views: 9815

Answers (3)

Ragu
Ragu

Reputation: 1

Hi @gdelat I have used the alarm plugin as mentioned in the flutter documentation and received the following error in IOS. Android it is working as expected.

alarm/SwiftAlarmPlugin.swift:16: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=561015905 "(null)" 2023-02-10 12:55:17.197468+0800 Runner[25375:1895342] alarm/SwiftAlarmPlugin.swift:16: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=561015905 "(null)"

Upvotes: 0

gdelataillade
gdelataillade

Reputation: 36

If you need to play an alarm audio even if app is on background, I may have a solution for you.

I've just released a package that makes alarm integration easy for iOS and Android. It utilized platform channel though.

https://pub.dev/packages/alarm

Upvotes: 0

user13579316
user13579316

Reputation: 171

i found a work around for the problem using flutter local notification package , you can schedule notification in the future and it would work in foreground, background and when app terminated so covering all cases and work perfectly in my scenario. if you need to do something like alarm or reminder for IOS it will do the job for you.

var scheduledNotificationDateTime =
    DateTime.now().add(Duration(seconds: 5));
var androidPlatformChannelSpecifics =
    AndroidNotificationDetails('your other channel id',
        'your other channel name', 'your other channel description');
var iOSPlatformChannelSpecifics =
    IOSNotificationDetails();
NotificationDetails platformChannelSpecifics = NotificationDetails(
    androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.schedule(
    0,
    'scheduled title',
    'scheduled body',
    scheduledNotificationDateTime,
    platformChannelSpecifics);

Upvotes: 9

Related Questions