live_activities 1.2.0
live_activities: ^1.2.0 copied to clipboard
A Flutter plugin to use iOS 16.1+ Live Activities & iPhone 14 Pro Dynamic Island features
Live Activities #
A Flutter plugin to use iOS 16.1+ Live Activities & iPhone 14 Pro Dynamic Island features.
π§ What is it ? #
This plugin use iOS ActivityKit API.
live_activities can be used to show dynamic live notification & implement dynamic island feature on the iPhone 14 Pro / Max β«οΈ
β οΈ live_activities is only intended to use with iOS 16.1+ ! It will simply do nothing on other platform & < iOS 16.1
π» Getting started #
Due to some technical restriction, it's not currently possible to only use Flutter π«£.
You need to implement in your Flutter iOS project a Widget Extension & develop in Swift/Objective-C your own Live Activity / Dynamic Island design.
βΉοΈ You can check into the example repository for a full example app using Live Activities & Dynamic Island
π§΅ Native #
-
π± Create natively your Live Activity view tutorial
- β«οΈ (Opt.) Create natively a Dynamic Island tutorial
-
π Enable push notification capabilities.
- βΉοΈ Enable live activities for both your app & widget extension.
π Flutter #
- π Import the plugin.
import 'package:live_activities/live_activities.dart';
- π£ Create your dynamic activity.
final Map<String, String> activityModel = {
'name': 'Margherita',
'ingredient': 'tomato, mozzarella, basil',
'quantity': '1',
};
_liveActivitiesPlugin.createActivity(activityModel.toMap());
β οΈ For now you can only pass values as
String.
Communicate over Native π§΅ and Flutter π #
In order to pass some useful data between your native live activity / dynamic island with your Flutter app you just need to setup URL scheme.
- π Add a custom url scheme in Xcode by navigating to Runner > Runner > URL Types > URL Schemes
- π In your Swift code, just create a new link and open to your custom URL Scheme
Link(destination: URL(string: "la://my.app/order?=123")!) { // Replace "la" with your scheme
Text("See order")
}
β οΈ Don't forget to put the URL Scheme you have typed in the previous step.
- π In your Flutter App, you just need to listen on the url scheme Scheme
_liveActivitiesPlugin.urlSchemeStream().listen((schemeData) {
// do what do you want here π€
});
π Documentation #
| Name | Description | Returned value |
|---|---|---|
.createActivity() |
Create an iOS live activity, | String The activity identifier |
.updateActivity() |
Update the live activity data by using the activityId provided |
Future When the activity was updated |
.endActivity() |
End the live activity by using the activityId provided |
Future When the activity was ended |
.getAllActivitiesIds() |
Get all activities ids created | Future<List<String>> List of all activities ids |
.endAllActivities() |
End all live activities of the app | Future When all activities was ended |
.areActivitiesEnabled() |
Check if live activities feature are supported & enabled | Future<bool> Live activities supported or not |
.urlSchemeStream() |
Subscription to handle every url scheme (ex: when the app is opened from a live activity / dynamic island button, you can pass data) | Future<UrlSchemeData> Url scheme data which handle scheme url host path queryItems |
π― Roadmap #
- β Support multiple type instead of
String(Date, Number etc.). - β Inject a Widget inside the notification with Flutter Engine ?
- β Pass data across native dynamic island and Flutter app.
- β Pass data across native live activity notification and Flutter app.
- β Cancel all activities.
- β Get all activities ids.
- β Check if live activities are supported.