-
Notifications
You must be signed in to change notification settings - Fork 53
handleActionWithIdentifier not firing when app is not running (i.e. force-quit). #3
Comments
Supports actions for backgrounded app but still suffers from issue of silent actions on force-quitted app (see holmesal#3)
Just to clarify - is I think you're probably right that the failure is due to the completion handler being called too early - to test, can you try commenting out lines 131 and 136 in RNNotificationActions.m and see if your JS callbacks work when the application has been killed? Let me know if that fixes it - if so, storing those completion blocks by actionId on the obj-c side should do the trick. My objective-c skills are pretty noob-level, but I can give implementing that a shot. |
Haven't tested, but could this be related? facebook/react-native#1282 (even though I'm using RN 0.18.0-rc and this seems to have been resolved in 0.14)? |
Hi, holmesal , There is still a minor issue that can not be easy fix: as the app is not running in the forground, the component may not be mounted. So the NotifcationAction needs to be initialized out side of the component to be able to register the event as soon as the JS get parsed. |
handleActionWithIdentifier
works perfectly when app is backgrounded, but as soon as the app is killed/force-quit, actions on push notifications go silently, appearing not to trigger[RNNotificationActions application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo withResponseInfo:responseInfo completionHandler:completionHandler];
at all.Performing a task within the
handleActionWithIdentifier
declaration works fine (i.e. not sending a notification over the bridge to react-native).I have an inkling that it might be related to
done()
(i.e. thecompletionHandler
) being called too early and terminating the app before the task/operation can take place (see http://stackoverflow.com/a/29912511/1183749), though I have taken precautions to only call done() after completing my task (write to db). This, obviously, only works when the app is backgrounded and I don't know how else to test whether the completionHandler is being called at the right time and the app is not being terminated prematurely.FYI: Background Modes for Remote Notifications is enabled in Capabilities.
Any ideas?
The text was updated successfully, but these errors were encountered: