onesignal-expo-plugin 2.5.1 → 2.7.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 +16 -8
- package/dist/index.d.ts +1 -95
- package/dist/index.js +72 -32
- package/dist/plugin.d.ts +8 -0
- package/dist/plugin.js +7 -0
- package/dist/types-1HFwNzon.d.ts +101 -0
- package/package.json +5 -1
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
|
|
|
@@ -90,9 +89,18 @@ You can pass props to the plugin config object to configure:
|
|
|
90
89
|
| `appGroupName` | optional | Used to configure a custom iOS [App Group](https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group) name. If not provided, defaults to `"group.{ios.bundleIdentifier}.onesignal"`. e.g: `"group.com.example.myapp.onesignal2"`. |
|
|
91
90
|
| `nseBundleIdentifier` | optional | Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension. The full bundle identifier will be `"{ios.bundleIdentifier}.{nseBundleIdentifier}"`. If not provided, defaults to `"OneSignalNotificationServiceExtension"`. |
|
|
92
91
|
| `disableNSE` | optional | If `true`, the iOS Notification Service Extension (NSE) will not be added to the project. The NSE is required for badges, confirmed delivery, media attachments, and action buttons. Only disable this if you only need basic push notifications. |
|
|
92
|
+
| `disableLocation` | optional | If `true`, the native OneSignal location module will be excluded from iOS and Android builds. Use this if your app does not call `OneSignal.Location` and should not link native location APIs. |
|
|
93
93
|
| `sounds` | optional | An array of local paths to custom notification sound files (`.wav` only, ≤30 seconds). Files are copied into the app bundle on iOS and `res/raw/` on Android. e.g: `["./assets/notification_sound.wav"]`. See https://documentation.onesignal.com/docs/customize-notification-sounds. |
|
|
94
94
|
| `liveActivities` | optional | Opt in to scaffolding an iOS Widget Extension target for OneSignal Live Activities. Use `{}` for the default `OneSignalWidget` target, or pass `targetName`, `bundleIdentifierSuffix`, `widgetFilePath`, or `deploymentTarget` to customize it. See [Live Activities](#live-activities). |
|
|
95
95
|
|
|
96
|
+
### Disabling Location
|
|
97
|
+
|
|
98
|
+
When `disableLocation` is enabled, the plugin configures native dependency
|
|
99
|
+
resolution so `react-native-onesignal` excludes the location module. On iOS, it
|
|
100
|
+
writes the Podfile environment setting used during CocoaPods resolution. On
|
|
101
|
+
Android, it writes `onesignal.disableLocation=true` to the generated Gradle
|
|
102
|
+
properties.
|
|
103
|
+
|
|
96
104
|
### Live Activities
|
|
97
105
|
|
|
98
106
|
Set `liveActivities` to an object to add the native iOS Widget Extension files and Podfile target required for OneSignal Live Activities.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,100 +1,6 @@
|
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-1HFwNzon.js";
|
|
1
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
|
@@ -28,21 +28,6 @@ let _expo_image_utils = require("@expo/image-utils");
|
|
|
28
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;
|
|
@@ -51,9 +36,10 @@ const NSE_PRINCIPAL_CLASS_TEMPLATE_REGEX = /{{NSE_PRINCIPAL_CLASS}}/gm;
|
|
|
51
36
|
const NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";
|
|
52
37
|
/** Default Swift template shipped under serviceExtensionFiles/. */
|
|
53
38
|
const NSE_SOURCE_FILE = "NotificationService.swift";
|
|
54
|
-
const
|
|
39
|
+
const onesignalExtensionPodDependencies = (disableLocation) => disableLocation ? ["pod 'OneSignalXCFramework/OneSignal', '>= 5.0', '< 6.0'", "pod 'OneSignalXCFramework/OneSignalInAppMessages', '>= 5.0', '< 6.0'"].join("\n ") : "pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'";
|
|
40
|
+
const nsePodfileSnippet = (disableLocation = false) => `
|
|
55
41
|
target '${NSE_TARGET_NAME}' do
|
|
56
|
-
|
|
42
|
+
${onesignalExtensionPodDependencies(disableLocation)}
|
|
57
43
|
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
58
44
|
end`;
|
|
59
45
|
const NSE_PODFILE_REGEX = new RegExp(`target '${NSE_TARGET_NAME}'`);
|
|
@@ -63,9 +49,9 @@ const LIVE_ACTIVITY_DEPLOYMENT_TARGET = "16.2";
|
|
|
63
49
|
const LIVE_ACTIVITY_BUNDLE_FILE = "OneSignalWidgetBundle.swift";
|
|
64
50
|
const LIVE_ACTIVITY_WIDGET_FILE = "OneSignalWidgetLiveActivity.swift";
|
|
65
51
|
const LIVE_ACTIVITY_INFO_PLIST_FILE = `${LIVE_ACTIVITY_TARGET_NAME}-Info.plist`;
|
|
66
|
-
const liveActivityPodfileSnippet = (targetName) => `
|
|
52
|
+
const liveActivityPodfileSnippet = (targetName, disableLocation = false) => `
|
|
67
53
|
target '${targetName}' do
|
|
68
|
-
|
|
54
|
+
${onesignalExtensionPodDependencies(disableLocation)}
|
|
69
55
|
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
70
56
|
end`;
|
|
71
57
|
const liveActivityPodfileRegex = (targetName) => new RegExp(`target '${targetName}'`);
|
|
@@ -83,6 +69,27 @@ var OneSignalLog = class {
|
|
|
83
69
|
//#region src/support/helpers.ts
|
|
84
70
|
const HEX_COLOR_6_REGEX = /^#?[0-9A-Fa-f]{6}$/;
|
|
85
71
|
const HEX_COLOR_8_REGEX = /^#?[0-9A-Fa-f]{8}$/;
|
|
72
|
+
const ONESIGNAL_PLUGIN_PROPS = [
|
|
73
|
+
"mode",
|
|
74
|
+
"devTeam",
|
|
75
|
+
"iPhoneDeploymentTarget",
|
|
76
|
+
"smallIcons",
|
|
77
|
+
"largeIcons",
|
|
78
|
+
"iosNSEFilePath",
|
|
79
|
+
"smallIconAccentColor",
|
|
80
|
+
"appGroupName",
|
|
81
|
+
"nseBundleIdentifier",
|
|
82
|
+
"disableNSE",
|
|
83
|
+
"disableLocation",
|
|
84
|
+
"sounds",
|
|
85
|
+
"liveActivities"
|
|
86
|
+
];
|
|
87
|
+
const LIVE_ACTIVITY_PROPS = [
|
|
88
|
+
"targetName",
|
|
89
|
+
"bundleIdentifierSuffix",
|
|
90
|
+
"widgetFilePath",
|
|
91
|
+
"deploymentTarget"
|
|
92
|
+
];
|
|
86
93
|
/**
|
|
87
94
|
* Converts a hex color string (#RGB, #RRGGBB, or #AARRGGBB) to an
|
|
88
95
|
* 8-character ARGB hex string (no '#') expected by the OneSignal Android SDK.
|
|
@@ -108,6 +115,7 @@ function validatePluginProps(props) {
|
|
|
108
115
|
if (props.appGroupName && typeof props.appGroupName !== "string") throw new Error("OneSignal Expo Plugin: 'appGroupName' must be a string.");
|
|
109
116
|
if (props.nseBundleIdentifier && typeof props.nseBundleIdentifier !== "string") throw new Error("OneSignal Expo Plugin: 'nseBundleIdentifier' must be a string.");
|
|
110
117
|
if (props.disableNSE !== void 0 && typeof props.disableNSE !== "boolean") throw new Error("OneSignal Expo Plugin: 'disableNSE' must be a boolean.");
|
|
118
|
+
if (props.disableLocation !== void 0 && typeof props.disableLocation !== "boolean") throw new Error("OneSignal Expo Plugin: 'disableLocation' must be a boolean.");
|
|
111
119
|
if (props.sounds !== void 0) {
|
|
112
120
|
if (!Array.isArray(props.sounds)) throw new Error("OneSignal Expo Plugin: 'sounds' must be an array.");
|
|
113
121
|
for (const sound of props.sounds) {
|
|
@@ -118,19 +126,13 @@ function validatePluginProps(props) {
|
|
|
118
126
|
if (props.liveActivities !== void 0) {
|
|
119
127
|
if (props.liveActivities === null || Array.isArray(props.liveActivities) || typeof props.liveActivities !== "object") throw new Error("OneSignal Expo Plugin: 'liveActivities' must be an object.");
|
|
120
128
|
const liveActivities = props.liveActivities;
|
|
121
|
-
const liveActivityProps = [
|
|
122
|
-
"targetName",
|
|
123
|
-
"bundleIdentifierSuffix",
|
|
124
|
-
"widgetFilePath",
|
|
125
|
-
"deploymentTarget"
|
|
126
|
-
];
|
|
127
129
|
for (const prop of Object.keys(liveActivities)) {
|
|
128
|
-
if (!
|
|
130
|
+
if (!LIVE_ACTIVITY_PROPS.some((allowedProp) => allowedProp === prop)) throw new Error(`OneSignal Expo Plugin: You have provided an invalid property "${prop}" to 'liveActivities'.`);
|
|
129
131
|
if (typeof liveActivities[prop] !== "string") throw new Error(`OneSignal Expo Plugin: 'liveActivities.${prop}' must be a string.`);
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
const inputProps = Object.keys(props);
|
|
133
|
-
for (const prop of inputProps) if (!ONESIGNAL_PLUGIN_PROPS.
|
|
135
|
+
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
136
|
}
|
|
135
137
|
/**
|
|
136
138
|
* Detect whether the customer's NSE is Swift or Objective-C from `iosNSEFilePath`.
|
|
@@ -175,6 +177,7 @@ function resolveDevTeam(config, props) {
|
|
|
175
177
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
176
178
|
*/
|
|
177
179
|
const RESOURCE_ROOT_PATH = "android/app/src/main/res/";
|
|
180
|
+
const ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY = "onesignal.disableLocation";
|
|
178
181
|
const SMALL_ICON_DIRS_TO_SIZE = {
|
|
179
182
|
"drawable-mdpi": 24,
|
|
180
183
|
"drawable-hdpi": 36,
|
|
@@ -218,6 +221,21 @@ const withSmallIconAccentColor = (config, onesignalProps) => {
|
|
|
218
221
|
return config;
|
|
219
222
|
});
|
|
220
223
|
};
|
|
224
|
+
const withLocationModuleGradleProperty = (config, onesignalProps) => {
|
|
225
|
+
if (onesignalProps.disableLocation == null) return config;
|
|
226
|
+
return (0, expo_config_plugins_js.withGradleProperties)(config, (config) => {
|
|
227
|
+
const properties = config.modResults;
|
|
228
|
+
const existingIndex = properties.findIndex((entry) => entry.type === "property" && entry.key === ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY);
|
|
229
|
+
const property = {
|
|
230
|
+
type: "property",
|
|
231
|
+
key: ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY,
|
|
232
|
+
value: onesignalProps.disableLocation ? "true" : "false"
|
|
233
|
+
};
|
|
234
|
+
if (existingIndex === -1) properties.push(property);
|
|
235
|
+
else properties[existingIndex] = property;
|
|
236
|
+
return config;
|
|
237
|
+
});
|
|
238
|
+
};
|
|
221
239
|
async function saveIconsArrayAsync(projectRoot, icons, dirsToSize, defaultName) {
|
|
222
240
|
for (let i = 0; i < icons.length; i++) {
|
|
223
241
|
const outputName = i === 0 ? defaultName : void 0;
|
|
@@ -262,6 +280,7 @@ const withOneSignalAndroid = (config, props) => {
|
|
|
262
280
|
config = withSmallIcons(config, props);
|
|
263
281
|
config = withLargeIcons(config, props);
|
|
264
282
|
config = withSmallIconAccentColor(config, props);
|
|
283
|
+
config = withLocationModuleGradleProperty(config, props);
|
|
265
284
|
config = withSoundFiles$1(config, props);
|
|
266
285
|
return config;
|
|
267
286
|
};
|
|
@@ -385,14 +404,26 @@ var NseUpdaterManager = class {
|
|
|
385
404
|
};
|
|
386
405
|
//#endregion
|
|
387
406
|
//#region src/support/updatePodfile.ts
|
|
388
|
-
|
|
407
|
+
const ONESIGNAL_DISABLE_LOCATION_ENV = "ENV['ONESIGNAL_DISABLE_LOCATION']";
|
|
408
|
+
const ONESIGNAL_DISABLE_LOCATION_REGEX = /^(?:ENV\[['"]ONESIGNAL_DISABLE_LOCATION['"]\]\s*=\s*['"](true|false)['"]|\$OneSignalDisableLocation\s*=\s*(true|false))\s*$/m;
|
|
409
|
+
async function updatePodfile(iosPath, disableLocation = false) {
|
|
389
410
|
if ((await FileManager.readFile(`${iosPath}/Podfile`)).match(NSE_PODFILE_REGEX)) {
|
|
390
411
|
OneSignalLog.log(`${NSE_TARGET_NAME} target already added to Podfile. Skipping...`);
|
|
391
412
|
return;
|
|
392
413
|
}
|
|
393
|
-
await fs_promises.default.appendFile(`${iosPath}/Podfile`,
|
|
414
|
+
await fs_promises.default.appendFile(`${iosPath}/Podfile`, nsePodfileSnippet(disableLocation));
|
|
394
415
|
OneSignalLog.log(`${NSE_TARGET_NAME} target added to Podfile.`);
|
|
395
416
|
}
|
|
417
|
+
async function updatePodfileLocationModule(iosPath, disableLocation) {
|
|
418
|
+
const podfilePath = `${iosPath}/Podfile`;
|
|
419
|
+
const podfile = await FileManager.readFile(podfilePath);
|
|
420
|
+
const nextValue = `${ONESIGNAL_DISABLE_LOCATION_ENV} = '${disableLocation ? "true" : "false"}'`;
|
|
421
|
+
if (ONESIGNAL_DISABLE_LOCATION_REGEX.test(podfile)) {
|
|
422
|
+
await fs_promises.default.writeFile(podfilePath, podfile.replace(ONESIGNAL_DISABLE_LOCATION_REGEX, nextValue));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
await fs_promises.default.writeFile(podfilePath, `${nextValue}\n${podfile}`);
|
|
426
|
+
}
|
|
396
427
|
//#endregion
|
|
397
428
|
//#region src/onesignal/withOneSignalLiveActivity.ts
|
|
398
429
|
/**
|
|
@@ -436,7 +467,7 @@ const withLiveActivityPodfile = (config, props) => {
|
|
|
436
467
|
OneSignalLog.log(`${targetName} target already added to Podfile. Skipping...`);
|
|
437
468
|
return config;
|
|
438
469
|
}
|
|
439
|
-
await fs.promises.appendFile(podfilePath, liveActivityPodfileSnippet(targetName));
|
|
470
|
+
await fs.promises.appendFile(podfilePath, liveActivityPodfileSnippet(targetName, props.disableLocation === true));
|
|
440
471
|
OneSignalLog.log(`${targetName} target added to Podfile.`);
|
|
441
472
|
return config;
|
|
442
473
|
}]);
|
|
@@ -581,9 +612,17 @@ const withEasManagedCredentials = (config, props) => {
|
|
|
581
612
|
config.extra = getEasManagedCredentialsConfigExtra(config, props?.appGroupName, props?.nseBundleIdentifier, props?.liveActivities, props?.disableNSE);
|
|
582
613
|
return config;
|
|
583
614
|
};
|
|
584
|
-
const withOneSignalPodfile = (config) => {
|
|
615
|
+
const withOneSignalPodfile = (config, props) => {
|
|
616
|
+
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
617
|
+
await updatePodfile(path.join(config.modRequest.projectRoot, "ios"), props.disableLocation === true);
|
|
618
|
+
return config;
|
|
619
|
+
}]);
|
|
620
|
+
};
|
|
621
|
+
const withLocationModulePodfile = (config, props) => {
|
|
622
|
+
const disableLocation = props.disableLocation;
|
|
623
|
+
if (disableLocation == null) return config;
|
|
585
624
|
return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
|
|
586
|
-
await
|
|
625
|
+
await updatePodfileLocationModule(path.join(config.modRequest.projectRoot, "ios"), disableLocation);
|
|
587
626
|
return config;
|
|
588
627
|
}]);
|
|
589
628
|
};
|
|
@@ -686,6 +725,7 @@ const withSoundFiles = (config, onesignalProps) => {
|
|
|
686
725
|
const withOneSignalIos = (config, props) => {
|
|
687
726
|
config = withAppEnvironment(config, props);
|
|
688
727
|
config = withRemoteNotificationsPermissions(config, props);
|
|
728
|
+
config = withLocationModulePodfile(config, props);
|
|
689
729
|
if (!props.disableNSE) {
|
|
690
730
|
config = withCustomAppGroupsKey(config, props);
|
|
691
731
|
config = withAppGroupPermissions(config, props);
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-1HFwNzon.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,101 @@
|
|
|
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) If true, the native OneSignal location module will be excluded from iOS and Android builds.
|
|
84
|
+
* OneSignal.Location APIs will not collect location and will no-op or return false.
|
|
85
|
+
*/
|
|
86
|
+
disableLocation?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* (optional) An array of local paths to custom notification sound files (.wav only).
|
|
89
|
+
* Files are added to the iOS app bundle and Android res/raw/.
|
|
90
|
+
* @see https://documentation.onesignal.com/docs/customize-notification-sounds
|
|
91
|
+
*/
|
|
92
|
+
sounds?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* (optional) Opt in to scaffolding an iOS Widget Extension target for Live Activities.
|
|
95
|
+
* Presence of this prop enables Live Activity setup. Requires iOS 16.1+ and a .p8 APNs key.
|
|
96
|
+
* @see https://documentation.onesignal.com/docs/cross-platform-live-activity-setup
|
|
97
|
+
*/
|
|
98
|
+
liveActivities?: OneSignalLiveActivityProps;
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { OneSignalPluginProps as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "OneSignal Expo config plugin for adding iOS and Android push notification support to managed Expo apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"EAS",
|
|
@@ -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": {
|