expo-quest-notifications
Version:
A fork of [`expo-notifications`](https://github.com/expo/expo/tree/main/packages/expo-notifications) that provides two implementations: - The default `expo-notifications` for Android and iOS platforms. - A Meta Quest-compatible implementation that uses th
29 lines (25 loc) • 759 B
text/typescript
import { BadgeModule } from './BadgeModule.types';
let lastSetBadgeCount = 0;
const badgeModule: BadgeModule = {
addListener: () => {},
removeListeners: () => {},
getBadgeCountAsync: async () => {
return lastSetBadgeCount;
},
setBadgeCountAsync: async (badgeCount, options) => {
// If this module is loaded in SSR (NextJS), we can't modify the badge.
// It also can't load the badgin module, that instantly invokes methods on window.
if (typeof window === 'undefined') {
return false;
}
const badgin = require('badgin');
if (badgeCount > 0) {
badgin.set(badgeCount, options);
} else {
badgin.clear();
}
lastSetBadgeCount = badgeCount;
return true;
},
};
export default badgeModule;