Skip to content

Instantly share code, notes, and snippets.

@ashishkakkad8
Last active September 20, 2022 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashishkakkad8/af8dada8469263f4b213f88db2cdeb6a to your computer and use it in GitHub Desktop.
Save ashishkakkad8/af8dada8469263f4b213f88db2cdeb6a to your computer and use it in GitHub Desktop.
Sample View to demonstrate Start Activity
import SwiftUI
import ActivityKit
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "capsule")
.imageScale(.large)
.foregroundColor(.black)
Text("Hello, Dynamic Island!")
}.onAppear(perform: {
startActivity()
})
.padding()
}
func startActivity() {
let attributes = ActivityAttributesSample()
let contentState = ActivityAttributesSample.Status(value: "This is dynamic island!")
do {
let _ = try Activity<ActivityAttributesSample>.request(attributes: attributes, contentState: contentState)
}
catch (let error) {
print(error.localizedDescription)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment