onesignal-expo-plugin 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/{types-DC6uSYcE.d.ts → types-DJnWMAKM.d.ts} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,9 +106,9 @@ properties.
|
|
|
106
106
|
|
|
107
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
108
|
|
|
109
|
-
- Use `react-native-onesignal` 5.5.16 or newer (OneSignal Android SDK 5.11.0+).
|
|
109
|
+
- Use `react-native-onesignal` 5.5.16 or newer (OneSignal Android SDK 5.11.0+). Prebuild fails on older versions.
|
|
110
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.
|
|
111
|
+
- Resolve `com.google.firebase:firebase-messaging` 25.1.2 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
112
|
- Build with a development build or `expo run:android`. Expo Go is not supported.
|
|
113
113
|
|
|
114
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.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as OneSignalPluginProps } from "./types-
|
|
1
|
+
import { t as OneSignalPluginProps } from "./types-DJnWMAKM.js";
|
|
2
2
|
import { ConfigPlugin } from "expo/config-plugins";
|
|
3
3
|
declare const withOneSignal: ConfigPlugin<OneSignalPluginProps>;
|
|
4
4
|
export { type OneSignalPluginProps, withOneSignal as default };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ let path = require("path");
|
|
|
23
23
|
path = __toESM(path);
|
|
24
24
|
let fs = require("fs");
|
|
25
25
|
fs = __toESM(fs);
|
|
26
|
+
let module$1 = require("module");
|
|
26
27
|
let _expo_image_utils = require("@expo/image-utils");
|
|
27
28
|
let expo_config_plugins = require("expo/config-plugins");
|
|
28
29
|
let fs_promises = require("fs/promises");
|
|
@@ -177,6 +178,7 @@ function resolveDevTeam(config, props) {
|
|
|
177
178
|
const RESOURCE_ROOT_PATH = "android/app/src/main/res/";
|
|
178
179
|
const ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY = "onesignal.disableLocation";
|
|
179
180
|
const FIREBASE_INSTALLATION_ID_META_DATA = "firebase_messaging_installation_id_enabled";
|
|
181
|
+
const MIN_FID_REACT_NATIVE_ONESIGNAL_VERSION = "5.5.16";
|
|
180
182
|
const SMALL_ICON_DIRS_TO_SIZE = {
|
|
181
183
|
"drawable-mdpi": 24,
|
|
182
184
|
"drawable-hdpi": 36,
|
|
@@ -240,12 +242,36 @@ const withFirebaseInstallationIdManifest = (config, onesignalProps) => {
|
|
|
240
242
|
if (enabled == null) return config;
|
|
241
243
|
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
244
|
return (0, expo_config_plugins.withAndroidManifest)(config, (config) => {
|
|
245
|
+
if (enabled) assertFidCapableReactNativeOneSignal(config.modRequest?.projectRoot);
|
|
243
246
|
const mainApplication = expo_config_plugins.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
|
|
244
247
|
if (enabled) expo_config_plugins.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, FIREBASE_INSTALLATION_ID_META_DATA, "true");
|
|
245
248
|
else expo_config_plugins.AndroidConfig.Manifest.removeMetaDataItemFromMainApplication(mainApplication, FIREBASE_INSTALLATION_ID_META_DATA);
|
|
246
249
|
return config;
|
|
247
250
|
});
|
|
248
251
|
};
|
|
252
|
+
function assertFidCapableReactNativeOneSignal(projectRoot) {
|
|
253
|
+
if (!projectRoot) return;
|
|
254
|
+
const version = getInstalledReactNativeOneSignalVersion(projectRoot);
|
|
255
|
+
if (version && compareVersions(version, "5.5.16") < 0) throw new Error(`onesignal-expo-plugin: 'enableFirebaseInstallationId' requires react-native-onesignal ${MIN_FID_REACT_NATIVE_ONESIGNAL_VERSION} or newer, but ${version} is installed. Upgrade react-native-onesignal or remove 'enableFirebaseInstallationId'.`);
|
|
256
|
+
}
|
|
257
|
+
function getInstalledReactNativeOneSignalVersion(projectRoot) {
|
|
258
|
+
try {
|
|
259
|
+
const packageJsonPath = (0, module$1.createRequire)((0, path.resolve)(projectRoot, "package.json")).resolve("react-native-onesignal/package.json");
|
|
260
|
+
return JSON.parse((0, fs.readFileSync)(packageJsonPath, "utf8")).version;
|
|
261
|
+
} catch {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function compareVersions(a, b) {
|
|
266
|
+
const toParts = (version) => version.split("-")[0].split(".").map((part) => parseInt(part, 10) || 0);
|
|
267
|
+
const left = toParts(a);
|
|
268
|
+
const right = toParts(b);
|
|
269
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
270
|
+
const diff = (left[i] ?? 0) - (right[i] ?? 0);
|
|
271
|
+
if (diff !== 0) return diff;
|
|
272
|
+
}
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
249
275
|
async function saveIconsArrayAsync(projectRoot, icons, dirsToSize, defaultName) {
|
|
250
276
|
for (let i = 0; i < icons.length; i++) {
|
|
251
277
|
const outputName = i === 0 ? defaultName : void 0;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ type OneSignalPluginProps = {
|
|
|
86
86
|
/**
|
|
87
87
|
* (optional, Android only) If true, sets `firebase_messaging_installation_id_enabled=true` in the Android manifest so
|
|
88
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.
|
|
89
|
+
* Requires the app's own Firebase project (`android.googleServicesFile`), `firebase-messaging` 25.1.2+
|
|
90
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
91
|
*/
|
|
92
92
|
enableFirebaseInstallationId?: boolean;
|