onesignal-expo-plugin 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -19
- package/package.json +5 -6
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,8 +24,8 @@ let path = require("path");
|
|
|
24
24
|
path = __toESM(path);
|
|
25
25
|
let fs = require("fs");
|
|
26
26
|
fs = __toESM(fs);
|
|
27
|
-
let _expo_config_plugins = require("@expo/config-plugins");
|
|
28
27
|
let _expo_image_utils = require("@expo/image-utils");
|
|
28
|
+
let expo_config_plugins_js = require("expo/config-plugins.js");
|
|
29
29
|
let fs_promises = require("fs/promises");
|
|
30
30
|
fs_promises = __toESM(fs_promises);
|
|
31
31
|
//#region src/types/types.ts
|
|
@@ -187,7 +187,7 @@ const SMALL_ICON_DEFAULT_NAME = "ic_stat_onesignal_default";
|
|
|
187
187
|
const withSmallIcons = (config, onesignalProps) => {
|
|
188
188
|
const expoConfig = config;
|
|
189
189
|
if (!onesignalProps.smallIcons && !expoConfig.notification?.icon) return config;
|
|
190
|
-
return (0,
|
|
190
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["android", async (config) => {
|
|
191
191
|
const modConfig = config;
|
|
192
192
|
if (modConfig.notification?.icon) await saveIconAsync(modConfig.notification.icon, config.modRequest.projectRoot, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
193
193
|
if (onesignalProps.smallIcons) await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.smallIcons, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
@@ -197,14 +197,14 @@ const withSmallIcons = (config, onesignalProps) => {
|
|
|
197
197
|
const LARGE_ICON_DEFAULT_NAME = "ic_onesignal_large_icon_default";
|
|
198
198
|
const withLargeIcons = (config, onesignalProps) => {
|
|
199
199
|
if (!onesignalProps.largeIcons) return config;
|
|
200
|
-
return (0,
|
|
200
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["android", async (config) => {
|
|
201
201
|
if (onesignalProps.largeIcons) await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.largeIcons, LARGE_ICON_DIRS_TO_SIZE, LARGE_ICON_DEFAULT_NAME);
|
|
202
202
|
return config;
|
|
203
203
|
}]);
|
|
204
204
|
};
|
|
205
205
|
const withSmallIconAccentColor = (config, onesignalProps) => {
|
|
206
206
|
if (!onesignalProps.smallIconAccentColor) return config;
|
|
207
|
-
return (0,
|
|
207
|
+
return (0, expo_config_plugins_js.withStringsXml)(config, (config) => {
|
|
208
208
|
const colorInARGB = parseColorToARGB(onesignalProps.smallIconAccentColor ?? "");
|
|
209
209
|
const strings = config.modResults.resources.string ?? [];
|
|
210
210
|
const existingIndex = strings.findIndex((stringEntry) => stringEntry.$?.name === "onesignal_notification_accent_color");
|
|
@@ -245,7 +245,7 @@ async function saveIconAsync(icon, projectRoot, dirsToSize, outputName) {
|
|
|
245
245
|
}
|
|
246
246
|
const withSoundFiles$1 = (config, onesignalProps) => {
|
|
247
247
|
if (!onesignalProps.sounds) return config;
|
|
248
|
-
return (0,
|
|
248
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["android", async (config) => {
|
|
249
249
|
const projectRoot = config.modRequest.projectRoot;
|
|
250
250
|
const rawDir = (0, path.resolve)(projectRoot, RESOURCE_ROOT_PATH, "raw");
|
|
251
251
|
if (!(0, fs.existsSync)(rawDir)) (0, fs.mkdirSync)(rawDir, { recursive: true });
|
|
@@ -421,14 +421,14 @@ function resolveLiveActivityDeploymentTarget(props) {
|
|
|
421
421
|
}
|
|
422
422
|
/** Add NSSupportsLiveActivities=true to the main target's Info.plist. */
|
|
423
423
|
const withLiveActivityInfoPlist = (config) => {
|
|
424
|
-
return (0,
|
|
424
|
+
return (0, expo_config_plugins_js.withInfoPlist)(config, (newConfig) => {
|
|
425
425
|
newConfig.modResults.NSSupportsLiveActivities = true;
|
|
426
426
|
return newConfig;
|
|
427
427
|
});
|
|
428
428
|
};
|
|
429
429
|
/** Append a Widget Extension target block to the Podfile (idempotent). */
|
|
430
430
|
const withLiveActivityPodfile = (config, props) => {
|
|
431
|
-
return (0,
|
|
431
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
432
432
|
const targetName = resolveLiveActivityTargetName(props);
|
|
433
433
|
const podfilePath = path.join(config.modRequest.projectRoot, "ios", "Podfile");
|
|
434
434
|
const podfile = await FileManager.readFile(podfilePath);
|
|
@@ -443,7 +443,7 @@ const withLiveActivityPodfile = (config, props) => {
|
|
|
443
443
|
};
|
|
444
444
|
/** Copy widget extension template files (or the user-supplied widget file) into the iOS project. */
|
|
445
445
|
const withLiveActivityFiles = (config, props) => {
|
|
446
|
-
return (0,
|
|
446
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
447
447
|
const targetName = resolveLiveActivityTargetName(props);
|
|
448
448
|
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
449
449
|
const sourceDir = path.join(pluginDir, "../widgetExtensionFiles/");
|
|
@@ -467,7 +467,7 @@ const withLiveActivityFiles = (config, props) => {
|
|
|
467
467
|
};
|
|
468
468
|
/** Register the widget extension target, group, build phases, and build settings in the Xcode project. */
|
|
469
469
|
const withLiveActivityXcodeProject = (config, props) => {
|
|
470
|
-
return (0,
|
|
470
|
+
return (0, expo_config_plugins_js.withXcodeProject)(config, (newConfig) => {
|
|
471
471
|
const xcodeProject = newConfig.modResults;
|
|
472
472
|
const targetName = resolveLiveActivityTargetName(props);
|
|
473
473
|
const widgetBundleId = resolveLiveActivityBundleId(config.ios?.bundleIdentifier ?? "", props);
|
|
@@ -530,7 +530,7 @@ const withOneSignalLiveActivity = (config, props) => {
|
|
|
530
530
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
531
531
|
*/
|
|
532
532
|
const withAppEnvironment = (config, onesignalProps) => {
|
|
533
|
-
return (0,
|
|
533
|
+
return (0, expo_config_plugins_js.withEntitlementsPlist)(config, (newConfig) => {
|
|
534
534
|
if (onesignalProps?.mode == null) throw new Error(`
|
|
535
535
|
Missing required "mode" key in your app.json or app.config.js file for "onesignal-expo-plugin".
|
|
536
536
|
"mode" can be either "development" or "production".
|
|
@@ -545,7 +545,7 @@ const withAppEnvironment = (config, onesignalProps) => {
|
|
|
545
545
|
*/
|
|
546
546
|
const withRemoteNotificationsPermissions = (config) => {
|
|
547
547
|
const BACKGROUND_MODE_KEYS = ["remote-notification"];
|
|
548
|
-
return (0,
|
|
548
|
+
return (0, expo_config_plugins_js.withInfoPlist)(config, (newConfig) => {
|
|
549
549
|
if (!Array.isArray(newConfig.modResults.UIBackgroundModes)) newConfig.modResults.UIBackgroundModes = [];
|
|
550
550
|
for (const key of BACKGROUND_MODE_KEYS) if (!newConfig.modResults.UIBackgroundModes.includes(key)) newConfig.modResults.UIBackgroundModes.push(key);
|
|
551
551
|
return newConfig;
|
|
@@ -557,7 +557,7 @@ const withRemoteNotificationsPermissions = (config) => {
|
|
|
557
557
|
*/
|
|
558
558
|
const withAppGroupPermissions = (config, props) => {
|
|
559
559
|
const APP_GROUP_KEY = "com.apple.security.application-groups";
|
|
560
|
-
return (0,
|
|
560
|
+
return (0, expo_config_plugins_js.withEntitlementsPlist)(config, (newConfig) => {
|
|
561
561
|
if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) newConfig.modResults[APP_GROUP_KEY] = [];
|
|
562
562
|
const modResultsArray = newConfig.modResults[APP_GROUP_KEY];
|
|
563
563
|
const entitlement = getAppGroupIdentifier(newConfig?.ios?.bundleIdentifier || "", props?.appGroupName);
|
|
@@ -571,7 +571,7 @@ const withAppGroupPermissions = (config, props) => {
|
|
|
571
571
|
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
572
572
|
*/
|
|
573
573
|
const withCustomAppGroupsKey = (config, props) => {
|
|
574
|
-
return (0,
|
|
574
|
+
return (0, expo_config_plugins_js.withInfoPlist)(config, (newConfig) => {
|
|
575
575
|
if (props?.appGroupName) newConfig.modResults.OneSignal_app_groups_key = props.appGroupName;
|
|
576
576
|
return newConfig;
|
|
577
577
|
});
|
|
@@ -582,13 +582,13 @@ const withEasManagedCredentials = (config, props) => {
|
|
|
582
582
|
return config;
|
|
583
583
|
};
|
|
584
584
|
const withOneSignalPodfile = (config) => {
|
|
585
|
-
return (0,
|
|
585
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
586
586
|
await updatePodfile(path.join(config.modRequest.projectRoot, "ios"));
|
|
587
587
|
return config;
|
|
588
588
|
}]);
|
|
589
589
|
};
|
|
590
590
|
const withOneSignalNSE = (config, props) => {
|
|
591
|
-
return (0,
|
|
591
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
592
592
|
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
593
593
|
const sourceDir = path.join(pluginDir, "../serviceExtensionFiles/");
|
|
594
594
|
const iosPath = path.join(config.modRequest.projectRoot, "ios");
|
|
@@ -618,7 +618,7 @@ const withOneSignalNSE = (config, props) => {
|
|
|
618
618
|
}]);
|
|
619
619
|
};
|
|
620
620
|
const withOneSignalXcodeProject = (config, props) => {
|
|
621
|
-
return (0,
|
|
621
|
+
return (0, expo_config_plugins_js.withXcodeProject)(config, (newConfig) => {
|
|
622
622
|
const xcodeProject = newConfig.modResults;
|
|
623
623
|
const nseBundleId = `${config.ios?.bundleIdentifier}.${props.nseBundleIdentifier ?? "OneSignalNotificationServiceExtension"}`;
|
|
624
624
|
const devTeam = resolveDevTeam(config, props);
|
|
@@ -661,10 +661,10 @@ const withOneSignalXcodeProject = (config, props) => {
|
|
|
661
661
|
};
|
|
662
662
|
const withSoundFiles = (config, onesignalProps) => {
|
|
663
663
|
if (!onesignalProps.sounds) return config;
|
|
664
|
-
return (0,
|
|
664
|
+
return (0, expo_config_plugins_js.withXcodeProject)(config, (config) => {
|
|
665
665
|
const projectRoot = config.modRequest.projectRoot;
|
|
666
666
|
const projectName = config.modRequest.projectName;
|
|
667
|
-
const sourceRoot =
|
|
667
|
+
const sourceRoot = expo_config_plugins_js.IOSConfig.Paths.getSourceRoot(projectRoot);
|
|
668
668
|
let project = config.modResults;
|
|
669
669
|
for (const soundFile of onesignalProps.sounds) {
|
|
670
670
|
const fileName = path.basename(soundFile);
|
|
@@ -672,7 +672,7 @@ const withSoundFiles = (config, onesignalProps) => {
|
|
|
672
672
|
const destPath = path.resolve(sourceRoot, fileName);
|
|
673
673
|
OneSignalLog.log(`Copying sound file ${soundFile} to iOS project`);
|
|
674
674
|
fs.copyFileSync(sourcePath, destPath);
|
|
675
|
-
if (!project.hasFile(`${projectName}/${fileName}`)) project =
|
|
675
|
+
if (!project.hasFile(`${projectName}/${fileName}`)) project = expo_config_plugins_js.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
676
676
|
filepath: `${projectName}/${fileName}`,
|
|
677
677
|
groupName: projectName,
|
|
678
678
|
project,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "2.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "OneSignal Expo config plugin for adding iOS and Android push notification support to managed Expo apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"EAS",
|
|
7
7
|
"expo",
|
|
@@ -46,15 +46,14 @@
|
|
|
46
46
|
"@expo/image-utils": "^0.8.8"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@expo/config-types": "^55.0.5",
|
|
50
49
|
"@types/node": "^22.19.3",
|
|
51
50
|
"@vitest/coverage-v8": "^4.1.5",
|
|
52
51
|
"typescript": "^6.0.3",
|
|
53
|
-
"vite-plus": "0.1.
|
|
52
|
+
"vite-plus": "0.1.22"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
56
|
-
"
|
|
55
|
+
"expo": ">=53.0.0",
|
|
57
56
|
"react-native-onesignal": ">=5.0.0"
|
|
58
57
|
},
|
|
59
|
-
"packageManager": "bun@1.3.
|
|
58
|
+
"packageManager": "bun@1.3.14"
|
|
60
59
|
}
|