Skip to content

Commit b5de732

Browse files
committed
clarify and defend against null tags from onesignal
1 parent 792629c commit b5de732

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

flow-typed/npm/react-native-onesignal_vx.x.x.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ declare module 'react-native-onesignal' {
110110

111111
static sendTag(key: string, value: string): void;
112112
static sendTags(TagsObject): void;
113-
static getTags((TagsObject | Error) => mixed): void;
113+
static getTags((null | TagsObject | Error) => mixed): void;
114114
static deleteTag(key: string): void;
115115

116116
static enableVibrate(enable: boolean): void;

source/redux/parts/notifications.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import OneSignal, {
1414
} from 'react-native-onesignal'
1515
import pify from 'pify'
1616

17-
const getOneSignalTags: () => Promise<TagsObject> = pify(OneSignal.getTags, {
17+
const getOneSignalTags: () => Promise<?TagsObject> = pify(OneSignal.getTags, {
1818
errorFirst: false,
1919
})
2020
const getOneSignalPermissions: () => Promise<SubscriptionState> = pify(
@@ -100,7 +100,10 @@ export function hydrate(): ThunkAction<HydrateChannelsAction> {
100100
getOneSignalTags(),
101101
getOneSignalPermissions(),
102102
])
103-
let channels = new Set(Object.keys(tags))
103+
let channels = new Set()
104+
if (tags) {
105+
channels = new Set(Object.keys(tags))
106+
}
104107
dispatch({type: CHANNELS_HYDRATE, payload: {channels, permissions}})
105108
}
106109
}

0 commit comments

Comments
 (0)