New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’

expo-notifications

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-notifications - npm Package Compare versions

Comparing version

to
0.8.1

import { Platform, CodedError, UnavailabilityError } from '@unimodules/core';
import * as Application from 'expo-application';
import Constants from 'expo-constants';
import InstallationIdProvider from './InstallationIdProvider';
import { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';
import ServerRegistrationModule from './ServerRegistrationModule';
import getDevicePushTokenAsync from './getDevicePushTokenAsync';

@@ -20,3 +21,4 @@ const productionBaseUrl = 'https://exp.host/--/api/v2/';

const development = options.development || (await shouldUseDevelopmentNotificationService());
const url = options.url || `${options.baseUrl || productionBaseUrl}push/getExpoPushToken`;
const baseUrl = options.baseUrl ?? productionBaseUrl;
const url = options.url ?? `${baseUrl}push/getExpoPushToken`;
const body = {

@@ -51,2 +53,13 @@ type,

const expoPushToken = getExpoPushToken(await parseResponse(response));
try {
if (options.url || options.baseUrl) {
console.debug(`[expo-notifications] Since the URL endpoint to register in has been customized in the options, expo-notifications won't try to auto-update the device push token on the server.`);
}
else {
await setAutoServerRegistrationEnabledAsync(true);
}
}
catch (e) {
console.warn('[expo-notifications] Could not enable automatically registering new device tokens with the Expo notification service', e);
}
return {

@@ -81,8 +94,9 @@ type: 'expo',

}
// Same as in DevicePushTokenAutoRegistration
async function getDeviceIdAsync() {
try {
if (!InstallationIdProvider.getInstallationIdAsync) {
throw new UnavailabilityError('InstallationIdProvider', 'getInstallationIdAsync');
if (!ServerRegistrationModule.getInstallationIdAsync) {
throw new UnavailabilityError('ExpoServerRegistrationModule', 'getInstallationIdAsync');
}
return await InstallationIdProvider.getInstallationIdAsync();
return await ServerRegistrationModule.getInstallationIdAsync();
}

@@ -99,2 +113,3 @@ catch (e) {

}
// Same as in DevicePushTokenAutoRegistration
async function shouldUseDevelopmentNotificationService() {

@@ -114,2 +129,3 @@ if (Platform.OS === 'ios') {

}
// Same as in DevicePushTokenAutoRegistration
function getTypeOfToken(devicePushToken) {

@@ -116,0 +132,0 @@ switch (devicePushToken.type) {

@@ -26,2 +26,3 @@ export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';

export { default as useLastNotificationResponse } from './useLastNotificationResponse';
export { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';
export * from './TokenEmitter';

@@ -28,0 +29,0 @@ export * from './NotificationsEmitter';

@@ -26,2 +26,3 @@ export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';

export { default as useLastNotificationResponse } from './useLastNotificationResponse';
export { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';
export * from './TokenEmitter';

@@ -28,0 +29,0 @@ export * from './NotificationsEmitter';

@@ -6,2 +6,1 @@ import { Subscription } from '@unimodules/core';

export declare function removePushTokenSubscription(subscription: Subscription): void;
export declare function removeAllPushTokenListeners(): void;

@@ -15,5 +15,2 @@ import { EventEmitter, Platform } from '@unimodules/core';

}
export function removeAllPushTokenListeners() {
tokenEmitter.removeAllListeners(newTokenEventName);
}
//# sourceMappingURL=TokenEmitter.js.map

@@ -11,2 +11,6 @@ # Changelog

## 0.8.1 β€” 2020-11-25
_This version does not introduce any user-facing changes._
## 0.8.0 β€” 2020-11-17

@@ -25,2 +29,5 @@

- Removed `removeAllNotificationListeners` method. You can (and should) still remove listeners using `remove` method on `Subscription` objects returned by `addNotification…Listener`. ([#10883](https://github.com/expo/expo/pull/10883) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed device identifier being used to fetch Expo push token being backed up on Android which resulted in multiple devices having the same `deviceId` (and eventually, Expo push token). ([#11005](https://github.com/expo/expo/pull/11005) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed device identifier used when fetching Expo push token being different than `Constants.installationId` in managed workflow apps which resulted in different Expo push tokens returned for the same experience across old and new Expo API and the device push token not being automatically updated on Expo push servers which lead to Expo push tokens corresponding to outdated Firebase tokens. ([#11005](https://github.com/expo/expo/pull/11005) by [@sjchmiela](https://github.com/sjchmiela))
- Removed `removeAllPushTokenListeners` method. You can (and should) still remove listeners using `remove` method on `Subscription` objects returned by `addPushTokenListener`. ([#11106](https://github.com/expo/expo/pull/11106) by [@sjchmiela](https://github.com/sjchmiela))

@@ -33,2 +40,3 @@ ### πŸŽ‰ New features

- Added support for restoring scheduled notifications alarms on Android after an app is updated. ([#10708](https://github.com/expo/expo/pull/10708) by [@sjchmiela](https://github.com/sjchmiela))
- Added support for auto server reregistration for Expo push tokens (keeping Expo push token always valid) and auto server registration customizations. ([#10908](https://github.com/expo/expo/pull/10908) by [@sjchmiela](https://github.com/sjchmiela))

@@ -135,3 +143,3 @@ ### πŸ› Bug fixes

- > Note that this may or may not be a breaking change for you β€” if you'd expect the notification to be automatically dismissed when tapped on this is a bug fix and a new feature (fixes inconsistency between platforms as on iOS this is the only supported behavior; adds the ability to customize the behavior on Android). If you'd expect the notification to only be dismissed at your will this is a breaking change and you'll need to add `autoDismiss: false` to your notification content inputs.
Changed the default notification behavior on Android to be automatically dismissed when clicked. This is customizable with the `autoDismiss` parameter of `NotificationContentInput`. ([#8241](https://github.com/expo/expo/pull/8241) by [@thorbenprimke](https://github.com/thorbenprimke))
Changed the default notification behavior on Android to be automatically dismissed when clicked. This is customizable with the `autoDismiss` parameter of `NotificationContentInput`. ([#8241](https://github.com/expo/expo/pull/8241) by [@thorbenprimke](https://github.com/thorbenprimke))

@@ -138,0 +146,0 @@ ### πŸŽ‰ New features

{
"name": "expo-notifications",
"version": "0.8.0",
"version": "0.8.1",
"description": "Notifications module",
"main": "build/index.js",
"types": "build/index.d.ts",
"sideEffects": [
"./build/DevicePushTokenAutoRegistration.fx.js"
],
"scripts": {

@@ -43,12 +46,15 @@ "build": "expo-module build",

"dependencies": {
"@ide/backoff": "^1.0.0",
"abort-controller": "^3.0.0",
"badgin": "^1.1.5",
"expo-application": "~2.4.0",
"expo-constants": "9.3.0",
"expo-application": "~2.4.1",
"expo-constants": "9.3.1",
"uuid": "^3.4.0"
},
"devDependencies": {
"@types/node-fetch": "^2.5.7",
"@types/uuid": "^3.4.7",
"expo-module-scripts": "~1.2.0"
},
"gitHead": "bc6b4b3bc3cb5e44e477f145c72c07ed09588651"
"expo-module-scripts": "~1.2.0",
"node-fetch": "^2.6.1"
}
}

@@ -5,3 +5,4 @@ import { Platform, CodedError, UnavailabilityError } from '@unimodules/core';

import InstallationIdProvider from './InstallationIdProvider';
import { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';
import ServerRegistrationModule from './ServerRegistrationModule';
import { DevicePushToken, ExpoPushToken } from './Tokens.types';

@@ -52,3 +53,4 @@ import getDevicePushTokenAsync from './getDevicePushTokenAsync';

const url = options.url || `${options.baseUrl || productionBaseUrl}push/getExpoPushToken`;
const baseUrl = options.baseUrl ?? productionBaseUrl;
const url = options.url ?? `${baseUrl}push/getExpoPushToken`;

@@ -93,2 +95,17 @@ const body = {

try {
if (options.url || options.baseUrl) {
console.debug(
`[expo-notifications] Since the URL endpoint to register in has been customized in the options, expo-notifications won't try to auto-update the device push token on the server.`
);
} else {
await setAutoServerRegistrationEnabledAsync(true);
}
} catch (e) {
console.warn(
'[expo-notifications] Could not enable automatically registering new device tokens with the Expo notification service',
e
);
}
return {

@@ -144,9 +161,10 @@ type: 'expo',

// Same as in DevicePushTokenAutoRegistration
async function getDeviceIdAsync() {
try {
if (!InstallationIdProvider.getInstallationIdAsync) {
throw new UnavailabilityError('InstallationIdProvider', 'getInstallationIdAsync');
if (!ServerRegistrationModule.getInstallationIdAsync) {
throw new UnavailabilityError('ExpoServerRegistrationModule', 'getInstallationIdAsync');
}
return await InstallationIdProvider.getInstallationIdAsync();
return await ServerRegistrationModule.getInstallationIdAsync();
} catch (e) {

@@ -168,2 +186,3 @@ throw new CodedError(

// Same as in DevicePushTokenAutoRegistration
async function shouldUseDevelopmentNotificationService() {

@@ -184,2 +203,3 @@ if (Platform.OS === 'ios') {

// Same as in DevicePushTokenAutoRegistration
function getTypeOfToken(devicePushToken: DevicePushToken) {

@@ -186,0 +206,0 @@ switch (devicePushToken.type) {

@@ -26,2 +26,3 @@ export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';

export { default as useLastNotificationResponse } from './useLastNotificationResponse';
export { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';
export * from './TokenEmitter';

@@ -28,0 +29,0 @@ export * from './NotificationsEmitter';

@@ -22,5 +22,1 @@ import { EventEmitter, Subscription, Platform } from '@unimodules/core';

}
export function removeAllPushTokenListeners() {
tokenEmitter.removeAllListeners(newTokenEventName);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display