Skip to content

Commit

Permalink
📝 Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
istornz committed Dec 16, 2022
1 parent 4273d52 commit 73342c3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@ You need to **implement** in your Flutter iOS project a **Widget Extension** & d

> ℹ️ You can check on this [ressource](https://levelup.gitconnected.com/how-to-create-live-activities-widget-for-ios-16-2c07889f1235) or [here](https://betterprogramming.pub/create-live-activities-with-activitykit-on-ios-16-beta-4766a347035b) for more native informations.
- In your extension, you need to create an ```ActivityAttributes``` called **EXACTLY** ```LiveActivitiesAppAttributes``` (if you rename, activity will be created but not appear!)

```swift
struct LiveActivitiesAppAttributes: ActivityAttributes, Identifiable {
public struct ContentState: Codable, Hashable { }

var id = UUID()
}
```

- Create an ```UserDefaults``` with your group id to access Flutter data in your Swift code.

```swift
// Create shared default with custom group
let sharedDefault = UserDefaults(suiteName: "YOUR_GROUP_ID")!

struct FootballMatchApp: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: LiveActivitiesAppAttributes.self) { context in
// create your live activity widget extension here
// to access Flutter properties:
let myVariableFromFlutter = sharedDefault.string(forKey: "myVariableFromFlutter")!

// [...]
}
}
}
```

- ## 💙 Flutter

- Import the plugin.
Expand Down
1 change: 0 additions & 1 deletion lib/live_activities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class LiveActivities {
/// Create an App Group inside "Runner" target & "Extension" in Xcode.
/// Be sure to set the *SAME* App Group in both targets.
Future init({required String appGroupId}) {
// _appGroupId = appGroupId;
_appGroupsImageService.appGroupId = appGroupId;
return LiveActivitiesPlatform.instance.init(appGroupId);
}
Expand Down

0 comments on commit 73342c3

Please sign in to comment.