diff --git a/lib/actions/device-actions.js b/lib/actions/device-actions.js --- a/lib/actions/device-actions.js +++ b/lib/actions/device-actions.js @@ -10,7 +10,7 @@ }); const setDeviceToken = ( fetchJSON: FetchJSON, -): ((deviceToken: string) => Promise) => async deviceToken => { +): ((deviceToken: ?string) => Promise) => async deviceToken => { await fetchJSON('update_device_token', { deviceToken, platformDetails: getConfig().platformDetails, diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -554,7 +554,7 @@ } | { +type: 'SET_DEVICE_TOKEN_SUCCESS', - +payload: string, + +payload: ?string, +loadingInfo: LoadingInfo, } | { diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js --- a/native/push/push-handler.react.js +++ b/native/push/push-handler.react.js @@ -91,7 +91,7 @@ +dispatch: Dispatch, +dispatchActionPromise: DispatchActionPromise, // async functions that hit server APIs - +setDeviceToken: (deviceToken: string) => Promise, + +setDeviceToken: (deviceToken: ?string) => Promise, // withRootContext +rootContext: ?RootContextType, }; @@ -344,7 +344,7 @@ } } - handleAndroidDeviceToken = async (deviceToken: string) => { + handleAndroidDeviceToken = async (deviceToken: ?string) => { this.registerPushPermissions(deviceToken); await this.handleInitialAndroidNotification(); }; @@ -362,7 +362,7 @@ } } - registerPushPermissions = (deviceToken: string) => { + registerPushPermissions = (deviceToken: ?string) => { const deviceType = Platform.OS; if (deviceType !== 'android' && deviceType !== 'ios') { return; @@ -375,7 +375,7 @@ } }; - setDeviceToken(deviceToken: string) { + setDeviceToken(deviceToken: ?string) { this.props.dispatchActionPromise( setDeviceTokenActionTypes, this.props.setDeviceToken(deviceToken), @@ -383,6 +383,7 @@ } failedToRegisterPushPermissions = () => { + this.setDeviceToken(null); if (!this.props.loggedIn) { return; } diff --git a/server/src/responders/device-responders.js b/server/src/responders/device-responders.js --- a/server/src/responders/device-responders.js +++ b/server/src/responders/device-responders.js @@ -11,7 +11,7 @@ import { validateInput } from '../utils/validation-utils'; const deviceTokenUpdateRequestInputValidator: TInterface = tShape({ - deviceToken: t.String, + deviceToken: t.maybe(t.String), deviceType: t.maybe(t.enums.of(['ios', 'android'])), platformDetails: t.maybe(tPlatformDetails), });