onesignal-expo-plugin 2.5.0 → 2.6.0
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/README.md +7 -8
- package/dist/index.d.ts +2 -96
- package/dist/index.js +41 -42
- package/dist/plugin.d.ts +8 -0
- package/dist/plugin.js +7 -0
- package/dist/types-BKWSKFuI.d.ts +96 -0
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -58,19 +58,18 @@ Add the plugin to the **front** of the [plugin array](https://docs.expo.dev/vers
|
|
|
58
58
|
|
|
59
59
|
or
|
|
60
60
|
|
|
61
|
-
**app.config.js**
|
|
61
|
+
**app.config.js/ts**
|
|
62
62
|
|
|
63
63
|
```js
|
|
64
|
+
import withOneSignal from 'onesignal-expo-plugin/plugin';
|
|
65
|
+
|
|
64
66
|
export default {
|
|
65
67
|
...
|
|
66
68
|
plugins: [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
]
|
|
69
|
+
withOneSignal({
|
|
70
|
+
mode: 'development',
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
74
73
|
};
|
|
75
74
|
```
|
|
76
75
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,100 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-BKWSKFuI.js";
|
|
2
|
+
import { ConfigPlugin } from "expo/config-plugins.js";
|
|
2
3
|
|
|
3
|
-
//#region src/types/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the iOS Widget Extension target that hosts Live Activities.
|
|
6
|
-
*/
|
|
7
|
-
type OneSignalLiveActivityProps = {
|
|
8
|
-
/**
|
|
9
|
-
* (optional) Custom widget extension target name. Defaults to "OneSignalWidget".
|
|
10
|
-
* The full bundle identifier becomes "{ios.bundleIdentifier}.{bundleIdentifierSuffix ?? targetName}".
|
|
11
|
-
*/
|
|
12
|
-
targetName?: string;
|
|
13
|
-
/**
|
|
14
|
-
* (optional) Suffix appended to ios.bundleIdentifier for the widget extension. Defaults to targetName.
|
|
15
|
-
*/
|
|
16
|
-
bundleIdentifierSuffix?: string;
|
|
17
|
-
/**
|
|
18
|
-
* (optional) Local path to a custom Live Activity widget Swift file. If omitted, ships a default
|
|
19
|
-
* widget built on `DefaultLiveActivityAttributes` so it works with `OneSignal.LiveActivities.setupDefault()`.
|
|
20
|
-
*/
|
|
21
|
-
widgetFilePath?: string;
|
|
22
|
-
/**
|
|
23
|
-
* (optional) IPHONEOS_DEPLOYMENT_TARGET for the widget extension. Defaults to "16.2" (ActivityKit minimum).
|
|
24
|
-
* Values below 16.2 are clamped with a warning. Independent of the NSE's `iPhoneDeploymentTarget` prop.
|
|
25
|
-
*/
|
|
26
|
-
deploymentTarget?: string;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* OneSignalPluginProps refer to the properties set by the user in their app config file (e.g: app.json)
|
|
30
|
-
*/
|
|
31
|
-
type OneSignalPluginProps = {
|
|
32
|
-
/**
|
|
33
|
-
* (required) Used to configure APNs environment entitlement. "development" or "production"
|
|
34
|
-
*/
|
|
35
|
-
mode: 'development' | 'production';
|
|
36
|
-
/**
|
|
37
|
-
* (optional) Used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager e.g: "91SW8A37CR"
|
|
38
|
-
* @deprecated Use `ios.appleTeamId` in your Expo config instead. This prop will be removed in a future major release.
|
|
39
|
-
*/
|
|
40
|
-
devTeam?: string;
|
|
41
|
-
/**
|
|
42
|
-
* (optional) Target IPHONEOS_DEPLOYMENT_TARGET value to be used when adding the iOS NSE. A deployment target is nothing more than
|
|
43
|
-
* the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: "12.0".
|
|
44
|
-
*/
|
|
45
|
-
iPhoneDeploymentTarget?: string;
|
|
46
|
-
/**
|
|
47
|
-
* (optional) The small notification icons for Android. Images will be automatically scaled up/down, the recommended size
|
|
48
|
-
* is 96x96 to always scale down.
|
|
49
|
-
*/
|
|
50
|
-
smallIcons?: string[];
|
|
51
|
-
/**
|
|
52
|
-
* (optional) The accent color to use for notification icons on Android. Must be a valid Android color resource, for example: "#FF0000"
|
|
53
|
-
*/
|
|
54
|
-
smallIconAccentColor?: string;
|
|
55
|
-
/**
|
|
56
|
-
* (optional) The large notification icons for Android. Images will be automatically scaled up/down to 256x256.
|
|
57
|
-
*/
|
|
58
|
-
largeIcons?: string[];
|
|
59
|
-
/**
|
|
60
|
-
* (optional) Local path to a custom Notification Service Extension (NSE) source file.
|
|
61
|
-
* Both Swift (`.swift`) and Objective-C (`.m`) are supported. For `.m`, an optional sibling
|
|
62
|
-
* `NotificationService.h` will be picked up if present; otherwise the plugin's default header
|
|
63
|
-
* is used. Typically a copy of `serviceExtensionFiles/NotificationService.swift` or
|
|
64
|
-
* `NotificationService.m`, altered to support custom logic.
|
|
65
|
-
*/
|
|
66
|
-
iosNSEFilePath?: string;
|
|
67
|
-
/**
|
|
68
|
-
* (optional) Used to configure a custom iOS app group name. If not provided, defaults to "group.{ios.bundleIdentifier}.onesignal".
|
|
69
|
-
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
70
|
-
*/
|
|
71
|
-
appGroupName?: string;
|
|
72
|
-
/**
|
|
73
|
-
* (optional) Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension.
|
|
74
|
-
* The full bundle identifier will be "{ios.bundleIdentifier}.{nseBundleIdentifier}".
|
|
75
|
-
* If not provided, defaults to "OneSignalNotificationServiceExtension".
|
|
76
|
-
*/
|
|
77
|
-
nseBundleIdentifier?: string;
|
|
78
|
-
/**
|
|
79
|
-
* (optional) If true, the iOS Notification Service Extension (NSE) will not be added to the project.
|
|
80
|
-
* The NSE is required for badges, confirmed delivery, media attachments, and action buttons.
|
|
81
|
-
* Only disable if you only need basic push notifications.
|
|
82
|
-
*/
|
|
83
|
-
disableNSE?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* (optional) An array of local paths to custom notification sound files (.wav only).
|
|
86
|
-
* Files are added to the iOS app bundle and Android res/raw/.
|
|
87
|
-
* @see https://documentation.onesignal.com/docs/customize-notification-sounds
|
|
88
|
-
*/
|
|
89
|
-
sounds?: string[];
|
|
90
|
-
/**
|
|
91
|
-
* (optional) Opt in to scaffolding an iOS Widget Extension target for Live Activities.
|
|
92
|
-
* Presence of this prop enables Live Activity setup. Requires iOS 16.1+ and a .p8 APNs key.
|
|
93
|
-
* @see https://documentation.onesignal.com/docs/cross-platform-live-activity-setup
|
|
94
|
-
*/
|
|
95
|
-
liveActivities?: OneSignalLiveActivityProps;
|
|
96
|
-
};
|
|
97
|
-
//#endregion
|
|
98
4
|
//#region src/onesignal/withOneSignal.d.ts
|
|
99
5
|
declare const withOneSignal: ConfigPlugin<OneSignalPluginProps>;
|
|
100
6
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -24,25 +24,10 @@ 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
|
-
//#region src/types/types.ts
|
|
32
|
-
const ONESIGNAL_PLUGIN_PROPS = [
|
|
33
|
-
"mode",
|
|
34
|
-
"devTeam",
|
|
35
|
-
"iPhoneDeploymentTarget",
|
|
36
|
-
"smallIcons",
|
|
37
|
-
"largeIcons",
|
|
38
|
-
"iosNSEFilePath",
|
|
39
|
-
"smallIconAccentColor",
|
|
40
|
-
"appGroupName",
|
|
41
|
-
"nseBundleIdentifier",
|
|
42
|
-
"disableNSE",
|
|
43
|
-
"sounds",
|
|
44
|
-
"liveActivities"
|
|
45
|
-
];
|
|
46
31
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
47
32
|
const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
48
33
|
const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
@@ -83,6 +68,26 @@ var OneSignalLog = class {
|
|
|
83
68
|
//#region src/support/helpers.ts
|
|
84
69
|
const HEX_COLOR_6_REGEX = /^#?[0-9A-Fa-f]{6}$/;
|
|
85
70
|
const HEX_COLOR_8_REGEX = /^#?[0-9A-Fa-f]{8}$/;
|
|
71
|
+
const ONESIGNAL_PLUGIN_PROPS = [
|
|
72
|
+
"mode",
|
|
73
|
+
"devTeam",
|
|
74
|
+
"iPhoneDeploymentTarget",
|
|
75
|
+
"smallIcons",
|
|
76
|
+
"largeIcons",
|
|
77
|
+
"iosNSEFilePath",
|
|
78
|
+
"smallIconAccentColor",
|
|
79
|
+
"appGroupName",
|
|
80
|
+
"nseBundleIdentifier",
|
|
81
|
+
"disableNSE",
|
|
82
|
+
"sounds",
|
|
83
|
+
"liveActivities"
|
|
84
|
+
];
|
|
85
|
+
const LIVE_ACTIVITY_PROPS = [
|
|
86
|
+
"targetName",
|
|
87
|
+
"bundleIdentifierSuffix",
|
|
88
|
+
"widgetFilePath",
|
|
89
|
+
"deploymentTarget"
|
|
90
|
+
];
|
|
86
91
|
/**
|
|
87
92
|
* Converts a hex color string (#RGB, #RRGGBB, or #AARRGGBB) to an
|
|
88
93
|
* 8-character ARGB hex string (no '#') expected by the OneSignal Android SDK.
|
|
@@ -118,19 +123,13 @@ function validatePluginProps(props) {
|
|
|
118
123
|
if (props.liveActivities !== void 0) {
|
|
119
124
|
if (props.liveActivities === null || Array.isArray(props.liveActivities) || typeof props.liveActivities !== "object") throw new Error("OneSignal Expo Plugin: 'liveActivities' must be an object.");
|
|
120
125
|
const liveActivities = props.liveActivities;
|
|
121
|
-
const liveActivityProps = [
|
|
122
|
-
"targetName",
|
|
123
|
-
"bundleIdentifierSuffix",
|
|
124
|
-
"widgetFilePath",
|
|
125
|
-
"deploymentTarget"
|
|
126
|
-
];
|
|
127
126
|
for (const prop of Object.keys(liveActivities)) {
|
|
128
|
-
if (!
|
|
127
|
+
if (!LIVE_ACTIVITY_PROPS.some((allowedProp) => allowedProp === prop)) throw new Error(`OneSignal Expo Plugin: You have provided an invalid property "${prop}" to 'liveActivities'.`);
|
|
129
128
|
if (typeof liveActivities[prop] !== "string") throw new Error(`OneSignal Expo Plugin: 'liveActivities.${prop}' must be a string.`);
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
const inputProps = Object.keys(props);
|
|
133
|
-
for (const prop of inputProps) if (!ONESIGNAL_PLUGIN_PROPS.
|
|
132
|
+
for (const prop of inputProps) if (!ONESIGNAL_PLUGIN_PROPS.some((allowedProp) => allowedProp === prop)) throw new Error(`OneSignal Expo Plugin: You have provided an invalid property "${prop}" to the OneSignal plugin.`);
|
|
134
133
|
}
|
|
135
134
|
/**
|
|
136
135
|
* Detect whether the customer's NSE is Swift or Objective-C from `iosNSEFilePath`.
|
|
@@ -187,7 +186,7 @@ const SMALL_ICON_DEFAULT_NAME = "ic_stat_onesignal_default";
|
|
|
187
186
|
const withSmallIcons = (config, onesignalProps) => {
|
|
188
187
|
const expoConfig = config;
|
|
189
188
|
if (!onesignalProps.smallIcons && !expoConfig.notification?.icon) return config;
|
|
190
|
-
return (0,
|
|
189
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["android", async (config) => {
|
|
191
190
|
const modConfig = config;
|
|
192
191
|
if (modConfig.notification?.icon) await saveIconAsync(modConfig.notification.icon, config.modRequest.projectRoot, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
193
192
|
if (onesignalProps.smallIcons) await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.smallIcons, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
@@ -197,14 +196,14 @@ const withSmallIcons = (config, onesignalProps) => {
|
|
|
197
196
|
const LARGE_ICON_DEFAULT_NAME = "ic_onesignal_large_icon_default";
|
|
198
197
|
const withLargeIcons = (config, onesignalProps) => {
|
|
199
198
|
if (!onesignalProps.largeIcons) return config;
|
|
200
|
-
return (0,
|
|
199
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["android", async (config) => {
|
|
201
200
|
if (onesignalProps.largeIcons) await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.largeIcons, LARGE_ICON_DIRS_TO_SIZE, LARGE_ICON_DEFAULT_NAME);
|
|
202
201
|
return config;
|
|
203
202
|
}]);
|
|
204
203
|
};
|
|
205
204
|
const withSmallIconAccentColor = (config, onesignalProps) => {
|
|
206
205
|
if (!onesignalProps.smallIconAccentColor) return config;
|
|
207
|
-
return (0,
|
|
206
|
+
return (0, expo_config_plugins_js.withStringsXml)(config, (config) => {
|
|
208
207
|
const colorInARGB = parseColorToARGB(onesignalProps.smallIconAccentColor ?? "");
|
|
209
208
|
const strings = config.modResults.resources.string ?? [];
|
|
210
209
|
const existingIndex = strings.findIndex((stringEntry) => stringEntry.$?.name === "onesignal_notification_accent_color");
|
|
@@ -245,7 +244,7 @@ async function saveIconAsync(icon, projectRoot, dirsToSize, outputName) {
|
|
|
245
244
|
}
|
|
246
245
|
const withSoundFiles$1 = (config, onesignalProps) => {
|
|
247
246
|
if (!onesignalProps.sounds) return config;
|
|
248
|
-
return (0,
|
|
247
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["android", async (config) => {
|
|
249
248
|
const projectRoot = config.modRequest.projectRoot;
|
|
250
249
|
const rawDir = (0, path.resolve)(projectRoot, RESOURCE_ROOT_PATH, "raw");
|
|
251
250
|
if (!(0, fs.existsSync)(rawDir)) (0, fs.mkdirSync)(rawDir, { recursive: true });
|
|
@@ -421,14 +420,14 @@ function resolveLiveActivityDeploymentTarget(props) {
|
|
|
421
420
|
}
|
|
422
421
|
/** Add NSSupportsLiveActivities=true to the main target's Info.plist. */
|
|
423
422
|
const withLiveActivityInfoPlist = (config) => {
|
|
424
|
-
return (0,
|
|
423
|
+
return (0, expo_config_plugins_js.withInfoPlist)(config, (newConfig) => {
|
|
425
424
|
newConfig.modResults.NSSupportsLiveActivities = true;
|
|
426
425
|
return newConfig;
|
|
427
426
|
});
|
|
428
427
|
};
|
|
429
428
|
/** Append a Widget Extension target block to the Podfile (idempotent). */
|
|
430
429
|
const withLiveActivityPodfile = (config, props) => {
|
|
431
|
-
return (0,
|
|
430
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
432
431
|
const targetName = resolveLiveActivityTargetName(props);
|
|
433
432
|
const podfilePath = path.join(config.modRequest.projectRoot, "ios", "Podfile");
|
|
434
433
|
const podfile = await FileManager.readFile(podfilePath);
|
|
@@ -443,7 +442,7 @@ const withLiveActivityPodfile = (config, props) => {
|
|
|
443
442
|
};
|
|
444
443
|
/** Copy widget extension template files (or the user-supplied widget file) into the iOS project. */
|
|
445
444
|
const withLiveActivityFiles = (config, props) => {
|
|
446
|
-
return (0,
|
|
445
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
447
446
|
const targetName = resolveLiveActivityTargetName(props);
|
|
448
447
|
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
449
448
|
const sourceDir = path.join(pluginDir, "../widgetExtensionFiles/");
|
|
@@ -467,7 +466,7 @@ const withLiveActivityFiles = (config, props) => {
|
|
|
467
466
|
};
|
|
468
467
|
/** Register the widget extension target, group, build phases, and build settings in the Xcode project. */
|
|
469
468
|
const withLiveActivityXcodeProject = (config, props) => {
|
|
470
|
-
return (0,
|
|
469
|
+
return (0, expo_config_plugins_js.withXcodeProject)(config, (newConfig) => {
|
|
471
470
|
const xcodeProject = newConfig.modResults;
|
|
472
471
|
const targetName = resolveLiveActivityTargetName(props);
|
|
473
472
|
const widgetBundleId = resolveLiveActivityBundleId(config.ios?.bundleIdentifier ?? "", props);
|
|
@@ -530,7 +529,7 @@ const withOneSignalLiveActivity = (config, props) => {
|
|
|
530
529
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
531
530
|
*/
|
|
532
531
|
const withAppEnvironment = (config, onesignalProps) => {
|
|
533
|
-
return (0,
|
|
532
|
+
return (0, expo_config_plugins_js.withEntitlementsPlist)(config, (newConfig) => {
|
|
534
533
|
if (onesignalProps?.mode == null) throw new Error(`
|
|
535
534
|
Missing required "mode" key in your app.json or app.config.js file for "onesignal-expo-plugin".
|
|
536
535
|
"mode" can be either "development" or "production".
|
|
@@ -545,7 +544,7 @@ const withAppEnvironment = (config, onesignalProps) => {
|
|
|
545
544
|
*/
|
|
546
545
|
const withRemoteNotificationsPermissions = (config) => {
|
|
547
546
|
const BACKGROUND_MODE_KEYS = ["remote-notification"];
|
|
548
|
-
return (0,
|
|
547
|
+
return (0, expo_config_plugins_js.withInfoPlist)(config, (newConfig) => {
|
|
549
548
|
if (!Array.isArray(newConfig.modResults.UIBackgroundModes)) newConfig.modResults.UIBackgroundModes = [];
|
|
550
549
|
for (const key of BACKGROUND_MODE_KEYS) if (!newConfig.modResults.UIBackgroundModes.includes(key)) newConfig.modResults.UIBackgroundModes.push(key);
|
|
551
550
|
return newConfig;
|
|
@@ -557,7 +556,7 @@ const withRemoteNotificationsPermissions = (config) => {
|
|
|
557
556
|
*/
|
|
558
557
|
const withAppGroupPermissions = (config, props) => {
|
|
559
558
|
const APP_GROUP_KEY = "com.apple.security.application-groups";
|
|
560
|
-
return (0,
|
|
559
|
+
return (0, expo_config_plugins_js.withEntitlementsPlist)(config, (newConfig) => {
|
|
561
560
|
if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) newConfig.modResults[APP_GROUP_KEY] = [];
|
|
562
561
|
const modResultsArray = newConfig.modResults[APP_GROUP_KEY];
|
|
563
562
|
const entitlement = getAppGroupIdentifier(newConfig?.ios?.bundleIdentifier || "", props?.appGroupName);
|
|
@@ -571,7 +570,7 @@ const withAppGroupPermissions = (config, props) => {
|
|
|
571
570
|
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
572
571
|
*/
|
|
573
572
|
const withCustomAppGroupsKey = (config, props) => {
|
|
574
|
-
return (0,
|
|
573
|
+
return (0, expo_config_plugins_js.withInfoPlist)(config, (newConfig) => {
|
|
575
574
|
if (props?.appGroupName) newConfig.modResults.OneSignal_app_groups_key = props.appGroupName;
|
|
576
575
|
return newConfig;
|
|
577
576
|
});
|
|
@@ -582,13 +581,13 @@ const withEasManagedCredentials = (config, props) => {
|
|
|
582
581
|
return config;
|
|
583
582
|
};
|
|
584
583
|
const withOneSignalPodfile = (config) => {
|
|
585
|
-
return (0,
|
|
584
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
586
585
|
await updatePodfile(path.join(config.modRequest.projectRoot, "ios"));
|
|
587
586
|
return config;
|
|
588
587
|
}]);
|
|
589
588
|
};
|
|
590
589
|
const withOneSignalNSE = (config, props) => {
|
|
591
|
-
return (0,
|
|
590
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
592
591
|
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
593
592
|
const sourceDir = path.join(pluginDir, "../serviceExtensionFiles/");
|
|
594
593
|
const iosPath = path.join(config.modRequest.projectRoot, "ios");
|
|
@@ -618,7 +617,7 @@ const withOneSignalNSE = (config, props) => {
|
|
|
618
617
|
}]);
|
|
619
618
|
};
|
|
620
619
|
const withOneSignalXcodeProject = (config, props) => {
|
|
621
|
-
return (0,
|
|
620
|
+
return (0, expo_config_plugins_js.withXcodeProject)(config, (newConfig) => {
|
|
622
621
|
const xcodeProject = newConfig.modResults;
|
|
623
622
|
const nseBundleId = `${config.ios?.bundleIdentifier}.${props.nseBundleIdentifier ?? "OneSignalNotificationServiceExtension"}`;
|
|
624
623
|
const devTeam = resolveDevTeam(config, props);
|
|
@@ -661,10 +660,10 @@ const withOneSignalXcodeProject = (config, props) => {
|
|
|
661
660
|
};
|
|
662
661
|
const withSoundFiles = (config, onesignalProps) => {
|
|
663
662
|
if (!onesignalProps.sounds) return config;
|
|
664
|
-
return (0,
|
|
663
|
+
return (0, expo_config_plugins_js.withXcodeProject)(config, (config) => {
|
|
665
664
|
const projectRoot = config.modRequest.projectRoot;
|
|
666
665
|
const projectName = config.modRequest.projectName;
|
|
667
|
-
const sourceRoot =
|
|
666
|
+
const sourceRoot = expo_config_plugins_js.IOSConfig.Paths.getSourceRoot(projectRoot);
|
|
668
667
|
let project = config.modResults;
|
|
669
668
|
for (const soundFile of onesignalProps.sounds) {
|
|
670
669
|
const fileName = path.basename(soundFile);
|
|
@@ -672,7 +671,7 @@ const withSoundFiles = (config, onesignalProps) => {
|
|
|
672
671
|
const destPath = path.resolve(sourceRoot, fileName);
|
|
673
672
|
OneSignalLog.log(`Copying sound file ${soundFile} to iOS project`);
|
|
674
673
|
fs.copyFileSync(sourcePath, destPath);
|
|
675
|
-
if (!project.hasFile(`${projectName}/${fileName}`)) project =
|
|
674
|
+
if (!project.hasFile(`${projectName}/${fileName}`)) project = expo_config_plugins_js.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
676
675
|
filepath: `${projectName}/${fileName}`,
|
|
677
676
|
groupName: projectName,
|
|
678
677
|
project,
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-BKWSKFuI.js";
|
|
2
|
+
|
|
3
|
+
//#region package.json.d.ts
|
|
4
|
+
declare let name: string;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/onesignal/plugin.d.ts
|
|
7
|
+
declare const withOneSignal: (props: OneSignalPluginProps) => [typeof name, OneSignalPluginProps];
|
|
8
|
+
export = withOneSignal;
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the iOS Widget Extension target that hosts Live Activities.
|
|
4
|
+
*/
|
|
5
|
+
type OneSignalLiveActivityProps = {
|
|
6
|
+
/**
|
|
7
|
+
* (optional) Custom widget extension target name. Defaults to "OneSignalWidget".
|
|
8
|
+
* The full bundle identifier becomes "{ios.bundleIdentifier}.{bundleIdentifierSuffix ?? targetName}".
|
|
9
|
+
*/
|
|
10
|
+
targetName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* (optional) Suffix appended to ios.bundleIdentifier for the widget extension. Defaults to targetName.
|
|
13
|
+
*/
|
|
14
|
+
bundleIdentifierSuffix?: string;
|
|
15
|
+
/**
|
|
16
|
+
* (optional) Local path to a custom Live Activity widget Swift file. If omitted, ships a default
|
|
17
|
+
* widget built on `DefaultLiveActivityAttributes` so it works with `OneSignal.LiveActivities.setupDefault()`.
|
|
18
|
+
*/
|
|
19
|
+
widgetFilePath?: string;
|
|
20
|
+
/**
|
|
21
|
+
* (optional) IPHONEOS_DEPLOYMENT_TARGET for the widget extension. Defaults to "16.2" (ActivityKit minimum).
|
|
22
|
+
* Values below 16.2 are clamped with a warning. Independent of the NSE's `iPhoneDeploymentTarget` prop.
|
|
23
|
+
*/
|
|
24
|
+
deploymentTarget?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* OneSignalPluginProps refer to the properties set by the user in their app config file (e.g: app.json)
|
|
28
|
+
*/
|
|
29
|
+
type OneSignalPluginProps = {
|
|
30
|
+
/**
|
|
31
|
+
* (required) Used to configure APNs environment entitlement. "development" or "production"
|
|
32
|
+
*/
|
|
33
|
+
mode: 'development' | 'production';
|
|
34
|
+
/**
|
|
35
|
+
* (optional) Used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager e.g: "91SW8A37CR"
|
|
36
|
+
* @deprecated Use `ios.appleTeamId` in your Expo config instead. This prop will be removed in a future major release.
|
|
37
|
+
*/
|
|
38
|
+
devTeam?: string;
|
|
39
|
+
/**
|
|
40
|
+
* (optional) Target IPHONEOS_DEPLOYMENT_TARGET value to be used when adding the iOS NSE. A deployment target is nothing more than
|
|
41
|
+
* the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: "12.0".
|
|
42
|
+
*/
|
|
43
|
+
iPhoneDeploymentTarget?: string;
|
|
44
|
+
/**
|
|
45
|
+
* (optional) The small notification icons for Android. Images will be automatically scaled up/down, the recommended size
|
|
46
|
+
* is 96x96 to always scale down.
|
|
47
|
+
*/
|
|
48
|
+
smallIcons?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* (optional) The accent color to use for notification icons on Android. Must be a valid Android color resource, for example: "#FF0000"
|
|
51
|
+
*/
|
|
52
|
+
smallIconAccentColor?: string;
|
|
53
|
+
/**
|
|
54
|
+
* (optional) The large notification icons for Android. Images will be automatically scaled up/down to 256x256.
|
|
55
|
+
*/
|
|
56
|
+
largeIcons?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* (optional) Local path to a custom Notification Service Extension (NSE) source file.
|
|
59
|
+
* Both Swift (`.swift`) and Objective-C (`.m`) are supported. For `.m`, an optional sibling
|
|
60
|
+
* `NotificationService.h` will be picked up if present; otherwise the plugin's default header
|
|
61
|
+
* is used. Typically a copy of `serviceExtensionFiles/NotificationService.swift` or
|
|
62
|
+
* `NotificationService.m`, altered to support custom logic.
|
|
63
|
+
*/
|
|
64
|
+
iosNSEFilePath?: string;
|
|
65
|
+
/**
|
|
66
|
+
* (optional) Used to configure a custom iOS app group name. If not provided, defaults to "group.{ios.bundleIdentifier}.onesignal".
|
|
67
|
+
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
68
|
+
*/
|
|
69
|
+
appGroupName?: string;
|
|
70
|
+
/**
|
|
71
|
+
* (optional) Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension.
|
|
72
|
+
* The full bundle identifier will be "{ios.bundleIdentifier}.{nseBundleIdentifier}".
|
|
73
|
+
* If not provided, defaults to "OneSignalNotificationServiceExtension".
|
|
74
|
+
*/
|
|
75
|
+
nseBundleIdentifier?: string;
|
|
76
|
+
/**
|
|
77
|
+
* (optional) If true, the iOS Notification Service Extension (NSE) will not be added to the project.
|
|
78
|
+
* The NSE is required for badges, confirmed delivery, media attachments, and action buttons.
|
|
79
|
+
* Only disable if you only need basic push notifications.
|
|
80
|
+
*/
|
|
81
|
+
disableNSE?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* (optional) An array of local paths to custom notification sound files (.wav only).
|
|
84
|
+
* Files are added to the iOS app bundle and Android res/raw/.
|
|
85
|
+
* @see https://documentation.onesignal.com/docs/customize-notification-sounds
|
|
86
|
+
*/
|
|
87
|
+
sounds?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* (optional) Opt in to scaffolding an iOS Widget Extension target for Live Activities.
|
|
90
|
+
* Presence of this prop enables Live Activity setup. Requires iOS 16.1+ and a .p8 APNs key.
|
|
91
|
+
* @see https://documentation.onesignal.com/docs/cross-platform-live-activity-setup
|
|
92
|
+
*/
|
|
93
|
+
liveActivities?: OneSignalLiveActivityProps;
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { OneSignalPluginProps as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.6.0",
|
|
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",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
31
|
"default": "./dist/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./plugin": {
|
|
34
|
+
"types": "./dist/plugin.d.ts",
|
|
35
|
+
"default": "./dist/plugin.js"
|
|
36
|
+
},
|
|
33
37
|
"./package.json": "./package.json"
|
|
34
38
|
},
|
|
35
39
|
"scripts": {
|
|
@@ -46,15 +50,14 @@
|
|
|
46
50
|
"@expo/image-utils": "^0.8.8"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
|
-
"@expo/config-types": "^55.0.5",
|
|
50
53
|
"@types/node": "^22.19.3",
|
|
51
54
|
"@vitest/coverage-v8": "^4.1.5",
|
|
52
55
|
"typescript": "^6.0.3",
|
|
53
|
-
"vite-plus": "0.1.
|
|
56
|
+
"vite-plus": "0.1.22"
|
|
54
57
|
},
|
|
55
58
|
"peerDependencies": {
|
|
56
|
-
"
|
|
59
|
+
"expo": ">=53.0.0",
|
|
57
60
|
"react-native-onesignal": ">=5.0.0"
|
|
58
61
|
},
|
|
59
|
-
"packageManager": "bun@1.3.
|
|
62
|
+
"packageManager": "bun@1.3.14"
|
|
60
63
|
}
|