createActivity method
Create an iOS 16.1+ live activity.
When the activity is created, an activity id is returned.
Data is a map of key/value pairs that will be transmitted to your iOS extension widget.
Files like images are limited by size,
be sure to pass only small file size (you can use resizeFactor
for images).
StaleIn
indicates if a StaleDate should be added to the activity. If the value is null or the Duration
is less than 1 minute then no staleDate will be used. The parameter only affects the live activity on
iOS 16.2+ and does nothing on on iOS 16.1
Implementation
Future<String?> createActivity(
String activityId,
Map<String, dynamic> data, {
bool removeWhenAppIsKilled = false,
Duration? staleIn,
}) async {
if (defaultTargetPlatform == TargetPlatform.iOS) {
await _appGroupsFileService.sendFilesToAppGroups(data);
}
return LiveActivitiesPlatform.instance.createActivity(
activityId,
data,
removeWhenAppIsKilled: removeWhenAppIsKilled,
staleIn: staleIn,
);
}