Home IOS Development ios – Tips on how to finish liveActivity through aps push

ios – Tips on how to finish liveActivity through aps push

0
ios – Tips on how to finish liveActivity through aps push

[ad_1]

I’ve built-in liveActivity in to my challenge, it does present up on the lock scree, I can replace it through the script beneath with “occasion”: “replace”, however I am unable to shut it through “occasion”: “finish” instantly.

I added this operate “endActivity(exercise: Exercise, dismissTimeInterval: Double?)” in anticipation that it’ll work, but it surely did not.

Right here the way it appears like:

func endActivity(exercise: Exercise<LiveActivityWidgetAttributes>, dismissTimeInterval: Double?) async {
        let finalContent = LiveActivityWidgetAttributes.ContentState(startTimestamp: 0, arrivalTime: 0)
        let dismissalPolicy: ActivityUIDismissalPolicy
        if let dismissTimeInterval = dismissTimeInterval {
            if dismissTimeInterval <= 0 {
                dismissalPolicy = .fast
            } else {
                dismissalPolicy = .after(.now + dismissTimeInterval)
            }
        } else {
            dismissalPolicy = .default
        }
        await exercise.finish(ActivityContent(state: finalContent, staleDate: nil), dismissalPolicy: dismissalPolicy)
    }

Once I ship the “replace” through apn – it really works and does replace the contents of the exercise. Once I do ship the “finish” through apn – no errors in terminal and nothing occurs it the app:

  • We’re fully uploaded and fantastic
    < HTTP/2 200

Right here is the information I ship to finish the liveActivity:

--data 
'{"aps": {
   "timestamp": '$(date +%s)',
   "occasion": "finish",
   "dismissal-date": 1663177260 //timestamp up to now to shut liveActivity instantly
}}' 

What’s lacking or fully fallacious? Frequent updates are enabled.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here