onesignal-expo-plugin 1.2.0 → 1.3.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/CHANGELOG.md +5 -0
- package/README.md +3 -1
- package/build/onesignal/withOneSignalIos.js +9 -4
- package/onesignal/withOneSignalIos.ts +10 -4
- package/package.json +1 -1
- package/types/types.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## November 2022
|
|
5
|
+
### `1.3.0` - 11/30/22
|
|
6
|
+
#### Changes
|
|
7
|
+
- Add `iosNSEFilePath` configuration options to the plugin, which allows an app to specify a custom iOS Notification Service Extension.
|
|
8
|
+
|
|
4
9
|
## October 2022
|
|
5
10
|
### `1.2.0` - 10/25/22
|
|
6
11
|
#### Changes
|
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ You can pass props to the plugin config object to configure:
|
|
|
86
86
|
| `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: `"12.0"`. |
|
|
87
87
|
| `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. |
|
|
88
88
|
| `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. |
|
|
89
|
+
| `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/support/serviceExtensionFiles/NotificationService.m), then altered to support any custom logic required. e.g: `"./assets/NotificationService.m"`. |
|
|
89
90
|
|
|
90
91
|
### OneSignal App ID
|
|
91
92
|
Add your OneSignal App ID to your [Expo constants via the `extra` param](https://docs.expo.dev/versions/latest/config/app/):
|
|
@@ -117,9 +118,10 @@ OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");
|
|
|
117
118
|
In your configuration file, make sure you set:
|
|
118
119
|
|
|
119
120
|
| Property | Details |
|
|
120
|
-
|
|
121
|
+
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
121
122
|
| `version` | Your app version. Corresponds to `CFBundleShortVersionString` on iOS. This value will be used in your NSE* target's plist file. |
|
|
122
123
|
| `ios.buildNumber` | Build number for your iOS standalone app. Corresponds to `CFBundleVersion` and must match Apple's specified format. This value will be used in your NSE* target's plist file. |
|
|
124
|
+
| `ios.bundleIdentifier` | Bundle identifier for your iOS standalone app. Corresponds to `CFBundleIdentifier`. This value will be used in your NSE* target's plist and entitlements file. |
|
|
123
125
|
|
|
124
126
|
\* NSE = Notification Service Extension. Learn more about the NSE [here](https://documentation.onesignal.com/docs/service-extensions).
|
|
125
127
|
|
|
@@ -105,7 +105,8 @@ const withOneSignalNSE = (config, onesignalProps) => {
|
|
|
105
105
|
bundleVersion: (_b = props.ios) === null || _b === void 0 ? void 0 : _b.buildNumber,
|
|
106
106
|
bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
|
|
107
107
|
mode: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.mode,
|
|
108
|
-
iPhoneDeploymentTarget: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.iPhoneDeploymentTarget
|
|
108
|
+
iPhoneDeploymentTarget: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.iPhoneDeploymentTarget,
|
|
109
|
+
iosNSEFilePath: onesignalProps.iosNSEFilePath
|
|
109
110
|
};
|
|
110
111
|
// support for monorepos where node_modules can be up to 5 parents
|
|
111
112
|
// above the project directory.
|
|
@@ -133,13 +134,13 @@ const withOneSignalIos = (config, props) => {
|
|
|
133
134
|
};
|
|
134
135
|
exports.withOneSignalIos = withOneSignalIos;
|
|
135
136
|
function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
136
|
-
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options;
|
|
137
|
+
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget, iosNSEFilePath } = options;
|
|
137
138
|
// not awaiting in order to not block main thread
|
|
138
139
|
(0, updatePodfile_1.updatePodfile)(iosPath).catch(err => { OneSignalLog_1.OneSignalLog.error(err); });
|
|
139
140
|
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
141
|
+
const sourceFile = "NotificationService.m";
|
|
140
142
|
const extFiles = [
|
|
141
143
|
"NotificationService.h",
|
|
142
|
-
"NotificationService.m",
|
|
143
144
|
`${iosConstants_1.NSE_TARGET_NAME}.entitlements`,
|
|
144
145
|
`${iosConstants_1.NSE_TARGET_NAME}-Info.plist`
|
|
145
146
|
];
|
|
@@ -156,13 +157,17 @@ function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
|
156
157
|
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${extFile}`;
|
|
157
158
|
await FileManager_1.FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
|
|
158
159
|
}
|
|
160
|
+
// Copy NSE source file either from configuration-provided location, falling back to the default one.
|
|
161
|
+
const sourcePath = iosNSEFilePath !== null && iosNSEFilePath !== void 0 ? iosNSEFilePath : `${sourceDir}${sourceFile}`;
|
|
162
|
+
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${sourceFile}`;
|
|
163
|
+
await FileManager_1.FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
159
164
|
/* MODIFY COPIED EXTENSION FILES */
|
|
160
165
|
const nseUpdater = new NseUpdaterManager_1.default(iosPath);
|
|
161
166
|
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`);
|
|
162
167
|
await nseUpdater.updateNSEBundleVersion(bundleVersion !== null && bundleVersion !== void 0 ? bundleVersion : iosConstants_1.DEFAULT_BUNDLE_VERSION);
|
|
163
168
|
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion !== null && bundleShortVersion !== void 0 ? bundleShortVersion : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
164
169
|
// Create new PBXGroup for the extension
|
|
165
|
-
const extGroup = xcodeProject.addPbxGroup(extFiles, iosConstants_1.NSE_TARGET_NAME, iosConstants_1.NSE_TARGET_NAME);
|
|
170
|
+
const extGroup = xcodeProject.addPbxGroup([...extFiles, sourceFile], iosConstants_1.NSE_TARGET_NAME, iosConstants_1.NSE_TARGET_NAME);
|
|
166
171
|
// Add the new PBXGroup to the top level group. This makes the
|
|
167
172
|
// files / folder appear in the file explorer in Xcode.
|
|
168
173
|
const groups = xcodeProject.hash.project.objects["PBXGroup"];
|
|
@@ -102,7 +102,8 @@ const withOneSignalNSE: ConfigPlugin<OneSignalPluginProps> = (config, onesignalP
|
|
|
102
102
|
bundleVersion: props.ios?.buildNumber,
|
|
103
103
|
bundleShortVersion: props?.version,
|
|
104
104
|
mode: onesignalProps?.mode,
|
|
105
|
-
iPhoneDeploymentTarget: onesignalProps?.iPhoneDeploymentTarget
|
|
105
|
+
iPhoneDeploymentTarget: onesignalProps?.iPhoneDeploymentTarget,
|
|
106
|
+
iosNSEFilePath: onesignalProps.iosNSEFilePath
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
// support for monorepos where node_modules can be up to 5 parents
|
|
@@ -145,16 +146,16 @@ export function xcodeProjectAddNse(
|
|
|
145
146
|
options: PluginOptions,
|
|
146
147
|
sourceDir: string
|
|
147
148
|
): void {
|
|
148
|
-
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options;
|
|
149
|
+
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget, iosNSEFilePath } = options;
|
|
149
150
|
|
|
150
151
|
// not awaiting in order to not block main thread
|
|
151
152
|
updatePodfile(iosPath).catch(err => { OneSignalLog.error(err) });
|
|
152
153
|
|
|
153
154
|
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
154
155
|
|
|
156
|
+
const sourceFile = "NotificationService.m"
|
|
155
157
|
const extFiles = [
|
|
156
158
|
"NotificationService.h",
|
|
157
|
-
"NotificationService.m",
|
|
158
159
|
`${NSE_TARGET_NAME}.entitlements`,
|
|
159
160
|
`${NSE_TARGET_NAME}-Info.plist`
|
|
160
161
|
];
|
|
@@ -176,6 +177,11 @@ export function xcodeProjectAddNse(
|
|
|
176
177
|
await FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
// Copy NSE source file either from configuration-provided location, falling back to the default one.
|
|
181
|
+
const sourcePath = iosNSEFilePath ?? `${sourceDir}${sourceFile}`
|
|
182
|
+
const targetFile = `${iosPath}/${NSE_TARGET_NAME}/${sourceFile}`;
|
|
183
|
+
await FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
184
|
+
|
|
179
185
|
/* MODIFY COPIED EXTENSION FILES */
|
|
180
186
|
const nseUpdater = new NseUpdaterManager(iosPath);
|
|
181
187
|
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`)
|
|
@@ -183,7 +189,7 @@ export function xcodeProjectAddNse(
|
|
|
183
189
|
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion ?? DEFAULT_BUNDLE_SHORT_VERSION);
|
|
184
190
|
|
|
185
191
|
// Create new PBXGroup for the extension
|
|
186
|
-
const extGroup = xcodeProject.addPbxGroup(extFiles, NSE_TARGET_NAME, NSE_TARGET_NAME);
|
|
192
|
+
const extGroup = xcodeProject.addPbxGroup([...extFiles, sourceFile], NSE_TARGET_NAME, NSE_TARGET_NAME);
|
|
187
193
|
|
|
188
194
|
// Add the new PBXGroup to the top level group. This makes the
|
|
189
195
|
// files / folder appear in the file explorer in Xcode.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.",
|
|
5
5
|
"main": "./app.plugin.js",
|
|
6
6
|
"scripts": {
|
package/types/types.ts
CHANGED
|
@@ -28,6 +28,13 @@
|
|
|
28
28
|
* (optional) The large notification icons for Android. Images will be automatically scaled up/down to 256x256.
|
|
29
29
|
*/
|
|
30
30
|
largeIcons?: string[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* (optional) The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy
|
|
34
|
+
* of the default NSE found at (support/serviceExtensionFiles/NotificationService.m, then altered to support any custom
|
|
35
|
+
* logic required.
|
|
36
|
+
*/
|
|
37
|
+
iosNSEFilePath?: string;
|
|
31
38
|
};
|
|
32
39
|
|
|
33
40
|
/**
|
|
@@ -41,7 +48,8 @@ export type PluginOptions = {
|
|
|
41
48
|
bundleVersion?: string,
|
|
42
49
|
bundleShortVersion?: string,
|
|
43
50
|
bundleIdentifier?: string,
|
|
44
|
-
iPhoneDeploymentTarget?: string
|
|
51
|
+
iPhoneDeploymentTarget?: string,
|
|
52
|
+
iosNSEFilePath?: string
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
export enum Mode {
|