Push notifications: Print notif and data payload when resuming app

- on-notification listener registered in root component
- print data (hardcoded keys) and notif payload to debug
This commit is contained in:
Oskar Thorén 2017-09-21 17:14:23 +02:00 committed by Roman Volosovskyi
parent 0badfd6b5b
commit 9ab7ebdcf2
3 changed files with 18 additions and 2 deletions

View File

@ -68,7 +68,9 @@
:component-did-mount
(fn []
(when config/notifications-wip-enabled?
(notifications/on-refresh-fcm-token)))
(notifications/on-refresh-fcm-token)
;; TODO(oskarth): Background click_action handler
(notifications/on-notification)))
:component-will-unmount
(fn []
(.stop react/http-bridge)

View File

@ -44,7 +44,8 @@
(fn []
(when config/notifications-wip-enabled?
(notifications/request-permissions)
(notifications/on-refresh-fcm-token)))
(notifications/on-refresh-fcm-token)
(notifications/on-notification)))
:component-will-unmount
(fn []
(.stop react/http-bridge))

View File

@ -32,3 +32,16 @@
(fn [x]
(log/debug "on-refresh-fcm-token: " x)
(dispatch [:update-fcm-token x]))))
;; TODO(oskarth): Only called in background on iOS right now.
;; NOTE(oskarth): Hardcoded data keys :sum and :msg in status-go right now.
(defn on-notification []
(.on (.-default rn/react-native-fcm)
(.-Notification (.-FCMEvent rn/react-native-fcm))
(fn [event-js]
(let [event (js->clj event-js :keywordize-keys true)
data (select-keys event [:sum :msg])
aps (:aps event)]
(log/debug "on-notification event: " (pr-str event))
(log/debug "on-notification aps: " (pr-str aps))
(log/debug "on-notification data: " (pr-str data))))))