After following this tutorial about how to use SwiftUI in combination with Handoff, but it isn't working for me. After trying a lot it seems like the OnContinueUserActivity is not called. The icon for handoff shows but once clicked on it, nothing happens. How can I fix this?
import SwiftUI
struct Board: View {
@State var BoardId: String
var body: some View {
VStack{
Text("Board: \(BoardId)")
}.onContinueUserActivity("bundleIdentifier.Board", perform: { userActivity in
if let Board = userActivity.userInfo?["Board"] as? String {
// Load handoff page
self.BoardId = Board
}
logUserActivity(userActivity, label: "on activity")
})
.userActivity("bundleIdentifier.Board", element: BoardId) {Board, activity in
let bundleid = Bundle.main.bundleIdentifier ?? ""
activity.addUserInfoEntries(from: ["Board": BoardId,
"setby": bundleid])
logUserActivity(activity, label: "activity")
}
}
}
struct Board_Previews: PreviewProvider {
static var previews: some View {
Board(BoardId: "NaN")
}
}
func logUserActivity(_ activity: NSUserActivity, label: String = "") {
print("\(label) TYPE = \(activity.activityType)")
print("\(label) INFO = \(activity.userInfo ?? [:])")
}
for people come across this in the future, swiftui has newly implemented approach for receiving url from universal links(or, deep links) it's no longer
continue useractivity
based approachsomething like this.