scheduleOneShotAlarm method
Implementation
@override
Future<String> scheduleOneShotAlarm({
required double timestamp,
String? label,
String? tintColor,
}) async {
try {
final args = {
'timestamp': timestamp,
if (label != null) 'label': label,
if (tintColor != null) 'tintColor': tintColor,
};
final alarmId = await methodChannel.invokeMethod<String>(
'scheduleOneShotAlarm',
args,
);
if (alarmId == null) {
throw PlatformException(
code: 'UNKNOWN_ERROR',
message: 'Failed to schedule alarm: null result',
);
}
return alarmId;
} on PlatformException catch (e) {
if (e.code == 'UNSUPPORTED_VERSION') {
throw PlatformException(
code: 'UNSUPPORTED_VERSION',
message: 'AlarmKit is only available on iOS 26.0 and above',
);
}
rethrow;
}
}