Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling web service for the notification action for a remote push notification on iOS

I need to call 2 web service calls when user clicks on a button on the interactive notification. This notification is a remote push notification. The web service calls work fine when the application is in foreground or background. But the behavior is not consistent when the app is in suspended state (user forcefully killed the app). Some times it works well i.e, calls both the web service calls. some times it fails and the most common reason I have seen in the logs is

Application background launch action for notification response action vscd.escalate received action response { description = "The operation couldn’t be completed. (BSActionErrorDomain error 4.)"; }>

I have only "Remote notifications" enabled under capabilities. "Background fetch" is not enabled.

Any help is appreciated.

like image 265
Shashidhar Yamsani Avatar asked Jan 19 '26 18:01

Shashidhar Yamsani


1 Answers

I had this happen when I hadn't registered the notification delegate properly on app launch - just like they warn in the documentation. The fix was to ensure the delegate was set explicitly during didFinishLaunchingWithOptions.

Previously, my app set the delegate during load of the initial view controller, which works for every case except when the app is not running in the foreground or the background, but is launched by the notification itself.

like image 113
jab Avatar answered Jan 21 '26 07:01

jab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!