diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index be62d25545..1518d1b4fe 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -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) diff --git a/src/status_im/ios/core.cljs b/src/status_im/ios/core.cljs index c2fee30082..3d99905655 100644 --- a/src/status_im/ios/core.cljs +++ b/src/status_im/ios/core.cljs @@ -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)) diff --git a/src/status_im/utils/notifications.cljs b/src/status_im/utils/notifications.cljs index 49b410b9e1..3fe16e94a5 100644 --- a/src/status_im/utils/notifications.cljs +++ b/src/status_im/utils/notifications.cljs @@ -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))))))