Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("must return PermissionSubscriptionState", () => {
OneSignal.getPermissionSubscriptionState(state => {
// $ExpectError - read only state
state.abc = "123";
(state: PermissionSubscriptionState);
});
});
it('must return PermissionSubscriptionState', () => {
OneSignal.getPermissionSubscriptionState(state => {
// $ExpectError - read only state
state.abc = '123';
(state: PermissionSubscriptionState);
});
});
componentDidMount() {
OneSignal.init(ONESIGNAL_SECRET, {
kOSSettingsKeyAutoPrompt: false,
kOSSettingsKeyInFocusDisplayOption: 0,
});
OneSignal.getPermissionSubscriptionState(status => {
if (!status.hasPrompted && Platform.OS === "ios") {
this.setState({
showNotificationsPrompt: true,
});
return;
}
if (!status.subscriptionEnabled && Platform.OS === "android") {
this.setState({
showNotificationsPrompt: true,
});
return;
}
});
// Triggers a fade in for fancy reasons
return dispatch => {
OneSignal.getPermissionSubscriptionState(permissions => {
dispatch({
type: SET_PERMISSIONS,
payload: {
enabled: permissions.notificationsEnabled,
hasPrompted: permissions.hasPrompted,
},
})
})
OneSignal.getTags(tags => {
if (!tags) {
return
}
if (tags.stack && tags.message) {
// it's an error
});
// Check subscription status
if (await isGrandfatheredIntoFreeSubscription()) {
this.setState({
isGrandfatheredIntoSubscription: true,
});
} else {
const expDate = await latestExpirationDate();
this.setState({
subscriptionExpirationDate: expDate,
});
}
// Check notification status
OneSignal.getPermissionSubscriptionState(status => {
this.setState({
areNotificationsOn: !!status.subscriptionEnabled,
isReady: true,
});
});
};