onesignal-expo-plugin 2.7.1 → 2.8.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 +28 -16
- package/dist/index.d.ts +2 -5
- package/dist/index.js +49 -46
- package/dist/plugin.d.ts +2 -7
- package/dist/plugin.js +2 -4
- package/dist/{types-A2mAFlHd.d.ts → types-DC6uSYcE.d.ts} +8 -3
- package/package.json +19 -9
package/README.md
CHANGED
|
@@ -77,21 +77,22 @@ export default {
|
|
|
77
77
|
|
|
78
78
|
You can pass props to the plugin config object to configure:
|
|
79
79
|
|
|
80
|
-
| Plugin Prop
|
|
81
|
-
|
|
|
82
|
-
| `mode`
|
|
83
|
-
| `devTeam`
|
|
84
|
-
| `iPhoneDeploymentTarget`
|
|
85
|
-
| `smallIcons`
|
|
86
|
-
| `largeIcons`
|
|
87
|
-
| `smallIconAccentColor`
|
|
88
|
-
| `iosNSEFilePath`
|
|
89
|
-
| `appGroupName`
|
|
90
|
-
| `nseBundleIdentifier`
|
|
91
|
-
| `disableNSE`
|
|
92
|
-
| `disableLocation`
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
80
|
+
| Plugin Prop | | |
|
|
81
|
+
| ------------------------------ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` |
|
|
83
|
+
| `devTeam` | **deprecated** | Use [`ios.appleTeamId`](https://docs.expo.dev/versions/latest/config/app/#appleteamid) in your Expo config instead. Falls back to this value if `appleTeamId` is not set. e.g: `"91SW8A37CR"` |
|
|
84
|
+
| `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"15.0"`. |
|
|
85
|
+
| `smallIcons` | optional | An array of local paths to small notification icons for Android. Image should be white, transparent, and 96x96 in size. Input images will be automatically scaled down and placed in the appropriate resource folders. e.g: `["./assets/ic_stat_onesignal_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#small-notification-icons. |
|
|
86
|
+
| `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. |
|
|
87
|
+
| `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
|
|
88
|
+
| `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Swift. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/serviceExtensionFiles/NotificationService.swift), then altered to support any custom logic required. e.g: `"./assets/NotificationService.swift"`. |
|
|
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"`. |
|
|
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"`. |
|
|
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
|
+
| `enableFirebaseInstallationId` | optional | Android only. If `true`, adds `firebase_messaging_installation_id_enabled=true` meta-data to the Android manifest so push registration uses the Firebase Installation ID (FID) path. If unset, the manifest is untouched (legacy FCM token path). If `false`, removes the entry from the app manifest if present. See [Firebase Installation ID (Android)](#firebase-installation-id-android). |
|
|
94
|
+
| `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. |
|
|
95
|
+
| `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
96
|
|
|
96
97
|
### Disabling Location
|
|
97
98
|
|
|
@@ -101,6 +102,17 @@ writes the Podfile environment setting used during CocoaPods resolution. On
|
|
|
101
102
|
Android, it writes `onesignal.disableLocation=true` to the generated Gradle
|
|
102
103
|
properties.
|
|
103
104
|
|
|
105
|
+
### Firebase Installation ID (Android)
|
|
106
|
+
|
|
107
|
+
`enableFirebaseInstallationId: true` opts in to the Firebase Installation ID (FID) push registration path. The plugin only writes the manifest flag; the rest of the setup is owned by your app:
|
|
108
|
+
|
|
109
|
+
- Use `react-native-onesignal` 5.5.16 or newer (OneSignal Android SDK 5.11.0+).
|
|
110
|
+
- Set `android.googleServicesFile` in your Expo config to a `google-services.json` from your own Firebase project. Its client entry must match `android.package` (and every variant you build). Expo prebuild then applies the Google Services Gradle plugin.
|
|
111
|
+
- Resolve `com.google.firebase:firebase-messaging` 25.1.0 or newer. The OneSignal Android SDK declares a lower range, so force the version in your app, e.g. with a config plugin that adds a Gradle `resolutionStrategy`. Firebase Messaging 25.x requires `minSdkVersion` 23.
|
|
112
|
+
- Build with a development build or `expo run:android`. Expo Go is not supported.
|
|
113
|
+
|
|
114
|
+
Leaving the prop unset keeps the legacy FCM token path and requires none of the above. Setting it to `false` removes the flag from the app manifest, for example after an earlier `expo prebuild` without `--clean`; it never writes `false`. The flag is app-wide, so another dependency can also enable it through manifest merging; in that case the same setup applies even without this prop.
|
|
115
|
+
|
|
104
116
|
### Live Activities
|
|
105
117
|
|
|
106
118
|
Set `liveActivities` to an object to add the native iOS Widget Extension files and Podfile target required for OneSignal Live Activities.
|
|
@@ -167,8 +179,8 @@ Add your OneSignal App ID to your [Expo constants via the `extra` param](https:/
|
|
|
167
179
|
You can then access the value to pass to the `initialize` function:
|
|
168
180
|
|
|
169
181
|
```js
|
|
170
|
-
import { OneSignal } from 'react-native-onesignal';
|
|
171
182
|
import Constants from 'expo-constants';
|
|
183
|
+
import { OneSignal } from 'react-native-onesignal';
|
|
172
184
|
OneSignal.initialize(Constants.expoConfig.extra.oneSignalAppId);
|
|
173
185
|
```
|
|
174
186
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { t as OneSignalPluginProps } from "./types-
|
|
2
|
-
import { ConfigPlugin } from "expo/config-plugins
|
|
3
|
-
|
|
4
|
-
//#region src/onesignal/withOneSignal.d.ts
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-DC6uSYcE.js";
|
|
2
|
+
import { ConfigPlugin } from "expo/config-plugins";
|
|
5
3
|
declare const withOneSignal: ConfigPlugin<OneSignalPluginProps>;
|
|
6
|
-
//#endregion
|
|
7
4
|
export { type OneSignalPluginProps, withOneSignal as default };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -15,17 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
22
|
let path = require("path");
|
|
24
23
|
path = __toESM(path);
|
|
25
24
|
let fs = require("fs");
|
|
26
25
|
fs = __toESM(fs);
|
|
27
26
|
let _expo_image_utils = require("@expo/image-utils");
|
|
28
|
-
let
|
|
27
|
+
let expo_config_plugins = require("expo/config-plugins");
|
|
29
28
|
let fs_promises = require("fs/promises");
|
|
30
29
|
fs_promises = __toESM(fs_promises);
|
|
31
30
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
@@ -55,8 +54,7 @@ target '${targetName}' do
|
|
|
55
54
|
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
56
55
|
end`;
|
|
57
56
|
const liveActivityPodfileRegex = (targetName) => new RegExp(`target '${targetName}'`);
|
|
58
|
-
|
|
59
|
-
//#region src/support/OneSignalLog.ts
|
|
57
|
+
// src/support/OneSignalLog.ts
|
|
60
58
|
var OneSignalLog = class {
|
|
61
59
|
static log(str) {
|
|
62
60
|
console.log(`\tonesignal-expo-plugin: ${str}`);
|
|
@@ -65,8 +63,7 @@ var OneSignalLog = class {
|
|
|
65
63
|
console.error(`\tonesignal-expo-plugin: ${str}`);
|
|
66
64
|
}
|
|
67
65
|
};
|
|
68
|
-
|
|
69
|
-
//#region src/support/helpers.ts
|
|
66
|
+
// src/support/helpers.ts
|
|
70
67
|
const HEX_COLOR_6_REGEX = /^#?[0-9A-Fa-f]{6}$/;
|
|
71
68
|
const HEX_COLOR_8_REGEX = /^#?[0-9A-Fa-f]{8}$/;
|
|
72
69
|
const ONESIGNAL_PLUGIN_PROPS = [
|
|
@@ -81,6 +78,7 @@ const ONESIGNAL_PLUGIN_PROPS = [
|
|
|
81
78
|
"nseBundleIdentifier",
|
|
82
79
|
"disableNSE",
|
|
83
80
|
"disableLocation",
|
|
81
|
+
"enableFirebaseInstallationId",
|
|
84
82
|
"sounds",
|
|
85
83
|
"liveActivities"
|
|
86
84
|
];
|
|
@@ -116,6 +114,7 @@ function validatePluginProps(props) {
|
|
|
116
114
|
if (props.nseBundleIdentifier && typeof props.nseBundleIdentifier !== "string") throw new Error("OneSignal Expo Plugin: 'nseBundleIdentifier' must be a string.");
|
|
117
115
|
if (props.disableNSE !== void 0 && typeof props.disableNSE !== "boolean") throw new Error("OneSignal Expo Plugin: 'disableNSE' must be a boolean.");
|
|
118
116
|
if (props.disableLocation !== void 0 && typeof props.disableLocation !== "boolean") throw new Error("OneSignal Expo Plugin: 'disableLocation' must be a boolean.");
|
|
117
|
+
if (props.enableFirebaseInstallationId !== void 0 && typeof props.enableFirebaseInstallationId !== "boolean") throw new Error("OneSignal Expo Plugin: 'enableFirebaseInstallationId' must be a boolean.");
|
|
119
118
|
if (props.sounds !== void 0) {
|
|
120
119
|
if (!Array.isArray(props.sounds)) throw new Error("OneSignal Expo Plugin: 'sounds' must be an array.");
|
|
121
120
|
for (const sound of props.sounds) {
|
|
@@ -170,14 +169,14 @@ function resolveDevTeam(config, props) {
|
|
|
170
169
|
return props.devTeam;
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
|
-
|
|
174
|
-
//#region src/onesignal/withOneSignalAndroid.ts
|
|
172
|
+
// src/onesignal/withOneSignalAndroid.ts
|
|
175
173
|
/**
|
|
176
174
|
* Expo config plugin for OneSignal (Android)
|
|
177
175
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
178
176
|
*/
|
|
179
177
|
const RESOURCE_ROOT_PATH = "android/app/src/main/res/";
|
|
180
178
|
const ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY = "onesignal.disableLocation";
|
|
179
|
+
const FIREBASE_INSTALLATION_ID_META_DATA = "firebase_messaging_installation_id_enabled";
|
|
181
180
|
const SMALL_ICON_DIRS_TO_SIZE = {
|
|
182
181
|
"drawable-mdpi": 24,
|
|
183
182
|
"drawable-hdpi": 36,
|
|
@@ -190,7 +189,7 @@ const SMALL_ICON_DEFAULT_NAME = "ic_stat_onesignal_default";
|
|
|
190
189
|
const withSmallIcons = (config, onesignalProps) => {
|
|
191
190
|
const expoConfig = config;
|
|
192
191
|
if (!onesignalProps.smallIcons && !expoConfig.notification?.icon) return config;
|
|
193
|
-
return (0,
|
|
192
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["android", async (config) => {
|
|
194
193
|
const modConfig = config;
|
|
195
194
|
if (modConfig.notification?.icon) await saveIconAsync(modConfig.notification.icon, config.modRequest.projectRoot, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
196
195
|
if (onesignalProps.smallIcons) await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.smallIcons, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
@@ -200,14 +199,14 @@ const withSmallIcons = (config, onesignalProps) => {
|
|
|
200
199
|
const LARGE_ICON_DEFAULT_NAME = "ic_onesignal_large_icon_default";
|
|
201
200
|
const withLargeIcons = (config, onesignalProps) => {
|
|
202
201
|
if (!onesignalProps.largeIcons) return config;
|
|
203
|
-
return (0,
|
|
202
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["android", async (config) => {
|
|
204
203
|
if (onesignalProps.largeIcons) await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.largeIcons, LARGE_ICON_DIRS_TO_SIZE, LARGE_ICON_DEFAULT_NAME);
|
|
205
204
|
return config;
|
|
206
205
|
}]);
|
|
207
206
|
};
|
|
208
207
|
const withSmallIconAccentColor = (config, onesignalProps) => {
|
|
209
208
|
if (!onesignalProps.smallIconAccentColor) return config;
|
|
210
|
-
return (0,
|
|
209
|
+
return (0, expo_config_plugins.withStringsXml)(config, (config) => {
|
|
211
210
|
const colorInARGB = parseColorToARGB(onesignalProps.smallIconAccentColor ?? "");
|
|
212
211
|
const strings = config.modResults.resources.string ?? [];
|
|
213
212
|
const existingIndex = strings.findIndex((stringEntry) => stringEntry.$?.name === "onesignal_notification_accent_color");
|
|
@@ -223,7 +222,7 @@ const withSmallIconAccentColor = (config, onesignalProps) => {
|
|
|
223
222
|
};
|
|
224
223
|
const withLocationModuleGradleProperty = (config, onesignalProps) => {
|
|
225
224
|
if (onesignalProps.disableLocation == null) return config;
|
|
226
|
-
return (0,
|
|
225
|
+
return (0, expo_config_plugins.withGradleProperties)(config, (config) => {
|
|
227
226
|
const properties = config.modResults;
|
|
228
227
|
const existingIndex = properties.findIndex((entry) => entry.type === "property" && entry.key === ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY);
|
|
229
228
|
const property = {
|
|
@@ -236,6 +235,17 @@ const withLocationModuleGradleProperty = (config, onesignalProps) => {
|
|
|
236
235
|
return config;
|
|
237
236
|
});
|
|
238
237
|
};
|
|
238
|
+
const withFirebaseInstallationIdManifest = (config, onesignalProps) => {
|
|
239
|
+
const enabled = onesignalProps.enableFirebaseInstallationId;
|
|
240
|
+
if (enabled == null) return config;
|
|
241
|
+
if (enabled && !config.android?.googleServicesFile) expo_config_plugins.WarningAggregator.addWarningAndroid("onesignal-expo-plugin", "'enableFirebaseInstallationId' is true but 'android.googleServicesFile' is not set. Firebase Installation ID push registration needs your own Firebase project's google-services.json.");
|
|
242
|
+
return (0, expo_config_plugins.withAndroidManifest)(config, (config) => {
|
|
243
|
+
const mainApplication = expo_config_plugins.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
|
|
244
|
+
if (enabled) expo_config_plugins.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, FIREBASE_INSTALLATION_ID_META_DATA, "true");
|
|
245
|
+
else expo_config_plugins.AndroidConfig.Manifest.removeMetaDataItemFromMainApplication(mainApplication, FIREBASE_INSTALLATION_ID_META_DATA);
|
|
246
|
+
return config;
|
|
247
|
+
});
|
|
248
|
+
};
|
|
239
249
|
async function saveIconsArrayAsync(projectRoot, icons, dirsToSize, defaultName) {
|
|
240
250
|
for (let i = 0; i < icons.length; i++) {
|
|
241
251
|
const outputName = i === 0 ? defaultName : void 0;
|
|
@@ -263,7 +273,7 @@ async function saveIconAsync(icon, projectRoot, dirsToSize, outputName) {
|
|
|
263
273
|
}
|
|
264
274
|
const withSoundFiles$1 = (config, onesignalProps) => {
|
|
265
275
|
if (!onesignalProps.sounds) return config;
|
|
266
|
-
return (0,
|
|
276
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["android", async (config) => {
|
|
267
277
|
const projectRoot = config.modRequest.projectRoot;
|
|
268
278
|
const rawDir = (0, path.resolve)(projectRoot, RESOURCE_ROOT_PATH, "raw");
|
|
269
279
|
if (!(0, fs.existsSync)(rawDir)) (0, fs.mkdirSync)(rawDir, { recursive: true });
|
|
@@ -281,11 +291,11 @@ const withOneSignalAndroid = (config, props) => {
|
|
|
281
291
|
config = withLargeIcons(config, props);
|
|
282
292
|
config = withSmallIconAccentColor(config, props);
|
|
283
293
|
config = withLocationModuleGradleProperty(config, props);
|
|
294
|
+
config = withFirebaseInstallationIdManifest(config, props);
|
|
284
295
|
config = withSoundFiles$1(config, props);
|
|
285
296
|
return config;
|
|
286
297
|
};
|
|
287
|
-
|
|
288
|
-
//#region src/support/eas/getEasManagedCredentialsConfigExtra.ts
|
|
298
|
+
// src/support/eas/getEasManagedCredentialsConfigExtra.ts
|
|
289
299
|
function getEasManagedCredentialsConfigExtra(config, appGroupName, nseBundleIdentifier, liveActivities, disableNSE) {
|
|
290
300
|
const bundleIdentifier = config?.ios?.bundleIdentifier ?? "";
|
|
291
301
|
const appExtensions = [...config.extra?.eas?.build?.experimental?.ios?.appExtensions ?? []];
|
|
@@ -323,8 +333,7 @@ function getEasManagedCredentialsConfigExtra(config, appGroupName, nseBundleIden
|
|
|
323
333
|
}
|
|
324
334
|
};
|
|
325
335
|
}
|
|
326
|
-
|
|
327
|
-
//#region src/support/FileManager.ts
|
|
336
|
+
// src/support/FileManager.ts
|
|
328
337
|
/**
|
|
329
338
|
* FileManager contains static *awaitable* file-system functions
|
|
330
339
|
*/
|
|
@@ -361,8 +370,7 @@ var FileManager = class FileManager {
|
|
|
361
370
|
return fs.existsSync(path);
|
|
362
371
|
}
|
|
363
372
|
};
|
|
364
|
-
|
|
365
|
-
//#region src/support/NseUpdaterManager.ts
|
|
373
|
+
// src/support/NseUpdaterManager.ts
|
|
366
374
|
const entitlementsFileName = `${NSE_TARGET_NAME}.entitlements`;
|
|
367
375
|
const plistFileName = `${NSE_TARGET_NAME}-Info.plist`;
|
|
368
376
|
var NseUpdaterManager = class {
|
|
@@ -402,8 +410,7 @@ var NseUpdaterManager = class {
|
|
|
402
410
|
await FileManager.writeFile(plistFilePath, plistFile);
|
|
403
411
|
}
|
|
404
412
|
};
|
|
405
|
-
|
|
406
|
-
//#region src/support/updatePodfile.ts
|
|
413
|
+
// src/support/updatePodfile.ts
|
|
407
414
|
const ONESIGNAL_DISABLE_LOCATION_ENV = "ENV['ONESIGNAL_DISABLE_LOCATION']";
|
|
408
415
|
const ONESIGNAL_DISABLE_LOCATION_REGEX = /^(?:ENV\[['"]ONESIGNAL_DISABLE_LOCATION['"]\]\s*=\s*['"](true|false)['"]|\$OneSignalDisableLocation\s*=\s*(true|false))\s*$/m;
|
|
409
416
|
async function updatePodfile(iosPath, disableLocation = false) {
|
|
@@ -424,8 +431,7 @@ async function updatePodfileLocationModule(iosPath, disableLocation) {
|
|
|
424
431
|
}
|
|
425
432
|
await fs_promises.default.writeFile(podfilePath, `${nextValue}\n${podfile}`);
|
|
426
433
|
}
|
|
427
|
-
|
|
428
|
-
//#region src/onesignal/withOneSignalLiveActivity.ts
|
|
434
|
+
// src/onesignal/withOneSignalLiveActivity.ts
|
|
429
435
|
/**
|
|
430
436
|
* Expo config plugin that scaffolds an iOS Widget Extension target for OneSignal Live Activities.
|
|
431
437
|
* @see https://documentation.onesignal.com/docs/cross-platform-live-activity-setup
|
|
@@ -452,14 +458,14 @@ function resolveLiveActivityDeploymentTarget(props) {
|
|
|
452
458
|
}
|
|
453
459
|
/** Add NSSupportsLiveActivities=true to the main target's Info.plist. */
|
|
454
460
|
const withLiveActivityInfoPlist = (config) => {
|
|
455
|
-
return (0,
|
|
461
|
+
return (0, expo_config_plugins.withInfoPlist)(config, (newConfig) => {
|
|
456
462
|
newConfig.modResults.NSSupportsLiveActivities = true;
|
|
457
463
|
return newConfig;
|
|
458
464
|
});
|
|
459
465
|
};
|
|
460
466
|
/** Append a Widget Extension target block to the Podfile (idempotent). */
|
|
461
467
|
const withLiveActivityPodfile = (config, props) => {
|
|
462
|
-
return (0,
|
|
468
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["ios", async (config) => {
|
|
463
469
|
const targetName = resolveLiveActivityTargetName(props);
|
|
464
470
|
const podfilePath = path.join(config.modRequest.projectRoot, "ios", "Podfile");
|
|
465
471
|
const podfile = await FileManager.readFile(podfilePath);
|
|
@@ -474,7 +480,7 @@ const withLiveActivityPodfile = (config, props) => {
|
|
|
474
480
|
};
|
|
475
481
|
/** Copy widget extension template files (or the user-supplied widget file) into the iOS project. */
|
|
476
482
|
const withLiveActivityFiles = (config, props) => {
|
|
477
|
-
return (0,
|
|
483
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["ios", async (config) => {
|
|
478
484
|
const targetName = resolveLiveActivityTargetName(props);
|
|
479
485
|
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
480
486
|
const sourceDir = path.join(pluginDir, "../widgetExtensionFiles/");
|
|
@@ -498,7 +504,7 @@ const withLiveActivityFiles = (config, props) => {
|
|
|
498
504
|
};
|
|
499
505
|
/** Register the widget extension target, group, build phases, and build settings in the Xcode project. */
|
|
500
506
|
const withLiveActivityXcodeProject = (config, props) => {
|
|
501
|
-
return (0,
|
|
507
|
+
return (0, expo_config_plugins.withXcodeProject)(config, (newConfig) => {
|
|
502
508
|
const xcodeProject = newConfig.modResults;
|
|
503
509
|
const targetName = resolveLiveActivityTargetName(props);
|
|
504
510
|
const widgetBundleId = resolveLiveActivityBundleId(config.ios?.bundleIdentifier ?? "", props);
|
|
@@ -550,8 +556,7 @@ const withOneSignalLiveActivity = (config, props) => {
|
|
|
550
556
|
config = withLiveActivityXcodeProject(config, props);
|
|
551
557
|
return config;
|
|
552
558
|
};
|
|
553
|
-
|
|
554
|
-
//#region src/onesignal/withOneSignalIos.ts
|
|
559
|
+
// src/onesignal/withOneSignalIos.ts
|
|
555
560
|
/**
|
|
556
561
|
* Expo config plugin for One Signal (iOS)
|
|
557
562
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
@@ -561,7 +566,7 @@ const withOneSignalLiveActivity = (config, props) => {
|
|
|
561
566
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
562
567
|
*/
|
|
563
568
|
const withAppEnvironment = (config, onesignalProps) => {
|
|
564
|
-
return (0,
|
|
569
|
+
return (0, expo_config_plugins.withEntitlementsPlist)(config, (newConfig) => {
|
|
565
570
|
if (onesignalProps?.mode == null) throw new Error(`
|
|
566
571
|
Missing required "mode" key in your app.json or app.config.js file for "onesignal-expo-plugin".
|
|
567
572
|
"mode" can be either "development" or "production".
|
|
@@ -576,7 +581,7 @@ const withAppEnvironment = (config, onesignalProps) => {
|
|
|
576
581
|
*/
|
|
577
582
|
const withRemoteNotificationsPermissions = (config) => {
|
|
578
583
|
const BACKGROUND_MODE_KEYS = ["remote-notification"];
|
|
579
|
-
return (0,
|
|
584
|
+
return (0, expo_config_plugins.withInfoPlist)(config, (newConfig) => {
|
|
580
585
|
if (!Array.isArray(newConfig.modResults.UIBackgroundModes)) newConfig.modResults.UIBackgroundModes = [];
|
|
581
586
|
for (const key of BACKGROUND_MODE_KEYS) if (!newConfig.modResults.UIBackgroundModes.includes(key)) newConfig.modResults.UIBackgroundModes.push(key);
|
|
582
587
|
return newConfig;
|
|
@@ -588,7 +593,7 @@ const withRemoteNotificationsPermissions = (config) => {
|
|
|
588
593
|
*/
|
|
589
594
|
const withAppGroupPermissions = (config, props) => {
|
|
590
595
|
const APP_GROUP_KEY = "com.apple.security.application-groups";
|
|
591
|
-
return (0,
|
|
596
|
+
return (0, expo_config_plugins.withEntitlementsPlist)(config, (newConfig) => {
|
|
592
597
|
if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) newConfig.modResults[APP_GROUP_KEY] = [];
|
|
593
598
|
const modResultsArray = newConfig.modResults[APP_GROUP_KEY];
|
|
594
599
|
const entitlement = getAppGroupIdentifier(newConfig?.ios?.bundleIdentifier || "", props?.appGroupName);
|
|
@@ -602,7 +607,7 @@ const withAppGroupPermissions = (config, props) => {
|
|
|
602
607
|
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
603
608
|
*/
|
|
604
609
|
const withCustomAppGroupsKey = (config, props) => {
|
|
605
|
-
return (0,
|
|
610
|
+
return (0, expo_config_plugins.withInfoPlist)(config, (newConfig) => {
|
|
606
611
|
if (props?.appGroupName) newConfig.modResults.OneSignal_app_groups_key = props.appGroupName;
|
|
607
612
|
return newConfig;
|
|
608
613
|
});
|
|
@@ -613,7 +618,7 @@ const withEasManagedCredentials = (config, props) => {
|
|
|
613
618
|
return config;
|
|
614
619
|
};
|
|
615
620
|
const withOneSignalPodfile = (config, props) => {
|
|
616
|
-
return (0,
|
|
621
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["ios", async (config) => {
|
|
617
622
|
await updatePodfile(path.join(config.modRequest.projectRoot, "ios"), props.disableLocation === true);
|
|
618
623
|
return config;
|
|
619
624
|
}]);
|
|
@@ -621,13 +626,13 @@ const withOneSignalPodfile = (config, props) => {
|
|
|
621
626
|
const withLocationModulePodfile = (config, props) => {
|
|
622
627
|
const disableLocation = props.disableLocation;
|
|
623
628
|
if (disableLocation == null) return config;
|
|
624
|
-
return (0,
|
|
629
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["ios", async (config) => {
|
|
625
630
|
await updatePodfileLocationModule(path.join(config.modRequest.projectRoot, "ios"), disableLocation);
|
|
626
631
|
return config;
|
|
627
632
|
}]);
|
|
628
633
|
};
|
|
629
634
|
const withOneSignalNSE = (config, props) => {
|
|
630
|
-
return (0,
|
|
635
|
+
return (0, expo_config_plugins.withDangerousMod)(config, ["ios", async (config) => {
|
|
631
636
|
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
632
637
|
const sourceDir = path.join(pluginDir, "../serviceExtensionFiles/");
|
|
633
638
|
const iosPath = path.join(config.modRequest.projectRoot, "ios");
|
|
@@ -657,7 +662,7 @@ const withOneSignalNSE = (config, props) => {
|
|
|
657
662
|
}]);
|
|
658
663
|
};
|
|
659
664
|
const withOneSignalXcodeProject = (config, props) => {
|
|
660
|
-
return (0,
|
|
665
|
+
return (0, expo_config_plugins.withXcodeProject)(config, (newConfig) => {
|
|
661
666
|
const xcodeProject = newConfig.modResults;
|
|
662
667
|
const nseBundleId = `${config.ios?.bundleIdentifier}.${props.nseBundleIdentifier ?? "OneSignalNotificationServiceExtension"}`;
|
|
663
668
|
const devTeam = resolveDevTeam(config, props);
|
|
@@ -687,7 +692,7 @@ const withOneSignalXcodeProject = (config, props) => {
|
|
|
687
692
|
for (const key in configurations) if (typeof configurations[key].buildSettings !== "undefined" && configurations[key].buildSettings.PRODUCT_NAME == `"OneSignalNotificationServiceExtension"`) {
|
|
688
693
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
689
694
|
buildSettingsObj.DEVELOPMENT_TEAM = devTeam;
|
|
690
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = props?.iPhoneDeploymentTarget ?? "
|
|
695
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = props?.iPhoneDeploymentTarget ?? "15.0";
|
|
691
696
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
692
697
|
buildSettingsObj.SWIFT_VERSION = "5.0";
|
|
693
698
|
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${NSE_TARGET_NAME}/${NSE_TARGET_NAME}.entitlements`;
|
|
@@ -700,10 +705,10 @@ const withOneSignalXcodeProject = (config, props) => {
|
|
|
700
705
|
};
|
|
701
706
|
const withSoundFiles = (config, onesignalProps) => {
|
|
702
707
|
if (!onesignalProps.sounds) return config;
|
|
703
|
-
return (0,
|
|
708
|
+
return (0, expo_config_plugins.withXcodeProject)(config, (config) => {
|
|
704
709
|
const projectRoot = config.modRequest.projectRoot;
|
|
705
710
|
const projectName = config.modRequest.projectName;
|
|
706
|
-
const sourceRoot =
|
|
711
|
+
const sourceRoot = expo_config_plugins.IOSConfig.Paths.getSourceRoot(projectRoot);
|
|
707
712
|
let project = config.modResults;
|
|
708
713
|
for (const soundFile of onesignalProps.sounds) {
|
|
709
714
|
const fileName = path.basename(soundFile);
|
|
@@ -711,7 +716,7 @@ const withSoundFiles = (config, onesignalProps) => {
|
|
|
711
716
|
const destPath = path.resolve(sourceRoot, fileName);
|
|
712
717
|
OneSignalLog.log(`Copying sound file ${soundFile} to iOS project`);
|
|
713
718
|
fs.copyFileSync(sourcePath, destPath);
|
|
714
|
-
if (!project.hasFile(`${projectName}/${fileName}`)) project =
|
|
719
|
+
if (!project.hasFile(`${projectName}/${fileName}`)) project = expo_config_plugins.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
715
720
|
filepath: `${projectName}/${fileName}`,
|
|
716
721
|
groupName: projectName,
|
|
717
722
|
project,
|
|
@@ -738,8 +743,7 @@ const withOneSignalIos = (config, props) => {
|
|
|
738
743
|
if (!props.disableNSE || props.liveActivities) config = withEasManagedCredentials(config, props);
|
|
739
744
|
return config;
|
|
740
745
|
};
|
|
741
|
-
|
|
742
|
-
//#region src/onesignal/withOneSignal.ts
|
|
746
|
+
// src/onesignal/withOneSignal.ts
|
|
743
747
|
const withOneSignal = (config, props) => {
|
|
744
748
|
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.");
|
|
745
749
|
validatePluginProps(props);
|
|
@@ -747,5 +751,4 @@ const withOneSignal = (config, props) => {
|
|
|
747
751
|
config = withOneSignalAndroid(config, props);
|
|
748
752
|
return config;
|
|
749
753
|
};
|
|
750
|
-
//#endregion
|
|
751
754
|
module.exports = withOneSignal;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { t as OneSignalPluginProps } from "./types-
|
|
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];
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-DC6uSYcE.js";
|
|
2
|
+
declare const withOneSignal: (props: OneSignalPluginProps) => [string, OneSignalPluginProps];
|
|
8
3
|
export = withOneSignal;
|
package/dist/plugin.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Configuration for the iOS Widget Extension target that hosts Live Activities.
|
|
4
3
|
*/
|
|
@@ -38,7 +37,7 @@ type OneSignalPluginProps = {
|
|
|
38
37
|
devTeam?: string;
|
|
39
38
|
/**
|
|
40
39
|
* (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: "
|
|
40
|
+
* the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: "15.0".
|
|
42
41
|
*/
|
|
43
42
|
iPhoneDeploymentTarget?: string;
|
|
44
43
|
/**
|
|
@@ -84,6 +83,13 @@ type OneSignalPluginProps = {
|
|
|
84
83
|
* OneSignal.Location APIs will not collect location and will no-op or return false.
|
|
85
84
|
*/
|
|
86
85
|
disableLocation?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* (optional, Android only) If true, sets `firebase_messaging_installation_id_enabled=true` in the Android manifest so
|
|
88
|
+
* push registration uses the Firebase Installation ID (FID) path instead of the legacy FCM token API.
|
|
89
|
+
* Requires the app's own Firebase project (`android.googleServicesFile`), `firebase-messaging` 25.1.0+
|
|
90
|
+
* and `react-native-onesignal` 5.5.16+ (OneSignal Android SDK 5.11.0+). If unset, the manifest is untouched; if false, the app's own entry is removed.
|
|
91
|
+
*/
|
|
92
|
+
enableFirebaseInstallationId?: boolean;
|
|
87
93
|
/**
|
|
88
94
|
* (optional) An array of local paths to custom notification sound files (.wav only).
|
|
89
95
|
* Files are added to the iOS app bundle and Android res/raw/.
|
|
@@ -97,5 +103,4 @@ type OneSignalPluginProps = {
|
|
|
97
103
|
*/
|
|
98
104
|
liveActivities?: OneSignalLiveActivityProps;
|
|
99
105
|
};
|
|
100
|
-
//#endregion
|
|
101
106
|
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.8.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",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "vp pack",
|
|
41
41
|
"format:spotless": "./examples/demo/android/gradlew spotlessApply",
|
|
42
|
-
"format": "vp fmt &&
|
|
42
|
+
"format": "vp fmt && vp run format:spotless",
|
|
43
43
|
"format:check:spotless": "./examples/demo/android/gradlew spotlessCheck",
|
|
44
|
-
"format:check": "vp fmt --check &&
|
|
45
|
-
"lint": "vp check src &&
|
|
46
|
-
"lint:fix": "vp check --fix src &&
|
|
44
|
+
"format:check": "vp fmt --check && vp run format:check:spotless",
|
|
45
|
+
"lint": "vp check src && vp run format:check",
|
|
46
|
+
"lint:fix": "vp check --fix src && vp run format",
|
|
47
47
|
"test": "vp test"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
@@ -51,13 +51,23 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^22.19.3",
|
|
54
|
-
"@vitest/coverage-v8": "
|
|
55
|
-
"typescript": "^
|
|
56
|
-
"vite
|
|
54
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
55
|
+
"typescript": "^7.0.2",
|
|
56
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
57
|
+
"vite-plus": "1.4.0"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
60
|
"expo": ">=53.0.0",
|
|
60
61
|
"react-native-onesignal": ">=5.0.0"
|
|
61
62
|
},
|
|
62
|
-
"
|
|
63
|
+
"overrides": {
|
|
64
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0"
|
|
65
|
+
},
|
|
66
|
+
"devEngines": {
|
|
67
|
+
"packageManager": {
|
|
68
|
+
"name": "bun",
|
|
69
|
+
"version": "1.4.4",
|
|
70
|
+
"onFail": "warn"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
63
73
|
}
|