New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

onesignal-expo-plugin

Package Overview
Dependencies
Maintainers
9
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onesignal-expo-plugin - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

build/support/helpers.js

6

build/onesignal/withOneSignal.js

@@ -9,3 +9,9 @@ "use strict";

const withOneSignalIos_1 = require("./withOneSignalIos");
const helpers_1 = require("../support/helpers");
const withOneSignal = (config, props) => {
// if props are undefined, throw error
if (!props) {
throw new Error('You are trying to use the OneSignal plugin without any props. Property "mode" is required. Please see https://github.com/OneSignal/onesignal-expo-plugin for more info.');
}
(0, helpers_1.validatePluginProps)(props);
config = (0, withOneSignalIos_1.withOneSignalIos)(config, props);

@@ -12,0 +18,0 @@ config = (0, withOneSignalAndroid_1.withOneSignalAndroid)(config, props);

@@ -61,2 +61,26 @@ "use strict";

};
const withSmallIconAccentColor = (config, onesignalProps) => {
if (!onesignalProps.smallIconAccentColor) {
return config;
}
return (0, config_plugins_1.withStringsXml)(config, (config) => {
var _a, _b;
const colorInARGB = `FF${(_a = onesignalProps.smallIconAccentColor) === null || _a === void 0 ? void 0 : _a.replace('#', '')}`;
const strings = (_b = config.modResults.resources.string) !== null && _b !== void 0 ? _b : [];
// Check if the accent color entry already exists
const hasAccentColor = strings.some((stringEntry) => {
var _a;
return ((_a = stringEntry.$) === null || _a === void 0 ? void 0 : _a.name) === 'onesignal_notification_accent_color' &&
stringEntry._ === colorInARGB;
});
if (!hasAccentColor) {
const accentColorEntry = {
$: { name: 'onesignal_notification_accent_color' },
_: colorInARGB,
};
config.modResults.resources.string = [...strings, accentColorEntry];
}
return config;
});
};
async function saveIconsArrayAsync(projectRoot, icons, dirsToSize) {

@@ -88,4 +112,5 @@ for (const icon of icons) {

config = withLargeIcons(config, props);
config = withSmallIconAccentColor(config, props);
return config;
};
exports.withOneSignalAndroid = withOneSignalAndroid;

11

build/types/types.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mode = void 0;
exports.Mode = exports.ONESIGNAL_PLUGIN_PROPS = void 0;
exports.ONESIGNAL_PLUGIN_PROPS = [
"mode",
"devTeam",
"iPhoneDeploymentTarget",
"smallIcons",
"largeIcons",
"iosNSEFilePath",
"smallIconAccentColor"
];
var Mode;

@@ -5,0 +14,0 @@ (function (Mode) {

@@ -10,4 +10,14 @@ /**

import { withOneSignalIos } from './withOneSignalIos';
import { validatePluginProps } from '../support/helpers';
const withOneSignal: ConfigPlugin<OneSignalPluginProps> = (config, props) => {
// if props are undefined, throw error
if (!props) {
throw new Error(
'You are trying to use the OneSignal plugin without any props. Property "mode" is required. Please see https://github.com/OneSignal/onesignal-expo-plugin for more info.'
);
}
validatePluginProps(props);
config = withOneSignalIos(config, props);

@@ -14,0 +24,0 @@ config = withOneSignalAndroid(config, props);

@@ -6,3 +6,3 @@ /**

import { ConfigPlugin, withDangerousMod } from '@expo/config-plugins';
import { ConfigPlugin, withDangerousMod, withStringsXml } from '@expo/config-plugins';
import { generateImageAsync } from '@expo/image-utils';

@@ -76,2 +76,31 @@ import { OneSignalLog } from '../support/OneSignalLog';

const withSmallIconAccentColor: ConfigPlugin<OneSignalPluginProps> = (config, onesignalProps) => {
if(!onesignalProps.smallIconAccentColor) {
return config
}
return withStringsXml(config, (config) => {
const colorInARGB = `FF${onesignalProps.smallIconAccentColor?.replace('#', '')}`;
const strings = config.modResults.resources.string ?? [];
// Check if the accent color entry already exists
const hasAccentColor = strings.some(
(stringEntry) =>
stringEntry.$?.name === 'onesignal_notification_accent_color' &&
stringEntry._ === colorInARGB
);
if (!hasAccentColor) {
const accentColorEntry = {
$: { name: 'onesignal_notification_accent_color' },
_: colorInARGB,
};
config.modResults.resources.string = [...strings, accentColorEntry];
}
return config;
});
}
async function saveIconsArrayAsync(projectRoot: string, icons: string[], dirsToSize: { [name: string]: number }) {

@@ -118,3 +147,4 @@ for(const icon of icons) {

config = withLargeIcons(config, props);
config = withSmallIconAccentColor(config, props);
return config;
};

2

package.json
{
"name": "onesignal-expo-plugin",
"version": "2.0.0",
"version": "2.0.1",
"description": "The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.",

@@ -5,0 +5,0 @@ "main": "./app.plugin.js",

@@ -90,6 +90,7 @@ <h1 align="center">Welcome to the onesignal-expo-plugin 👋</h1>

| `largeIcons` | optional | An array of local paths to large notification icons for Android. Image should be white, transparent, and 256x256 in size. e.g: `["./assets/ic_onesignal_large_icon_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#large-notification-icons. |
| `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
| `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/support/serviceExtensionFiles/NotificationService.m), then altered to support any custom logic required. e.g: `"./assets/NotificationService.m"`. |
### OneSignal App ID
Add your OneSignal App ID to your [Expo constants via the `extra` param](https://docs.expo.dev/versions/latest/config/app/):
Add your OneSignal App ID to your [Expo constants via the `extra` param](https://docs.expo.dev/versions/latest/config/app/#extra):

@@ -105,3 +106,3 @@ **Example:**

You can then access the value to pass to the `setAppId` function:
You can then access the value to pass to the `initialize` function:

@@ -111,3 +112,3 @@ ```js

import Constants from "expo-constants";
OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);
OneSignal.initialize(Constants.expoConfig.extra.oneSignalAppId);
```

@@ -118,3 +119,3 @@

```js
OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");
OneSignal.initialize("YOUR-ONESIGNAL-APP-ID");
```

@@ -121,0 +122,0 @@

@@ -11,5 +11,5 @@ /**

/**
* (optional) Used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager e.g: "91SW8A37CR"
* (optional) Used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager e.g: "91SW8A37CR"
*/
devTeam: string;
devTeam?: string;

@@ -20,3 +20,3 @@ /**

*/
iPhoneDeploymentTarget: string;
iPhoneDeploymentTarget?: string;

@@ -30,2 +30,7 @@ /**

/**
* (optional) The accent color to use for notification icons on Android. Must be a valid Android color resource, for example: "#FF0000"
*/
smallIconAccentColor?: string;
/**
* (optional) The large notification icons for Android. Images will be automatically scaled up/down to 256x256.

@@ -43,2 +48,12 @@ */

export const ONESIGNAL_PLUGIN_PROPS: string[] = [
"mode",
"devTeam",
"iPhoneDeploymentTarget",
"smallIcons",
"largeIcons",
"iosNSEFilePath",
"smallIconAccentColor"
];
export enum Mode {

@@ -45,0 +60,0 @@ Dev = "development",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc