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,CAAC,CAAC;IAC3D,CAAC;CACF,CAAC","sourcesContent":["import { EventEmitter, EventSubscription } from 'fbemitter';\nimport warning from 'fbjs/lib/warning';\nimport invariant from 'invariant';\nimport { AsyncStorage, DeviceEventEmitter, NativeModules, Platform } from 'react-native';\n\nconst { ExponentNotifications } = NativeModules;\n\ntype Notification = {\n origin: 'selected' | 'received';\n data: any;\n remote: boolean;\n isMultiple: boolean;\n};\n\ntype LocalNotification = {\n title: string;\n // How should we deal with body being required on iOS but not on Android?\n body?: string;\n data?: any;\n ios?: {\n sound?: boolean;\n };\n android?: {\n channelId?: string;\n icon?: string;\n color?: string;\n sticky?: boolean;\n link?: string;\n // DEPRECATED:\n sound?: boolean;\n vibrate?: boolean | number[];\n priority: string;\n };\n};\n\ntype Channel = {\n name: string;\n description?: string;\n priority?: string;\n sound?: boolean;\n vibrate?: boolean | number[];\n badge?: boolean;\n};\n\n// Android assigns unique number to each notification natively.\n// Since that's not supported on iOS, we generate an unique string.\ntype LocalNotificationId = string | number;\n\nlet _emitter;\nlet _initialNotification;\n\nfunction _maybeInitEmitter() {\n if (!_emitter) {\n _emitter = new EventEmitter();\n DeviceEventEmitter.addListener('Exponent.notification', _emitNotification);\n }\n}\n\nfunction _emitNotification(notification) {\n if (typeof notification === 'string') {\n notification = JSON.parse(notification);\n }\n\n /* Don't mutate the original notification */\n notification = { ...notification };\n\n if (typeof notification.data === 'string') {\n try {\n notification.data = JSON.parse(notification.data);\n } catch (e) {\n // It's actually just a string, that's fine\n }\n }\n\n _emitter.emit('notification', notification);\n}\n\nfunction _processNotification(notification) {\n notification = Object.assign({}, notification);\n\n if (!notification.data) {\n notification.data = {};\n }\n\n if (notification.hasOwnProperty('count')) {\n delete notification.count;\n }\n\n // Delete any Android properties on iOS and merge the iOS properties on root notification object\n if (Platform.OS === 'ios') {\n if (notification.android) {\n delete notification.android;\n }\n\n if (notification.ios) {\n notification = Object.assign(notification, notification.ios);\n delete notification.ios;\n }\n }\n\n // Delete any iOS properties on Android and merge the Android properties on root notification\n // object\n if (Platform.OS === 'android') {\n if (notification.ios) {\n delete notification.ios;\n }\n\n if (notification.android) {\n notification = Object.assign(notification, notification.android);\n delete notification.android;\n }\n }\n\n return notification;\n}\n\nfunction _validateNotification(notification) {\n if (Platform.OS === 'ios') {\n invariant(\n !!notification.title && !!notification.body,\n 'Local notifications on iOS require both a title and a body'\n );\n } else if (Platform.OS === 'android') {\n invariant(!!notification.title, 'Local notifications on Android require a title');\n }\n}\n\nlet ASYNC_STORAGE_PREFIX = '__expo_internal_channel_';\n// TODO: remove this before releasing\n// this will always be `true` for SDK 28+\nlet IS_USING_NEW_BINARY = typeof ExponentNotifications.createChannel === 'function';\n\nasync function _legacyReadChannel(id: string): Promise<Channel | null> {\n try {\n let channelString = await AsyncStorage.getItem(`${ASYNC_STORAGE_PREFIX}${id}`);\n if (channelString) {\n return JSON.parse(channelString);\n }\n } catch (e) {}\n return null;\n}\n\nfunction _legacyDeleteChannel(id: string): Promise<void> {\n return AsyncStorage.removeItem(`${ASYNC_STORAGE_PREFIX}${id}`);\n}\n\nif (Platform.OS === 'android') {\n AsyncStorage.clear = async function(callback?: (error?: Error) => void): Promise<void> {\n try {\n let keys = await AsyncStorage.getAllKeys();\n let result = null;\n if (keys && keys.length) {\n let filteredKeys = keys.filter(key => !key.startsWith(ASYNC_STORAGE_PREFIX));\n await AsyncStorage.multiRemove(filteredKeys);\n }\n callback && callback();\n } catch (e) {\n callback && callback(e);\n throw e;\n }\n };\n}\n\n// This codepath will never be triggered in SDK 28 and above\n// TODO: remove before releasing\nfunction _legacySaveChannel(id: string, channel: Channel): Promise<void> {\n return AsyncStorage.setItem(`${ASYNC_STORAGE_PREFIX}${id}`, JSON.stringify(channel));\n}\n\nexport default {\n /* Only used internally to initialize the notification from top level props */\n _setInitialNotification(notification: Notification) {\n _initialNotification = notification;\n },\n\n /* Re-export */\n getExpoPushTokenAsync(): Promise<string> {\n return ExponentNotifications.getExponentPushTokenAsync();\n },\n\n getDevicePushTokenAsync: (config: {\n gcmSenderId?: string;\n }): Promise<{ type: string; data: string }> =>\n ExponentNotifications.getDevicePushTokenAsync(config || {}),\n\n createChannelAndroidAsync(id: string, channel: Channel): Promise<void> {\n if (Platform.OS === 'ios') {\n console.warn('createChannelAndroidAsync(...) has no effect on iOS');\n return Promise.resolve();\n }\n // This codepath will never be triggered in SDK 28 and above\n // TODO: remove before releasing\n if (!IS_USING_NEW_BINARY) {\n return _legacySaveChannel(id, channel);\n }\n return ExponentNotifications.createChannel(id, channel);\n },\n\n deleteChannelAndroidAsync(id: string): Promise<void> {\n if (Platform.OS === 'ios') {\n console.warn('deleteChannelAndroidAsync(...) has no effect on iOS');\n return Promise.resolve();\n }\n // This codepath will never be triggered in SDK 28 and above\n // TODO: remove before releasing\n if (!IS_USING_NEW_BINARY) {\n return Promise.resolve();\n }\n return ExponentNotifications.deleteChannel(id);\n },\n\n /* Shows a notification instantly */\n async presentLocalNotificationAsync(\n notification: LocalNotification\n ): Promise<LocalNotificationId> {\n _validateNotification(notification);\n let nativeNotification = _processNotification(notification);\n\n if (Platform.OS === 'ios') {\n return ExponentNotifications.presentLocalNotification(nativeNotification);\n } else {\n let _channel;\n if (nativeNotification.channelId) {\n _channel = await _legacyReadChannel(nativeNotification.channelId);\n }\n\n if (IS_USING_NEW_BINARY) {\n // delete the legacy channel from AsyncStorage so this codepath isn't triggered anymore\n _legacyDeleteChannel(nativeNotification.channelId);\n return ExponentNotifications.presentLocalNotificationWithChannel(\n nativeNotification,\n _channel\n );\n } else {\n // TODO: remove this codepath before releasing, it will never be triggered on SDK 28+\n // channel does not actually exist, so add its settings to the individual notification\n if (_channel) {\n nativeNotification.sound = _channel.sound;\n nativeNotification.priority = _channel.priority;\n nativeNotification.vibrate = _channel.vibrate;\n }\n return ExponentNotifications.presentLocalNotification(nativeNotification);\n }\n }\n },\n\n /* Schedule a notification at a later date */\n async scheduleLocalNotificationAsync(\n notification: LocalNotification,\n options: {\n time?: Date | number;\n repeat?: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n intervalMs?: number;\n } = {}\n ): Promise<LocalNotificationId> {\n // set now at the beginning of the method, to prevent potential weird warnings when we validate\n // options.time later on\n const now = Date.now();\n\n // Validate and process the notification data\n _validateNotification(notification);\n let nativeNotification = _processNotification(notification);\n\n // Validate `options.time`\n if (options.time) {\n let timeAsDateObj: Date | null = null;\n if (options.time && typeof options.time === 'number') {\n timeAsDateObj = new Date(options.time);\n if (timeAsDateObj.toString() === 'Invalid Date') {\n timeAsDateObj = null;\n }\n } else if (options.time && options.time instanceof Date) {\n timeAsDateObj = options.time;\n }\n\n // If we couldn't convert properly, throw an error\n if (!timeAsDateObj) {\n throw new Error(\n `Provided value for \"time\" is invalid. Please verify that it's either a number representing Unix Epoch time in milliseconds, or a valid date object.`\n );\n }\n\n // If someone passes in a value that is too small, say, by an order of 1000 (it's common to\n // accidently pass seconds instead of ms), display a warning.\n warning(\n timeAsDateObj.getTime() >= now,\n `Provided value for \"time\" is before the current date. Did you possibly pass number of seconds since Unix Epoch instead of number of milliseconds?`\n );\n\n // If iOS, pass time as milliseconds\n if (Platform.OS === 'ios') {\n options = {\n ...options,\n time: timeAsDateObj.getTime(),\n };\n } else {\n options = {\n ...options,\n time: timeAsDateObj,\n };\n }\n }\n\n if (options.intervalMs != null && options.repeat != null) {\n throw new Error(`Pass either the \"repeat\" option or \"intervalMs\" option, not both`);\n }\n\n // Validate options.repeat\n if (options.repeat != null) {\n const validOptions = new Set(['minute', 'hour', 'day', 'week', 'month', 'year']);\n if (!validOptions.has(options.repeat)) {\n throw new Error(\n `Pass one of ['minute', 'hour', 'day', 'week', 'month', 'year'] as the value for the \"repeat\" option`\n );\n }\n }\n\n if (options.intervalMs != null) {\n if (Platform.OS === 'ios') {\n throw new Error(`The \"intervalMs\" option is not supported on iOS`);\n }\n\n if (options.intervalMs <= 0 || !Number.isInteger(options.intervalMs)) {\n throw new Error(\n `Pass an integer greater than zero as the value for the \"intervalMs\" option`\n );\n }\n }\n\n if (Platform.OS === 'ios') {\n return ExponentNotifications.scheduleLocalNotification(nativeNotification, options);\n } else {\n let _channel;\n if (nativeNotification.channelId) {\n _channel = await _legacyReadChannel(nativeNotification.channelId);\n }\n\n if (IS_USING_NEW_BINARY) {\n // delete the legacy channel from AsyncStorage so this codepath isn't triggered anymore\n _legacyDeleteChannel(nativeNotification.channelId);\n return ExponentNotifications.scheduleLocalNotificationWithChannel(\n nativeNotification,\n options,\n _channel\n );\n } else {\n // TODO: remove this codepath before releasing, it will never be triggered on SDK 28+\n // channel does not actually exist, so add its settings to the individual notification\n if (_channel) {\n nativeNotification.sound = _channel.sound;\n nativeNotification.priority = _channel.priority;\n nativeNotification.vibrate = _channel.vibrate;\n }\n return ExponentNotifications.scheduleLocalNotification(nativeNotification, options);\n }\n }\n },\n\n /* Dismiss currently shown notification with ID (Android only) */\n async dismissNotificationAsync(notificationId: LocalNotificationId): Promise<void> {\n if (Platform.OS === 'android') {\n return ExponentNotifications.dismissNotification(notificationId);\n } else {\n throw new Error('Dismissing notifications is not supported on iOS');\n }\n },\n\n /* Dismiss all currently shown notifications (Android only) */\n async dismissAllNotificationsAsync(): Promise<void> {\n if (Platform.OS === 'android') {\n return ExponentNotifications.dismissAllNotifications();\n } else {\n throw new Error('Dismissing notifications is not supported on iOS');\n }\n },\n\n /* Cancel scheduled notification notification with ID */\n cancelScheduledNotificationAsync(notificationId: LocalNotificationId): Promise<void> {\n return ExponentNotifications.cancelScheduledNotification(notificationId);\n },\n\n /* Cancel all scheduled notifications */\n cancelAllScheduledNotificationsAsync(): Promise<void> {\n return ExponentNotifications.cancelAllScheduledNotifications();\n },\n\n /* Primary public api */\n addListener(listener: Function): EventSubscription {\n _maybeInitEmitter();\n\n if (_initialNotification) {\n const initialNotification = _initialNotification;\n _initialNotification = null;\n setTimeout(() => {\n _emitNotification(initialNotification);\n }, 0);\n }\n\n return _emitter.addListener('notification', listener);\n },\n\n async getBadgeNumberAsync(): Promise<number> {\n if (!ExponentNotifications.getBadgeNumberAsync) {\n return 0;\n }\n return ExponentNotifications.getBadgeNumberAsync();\n },\n\n async setBadgeNumberAsync(number: number): Promise<void> {\n if (!ExponentNotifications.setBadgeNumberAsync) {\n return;\n }\n return ExponentNotifications.setBadgeNumberAsync(number);\n },\n};\n"]}
\No newline at end of file