ios, ui, utils: relocated iOS notification permissions to home screen
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
b3ef1ed53a
commit
13c448032c
|
@ -32,7 +32,6 @@
|
|||
(.hide react/splash-screen))
|
||||
:component-did-mount
|
||||
(fn []
|
||||
(notifications/request-permissions)
|
||||
(notifications/on-refresh-fcm-token)
|
||||
(notifications/on-notification))
|
||||
:component-will-unmount
|
||||
|
|
|
@ -212,7 +212,8 @@
|
|||
:account-finalized
|
||||
(fn [{db :db} _]
|
||||
{:db db
|
||||
:dispatch [:navigate-to-clean :home]}))
|
||||
:dispatch-n [[:navigate-to-clean :home]
|
||||
[:request-notifications]]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-sign-in-time
|
||||
|
|
|
@ -176,6 +176,11 @@
|
|||
(fn [options]
|
||||
(permissions/request-permissions options)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::request-notifications-fx
|
||||
(fn [_]
|
||||
(notifications/request-permissions)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::testfairy-alert
|
||||
(fn []
|
||||
|
@ -418,6 +423,11 @@
|
|||
(fn [_ [_ options]]
|
||||
{:request-permissions-fx options}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-notifications
|
||||
(fn [_ _]
|
||||
{::request-notifications-fx {}}))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:set-swipe-position
|
||||
[re-frame/trim-v]
|
||||
|
|
|
@ -21,6 +21,14 @@
|
|||
{:label "Logout"
|
||||
:trigger [:navigate-to :accounts]}
|
||||
|
||||
; Push notification settings
|
||||
|
||||
{:label "Granted push notifications"
|
||||
:trigger [:request-notifications-granted]}
|
||||
|
||||
{:label "Denied push notifications"
|
||||
:trigger [:request-notifications-denied]}
|
||||
|
||||
;; Tab navigation
|
||||
|
||||
{:label "Tap"
|
||||
|
|
|
@ -16,9 +16,24 @@
|
|||
(fn [db [_ fcm-token]]
|
||||
(assoc-in db [:notifications :fcm-token] fcm-token)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-notifications-granted
|
||||
(fn [_ _]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-notifications-denied
|
||||
(fn [_ _]))
|
||||
|
||||
;; NOTE: Only need to explicitly request permissions on iOS.
|
||||
(defn request-permissions []
|
||||
(.requestPermissions (.-default rn/react-native-fcm)))
|
||||
(-> (.requestPermissions (.-default rn/react-native-fcm))
|
||||
(.then
|
||||
(fn [_]
|
||||
(log/debug "notifications-granted")
|
||||
(dispatch [:request-notifications-granted {}]))
|
||||
(fn [_]
|
||||
(log/debug "notifications-denied")
|
||||
(dispatch [:request-notifications-denied {}])))))
|
||||
|
||||
(defn get-fcm-token []
|
||||
(-> (.getFCMToken (object/get rn/react-native-fcm "default"))
|
||||
|
|
Loading…
Reference in New Issue