I'm curious, has anyone managed to get SwiftUI's .onContinueUserActivity working? Looking at the sample code from Apple, it seems to be working in their app (note the testing instructions in the ReadMe file). But when I set up a new project for myself and try to reproduce it, I can't get it to work.
Mine is just a vanilla SwiftUI project with the following changes:
- In the info.plist, I have defined:
<key>NSUserActivityTypes</key>
<array>
<string>com.example.RnD.customActivity</string>
</array>
- Here's my app definition:
@main
struct UserActivityDemoApp: App {
static let customActivityType = "com.example.RnD.customActivity"
var body: some Scene {
WindowGroup {
ContentView()
.userActivity(Self.customActivityType, isActive: true) { activity in
activity.title = "Doing Custom Activity"
activity.isEligibleForSearch = true
activity.isEligibleForHandoff = true
activity.becomeCurrent()
print("Defining user activity")
}
.onContinueUserActivity(Self.customActivityType) { activity in
print("we should resume \(activity.title ?? "misconfigured activity")")
}
}
}
}
I would think this should be enough to get the "we should resume ..." message printed, but it isn't working. Is there something more I need to do in the .userActivity
block? Apple's docs seem to suggest that I have done enough.