HomeiOS Developmentios - The way to get SwiftUI's .onContinueUserActivity working

ios – The way to get SwiftUI’s .onContinueUserActivity working


I am curious, has anybody managed to get SwiftUI’s .onContinueUserActivity working? Wanting on the pattern code from Apple, it appears to be working of their app (observe the testing directions within the ReadMe file). However once I arrange a brand new mission for myself and attempt to reproduce it, I can not get it to work.

Mine is only a vanilla SwiftUI mission with the next modifications:

  1. Within the data.plist, I’ve outlined:
    <key>NSUserActivityTypes</key>
    <array>
        <string>com.instance.RnD.customActivity</string>
    </array>
  1. This is my app definition:
@principal
struct UserActivityDemoApp: App {
    static let customActivityType = "com.instance.RnD.customActivity"
    
    var physique: some Scene {
        WindowGroup {
            ContentView()
                .userActivity(Self.customActivityType, isActive: true) { exercise in
                    exercise.title = "Doing Customized Exercise"
                    exercise.isEligibleForSearch = true
                    exercise.isEligibleForHandoff = true
                    exercise.becomeCurrent()
                    print("Defining person exercise")
                }
                .onContinueUserActivity(Self.customActivityType) { exercise in
                    print("we should always resume (exercise.title ?? "misconfigured exercise")")
                }
        }
    }
}

I’d suppose this ought to be sufficient to get the “we should always resume …” message printed, however it is not working. Is there one thing extra I have to do within the .userActivity block? Apple’s docs appear to recommend that I’ve accomplished sufficient.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments