onesignal-expo-plugin 2.0.4 → 2.1.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 +1 -0
- package/build/onesignal/withOneSignalAndroid.js +3 -3
- package/build/onesignal/withOneSignalIos.js +52 -28
- package/build/support/NseUpdaterManager.js +7 -0
- package/build/support/eas/getEasManagedCredentialsConfigExtra.js +11 -10
- package/build/support/helpers.js +10 -5
- package/build/support/iosConstants.js +9 -5
- package/build/support/updatePodfile.js +2 -2
- package/build/types/types.js +8 -7
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -87,6 +87,7 @@ You can pass props to the plugin config object to configure:
|
|
|
87
87
|
| `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. |
|
|
88
88
|
| `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
|
|
89
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"`. |
|
|
90
|
+
| `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
91
|
|
|
91
92
|
### OneSignal App ID
|
|
92
93
|
|
|
@@ -17,11 +17,11 @@ const SMALL_ICON_DIRS_TO_SIZE = {
|
|
|
17
17
|
'drawable-hdpi': 36,
|
|
18
18
|
'drawable-xhdpi': 48,
|
|
19
19
|
'drawable-xxhdpi': 72,
|
|
20
|
-
'drawable-xxxhdpi': 96
|
|
20
|
+
'drawable-xxxhdpi': 96,
|
|
21
21
|
};
|
|
22
22
|
// The name of each large icon folder resource, and the icon size for that folder.
|
|
23
23
|
const LARGE_ICON_DIRS_TO_SIZE = {
|
|
24
|
-
'drawable-xxxhdpi': 256
|
|
24
|
+
'drawable-xxxhdpi': 256,
|
|
25
25
|
};
|
|
26
26
|
const withSmallIcons = (config, onesignalProps) => {
|
|
27
27
|
if (!onesignalProps.smallIcons && !config.notification?.icon) {
|
|
@@ -83,7 +83,7 @@ async function saveIconsArrayAsync(projectRoot, icons, dirsToSize) {
|
|
|
83
83
|
}
|
|
84
84
|
async function saveIconAsync(icon, projectRoot, dirsToSize) {
|
|
85
85
|
const name = (0, path_1.parse)(icon).name;
|
|
86
|
-
OneSignalLog_1.OneSignalLog.log(
|
|
86
|
+
OneSignalLog_1.OneSignalLog.log('Saving icon ' + icon + ' as drawable resource ' + name);
|
|
87
87
|
for (const iconResourceDir in dirsToSize) {
|
|
88
88
|
const path = (0, path_1.resolve)(projectRoot, RESOURCE_ROOT_PATH, iconResourceDir);
|
|
89
89
|
if (!(0, fs_1.existsSync)(path)) {
|
|
@@ -63,7 +63,7 @@ const withAppEnvironment = (config, onesignalProps) => {
|
|
|
63
63
|
"mode" can be either "development" or "production".
|
|
64
64
|
Please see onesignal-expo-plugin's README.md for more details.`);
|
|
65
65
|
}
|
|
66
|
-
newConfig.modResults[
|
|
66
|
+
newConfig.modResults['aps-environment'] = onesignalProps.mode;
|
|
67
67
|
return newConfig;
|
|
68
68
|
});
|
|
69
69
|
};
|
|
@@ -72,7 +72,7 @@ const withAppEnvironment = (config, onesignalProps) => {
|
|
|
72
72
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
73
73
|
*/
|
|
74
74
|
const withRemoteNotificationsPermissions = (config) => {
|
|
75
|
-
const BACKGROUND_MODE_KEYS = [
|
|
75
|
+
const BACKGROUND_MODE_KEYS = ['remote-notification'];
|
|
76
76
|
return (0, config_plugins_1.withInfoPlist)(config, (newConfig) => {
|
|
77
77
|
if (!Array.isArray(newConfig.modResults.UIBackgroundModes)) {
|
|
78
78
|
newConfig.modResults.UIBackgroundModes = [];
|
|
@@ -89,14 +89,14 @@ const withRemoteNotificationsPermissions = (config) => {
|
|
|
89
89
|
* Add "App Group" permission
|
|
90
90
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps (step 4.4)
|
|
91
91
|
*/
|
|
92
|
-
const withAppGroupPermissions = (config) => {
|
|
93
|
-
const APP_GROUP_KEY =
|
|
94
|
-
return (0, config_plugins_1.withEntitlementsPlist)(config, newConfig => {
|
|
92
|
+
const withAppGroupPermissions = (config, props) => {
|
|
93
|
+
const APP_GROUP_KEY = 'com.apple.security.application-groups';
|
|
94
|
+
return (0, config_plugins_1.withEntitlementsPlist)(config, (newConfig) => {
|
|
95
95
|
if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) {
|
|
96
96
|
newConfig.modResults[APP_GROUP_KEY] = [];
|
|
97
97
|
}
|
|
98
98
|
const modResultsArray = newConfig.modResults[APP_GROUP_KEY];
|
|
99
|
-
const entitlement =
|
|
99
|
+
const entitlement = (0, iosConstants_1.getAppGroupIdentifier)(newConfig?.ios?.bundleIdentifier || '', props?.appGroupName);
|
|
100
100
|
if (modResultsArray.indexOf(entitlement) !== -1) {
|
|
101
101
|
return newConfig;
|
|
102
102
|
}
|
|
@@ -104,9 +104,21 @@ const withAppGroupPermissions = (config) => {
|
|
|
104
104
|
return newConfig;
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Add OneSignal_app_groups_key to Info.plist when a custom app group name is provided.
|
|
109
|
+
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
110
|
+
*/
|
|
111
|
+
const withCustomAppGroupsKey = (config, props) => {
|
|
112
|
+
return (0, config_plugins_1.withInfoPlist)(config, (newConfig) => {
|
|
113
|
+
if (props?.appGroupName) {
|
|
114
|
+
newConfig.modResults.OneSignal_app_groups_key = props.appGroupName;
|
|
115
|
+
}
|
|
116
|
+
return newConfig;
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const withEasManagedCredentials = (config, props) => {
|
|
108
120
|
(0, assert_1.default)(config.ios?.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.");
|
|
109
|
-
config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config);
|
|
121
|
+
config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config, props?.appGroupName);
|
|
110
122
|
return config;
|
|
111
123
|
};
|
|
112
124
|
const withOneSignalPodfile = (config) => {
|
|
@@ -114,20 +126,22 @@ const withOneSignalPodfile = (config) => {
|
|
|
114
126
|
'ios',
|
|
115
127
|
async (config) => {
|
|
116
128
|
// not awaiting in order to not block main thread
|
|
117
|
-
const iosRoot = path.join(config.modRequest.projectRoot,
|
|
118
|
-
(0, updatePodfile_1.updatePodfile)(iosRoot).catch(err => {
|
|
129
|
+
const iosRoot = path.join(config.modRequest.projectRoot, 'ios');
|
|
130
|
+
(0, updatePodfile_1.updatePodfile)(iosRoot).catch((err) => {
|
|
131
|
+
OneSignalLog_1.OneSignalLog.error(err);
|
|
132
|
+
});
|
|
119
133
|
return config;
|
|
120
134
|
},
|
|
121
135
|
]);
|
|
122
136
|
};
|
|
123
137
|
const withOneSignalNSE = (config, props) => {
|
|
124
138
|
// support for monorepos where node_modules can be above the project directory.
|
|
125
|
-
const pluginDir = require.resolve(
|
|
126
|
-
const sourceDir = path.join(pluginDir,
|
|
139
|
+
const pluginDir = require.resolve('onesignal-expo-plugin/package.json');
|
|
140
|
+
const sourceDir = path.join(pluginDir, '../build/support/serviceExtensionFiles/');
|
|
127
141
|
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
128
142
|
'ios',
|
|
129
143
|
async (config) => {
|
|
130
|
-
const iosPath = path.join(config.modRequest.projectRoot,
|
|
144
|
+
const iosPath = path.join(config.modRequest.projectRoot, 'ios');
|
|
131
145
|
/* COPY OVER EXTENSION FILES */
|
|
132
146
|
fs.mkdirSync(`${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`, { recursive: true });
|
|
133
147
|
for (let i = 0; i < iosConstants_1.NSE_EXT_FILES.length; i++) {
|
|
@@ -141,7 +155,11 @@ const withOneSignalNSE = (config, props) => {
|
|
|
141
155
|
await FileManager_1.FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
142
156
|
/* MODIFY COPIED EXTENSION FILES */
|
|
143
157
|
const nseUpdater = new NseUpdaterManager_1.default(iosPath);
|
|
144
|
-
|
|
158
|
+
const appGroupId = (0, iosConstants_1.getAppGroupIdentifier)(config.ios?.bundleIdentifier ?? '', props.appGroupName);
|
|
159
|
+
await nseUpdater.updateNSEEntitlements(appGroupId);
|
|
160
|
+
if (props.appGroupName) {
|
|
161
|
+
await nseUpdater.updateNSEInfoPlistAppGroupKey(props.appGroupName);
|
|
162
|
+
}
|
|
145
163
|
await nseUpdater.updateNSEBundleVersion(config.ios?.buildNumber ?? iosConstants_1.DEFAULT_BUNDLE_VERSION);
|
|
146
164
|
await nseUpdater.updateNSEBundleShortVersion(config?.version ?? iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
147
165
|
return config;
|
|
@@ -149,7 +167,7 @@ const withOneSignalNSE = (config, props) => {
|
|
|
149
167
|
]);
|
|
150
168
|
};
|
|
151
169
|
const withOneSignalXcodeProject = (config, props) => {
|
|
152
|
-
return (0, config_plugins_1.withXcodeProject)(config, newConfig => {
|
|
170
|
+
return (0, config_plugins_1.withXcodeProject)(config, (newConfig) => {
|
|
153
171
|
const xcodeProject = newConfig.modResults;
|
|
154
172
|
if (xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) {
|
|
155
173
|
OneSignalLog_1.OneSignalLog.log(`${iosConstants_1.NSE_TARGET_NAME} already exists in project. Skipping...`);
|
|
@@ -159,9 +177,11 @@ const withOneSignalXcodeProject = (config, props) => {
|
|
|
159
177
|
const extGroup = xcodeProject.addPbxGroup([...iosConstants_1.NSE_EXT_FILES, iosConstants_1.NSE_SOURCE_FILE], iosConstants_1.NSE_TARGET_NAME, iosConstants_1.NSE_TARGET_NAME);
|
|
160
178
|
// Add the new PBXGroup to the top level group. This makes the
|
|
161
179
|
// files / folder appear in the file explorer in Xcode.
|
|
162
|
-
const groups = xcodeProject.hash.project.objects[
|
|
180
|
+
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
163
181
|
Object.keys(groups).forEach(function (key) {
|
|
164
|
-
if (typeof groups[key] ===
|
|
182
|
+
if (typeof groups[key] === 'object' &&
|
|
183
|
+
groups[key].name === undefined &&
|
|
184
|
+
groups[key].path === undefined) {
|
|
165
185
|
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
166
186
|
}
|
|
167
187
|
});
|
|
@@ -170,38 +190,42 @@ const withOneSignalXcodeProject = (config, props) => {
|
|
|
170
190
|
// An upstream fix should be made to the code referenced in this link:
|
|
171
191
|
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
|
|
172
192
|
const projObjects = xcodeProject.hash.project.objects;
|
|
173
|
-
projObjects['PBXTargetDependency'] =
|
|
174
|
-
|
|
193
|
+
projObjects['PBXTargetDependency'] =
|
|
194
|
+
projObjects['PBXTargetDependency'] || {};
|
|
195
|
+
projObjects['PBXContainerItemProxy'] =
|
|
196
|
+
projObjects['PBXTargetDependency'] || {};
|
|
175
197
|
// Add the NSE target
|
|
176
198
|
// This adds PBXTargetDependency and PBXContainerItemProxy for you
|
|
177
|
-
const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME,
|
|
199
|
+
const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, 'app_extension', iosConstants_1.NSE_TARGET_NAME, `${config.ios?.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`);
|
|
178
200
|
// Add build phases to the new target
|
|
179
|
-
xcodeProject.addBuildPhase([
|
|
180
|
-
xcodeProject.addBuildPhase([],
|
|
181
|
-
xcodeProject.addBuildPhase([],
|
|
201
|
+
xcodeProject.addBuildPhase(['NotificationService.m'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
|
|
202
|
+
xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
|
|
203
|
+
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
|
|
182
204
|
// Edit the Deployment info of the new Target, only IphoneOS and Targeted Device Family
|
|
183
205
|
// However, can be more
|
|
184
206
|
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
|
|
185
207
|
for (const key in configurations) {
|
|
186
|
-
if (typeof configurations[key].buildSettings !==
|
|
208
|
+
if (typeof configurations[key].buildSettings !== 'undefined' &&
|
|
187
209
|
configurations[key].buildSettings.PRODUCT_NAME == `"${iosConstants_1.NSE_TARGET_NAME}"`) {
|
|
188
210
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
189
211
|
buildSettingsObj.DEVELOPMENT_TEAM = props?.devTeam;
|
|
190
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
|
|
212
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
|
|
213
|
+
props?.iPhoneDeploymentTarget ?? iosConstants_1.IPHONEOS_DEPLOYMENT_TARGET;
|
|
191
214
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = iosConstants_1.TARGETED_DEVICE_FAMILY;
|
|
192
215
|
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_TARGET_NAME}.entitlements`;
|
|
193
|
-
buildSettingsObj.CODE_SIGN_STYLE =
|
|
216
|
+
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
194
217
|
}
|
|
195
218
|
}
|
|
196
219
|
// Add development teams to both your target and the original project
|
|
197
|
-
xcodeProject.addTargetAttribute(
|
|
198
|
-
xcodeProject.addTargetAttribute(
|
|
220
|
+
xcodeProject.addTargetAttribute('DevelopmentTeam', props?.devTeam, nseTarget);
|
|
221
|
+
xcodeProject.addTargetAttribute('DevelopmentTeam', props?.devTeam);
|
|
199
222
|
return newConfig;
|
|
200
223
|
});
|
|
201
224
|
};
|
|
202
225
|
const withOneSignalIos = (config, props) => {
|
|
203
226
|
config = withAppEnvironment(config, props);
|
|
204
227
|
config = withRemoteNotificationsPermissions(config, props);
|
|
228
|
+
config = withCustomAppGroupsKey(config, props);
|
|
205
229
|
config = withAppGroupPermissions(config, props);
|
|
206
230
|
config = withOneSignalPodfile(config, props);
|
|
207
231
|
config = withOneSignalNSE(config, props);
|
|
@@ -28,5 +28,12 @@ class NseUpdaterManager {
|
|
|
28
28
|
plistFile = plistFile.replace(iosConstants_1.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX, version);
|
|
29
29
|
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile);
|
|
30
30
|
}
|
|
31
|
+
async updateNSEInfoPlistAppGroupKey(appGroupName) {
|
|
32
|
+
const plistFilePath = `${this.nsePath}/${plistFileName}`;
|
|
33
|
+
let plistFile = await FileManager_1.FileManager.readFile(plistFilePath);
|
|
34
|
+
const appGroupEntry = `\t<key>OneSignal_app_groups_key</key>\n\t<string>${appGroupName}</string>\n</dict>\n</plist>`;
|
|
35
|
+
plistFile = plistFile.replace('</dict>\n</plist>', appGroupEntry);
|
|
36
|
+
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile);
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
exports.default = NseUpdaterManager;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = getEasManagedCredentialsConfigExtra;
|
|
4
4
|
const iosConstants_1 = require("../iosConstants");
|
|
5
|
-
function getEasManagedCredentialsConfigExtra(config) {
|
|
5
|
+
function getEasManagedCredentialsConfigExtra(config, appGroupName) {
|
|
6
6
|
return {
|
|
7
7
|
...config.extra,
|
|
8
8
|
eas: {
|
|
@@ -14,21 +14,22 @@ function getEasManagedCredentialsConfigExtra(config) {
|
|
|
14
14
|
ios: {
|
|
15
15
|
...config.extra?.eas?.build?.experimental?.ios,
|
|
16
16
|
appExtensions: [
|
|
17
|
-
...(config.extra?.eas?.build?.experimental?.ios?.appExtensions ??
|
|
17
|
+
...(config.extra?.eas?.build?.experimental?.ios?.appExtensions ??
|
|
18
|
+
[]),
|
|
18
19
|
{
|
|
19
20
|
// keep in sync with native changes in NSE
|
|
20
21
|
targetName: iosConstants_1.NSE_TARGET_NAME,
|
|
21
22
|
bundleIdentifier: `${config?.ios?.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`,
|
|
22
23
|
entitlements: {
|
|
23
24
|
'com.apple.security.application-groups': [
|
|
24
|
-
|
|
25
|
-
]
|
|
25
|
+
(0, iosConstants_1.getAppGroupIdentifier)(config?.ios?.bundleIdentifier ?? '', appGroupName),
|
|
26
|
+
],
|
|
26
27
|
},
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
33
34
|
};
|
|
34
35
|
}
|
package/build/support/helpers.js
CHANGED
|
@@ -4,27 +4,32 @@ exports.validatePluginProps = validatePluginProps;
|
|
|
4
4
|
const types_1 = require("../types/types");
|
|
5
5
|
function validatePluginProps(props) {
|
|
6
6
|
// check the type of each property
|
|
7
|
-
if (typeof props.mode !==
|
|
7
|
+
if (typeof props.mode !== 'string') {
|
|
8
8
|
throw new Error("OneSignal Expo Plugin: 'mode' must be a string.");
|
|
9
9
|
}
|
|
10
|
-
if (props.devTeam && typeof props.devTeam !==
|
|
10
|
+
if (props.devTeam && typeof props.devTeam !== 'string') {
|
|
11
11
|
throw new Error("OneSignal Expo Plugin: 'devTeam' must be a string.");
|
|
12
12
|
}
|
|
13
|
-
if (props.iPhoneDeploymentTarget &&
|
|
13
|
+
if (props.iPhoneDeploymentTarget &&
|
|
14
|
+
typeof props.iPhoneDeploymentTarget !== 'string') {
|
|
14
15
|
throw new Error("OneSignal Expo Plugin: 'iPhoneDeploymentTarget' must be a string.");
|
|
15
16
|
}
|
|
16
17
|
if (props.smallIcons && !Array.isArray(props.smallIcons)) {
|
|
17
18
|
throw new Error("OneSignal Expo Plugin: 'smallIcons' must be an array.");
|
|
18
19
|
}
|
|
19
|
-
if (props.smallIconAccentColor &&
|
|
20
|
+
if (props.smallIconAccentColor &&
|
|
21
|
+
typeof props.smallIconAccentColor !== 'string') {
|
|
20
22
|
throw new Error("OneSignal Expo Plugin: 'smallIconAccentColor' must be a string.");
|
|
21
23
|
}
|
|
22
24
|
if (props.largeIcons && !Array.isArray(props.largeIcons)) {
|
|
23
25
|
throw new Error("OneSignal Expo Plugin: 'largeIcons' must be an array.");
|
|
24
26
|
}
|
|
25
|
-
if (props.iosNSEFilePath && typeof props.iosNSEFilePath !==
|
|
27
|
+
if (props.iosNSEFilePath && typeof props.iosNSEFilePath !== 'string') {
|
|
26
28
|
throw new Error("OneSignal Expo Plugin: 'iosNSEFilePath' must be a string.");
|
|
27
29
|
}
|
|
30
|
+
if (props.appGroupName && typeof props.appGroupName !== 'string') {
|
|
31
|
+
throw new Error("OneSignal Expo Plugin: 'appGroupName' must be a string.");
|
|
32
|
+
}
|
|
28
33
|
// check for extra properties
|
|
29
34
|
const inputProps = Object.keys(props);
|
|
30
35
|
for (const prop of inputProps) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NSE_EXT_FILES = exports.NSE_SOURCE_FILE = exports.NSE_TARGET_NAME = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.DEFAULT_BUNDLE_VERSION = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.NSE_PODFILE_REGEX = exports.NSE_PODFILE_SNIPPET = exports.TARGETED_DEVICE_FAMILY = exports.IPHONEOS_DEPLOYMENT_TARGET = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.getAppGroupIdentifier = getAppGroupIdentifier;
|
|
5
|
+
exports.IPHONEOS_DEPLOYMENT_TARGET = '11.0';
|
|
5
6
|
exports.TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
6
7
|
exports.NSE_PODFILE_SNIPPET = `
|
|
7
8
|
target 'OneSignalNotificationServiceExtension' do
|
|
@@ -14,10 +15,13 @@ exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
|
14
15
|
exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
15
16
|
exports.DEFAULT_BUNDLE_VERSION = '1';
|
|
16
17
|
exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
17
|
-
exports.NSE_TARGET_NAME =
|
|
18
|
-
|
|
18
|
+
exports.NSE_TARGET_NAME = 'OneSignalNotificationServiceExtension';
|
|
19
|
+
function getAppGroupIdentifier(bundleIdentifier, customAppGroupName) {
|
|
20
|
+
return customAppGroupName ?? `group.${bundleIdentifier}.onesignal`;
|
|
21
|
+
}
|
|
22
|
+
exports.NSE_SOURCE_FILE = 'NotificationService.m';
|
|
19
23
|
exports.NSE_EXT_FILES = [
|
|
20
|
-
|
|
24
|
+
'NotificationService.h',
|
|
21
25
|
`${exports.NSE_TARGET_NAME}.entitlements`,
|
|
22
|
-
`${exports.NSE_TARGET_NAME}-Info.plist
|
|
26
|
+
`${exports.NSE_TARGET_NAME}-Info.plist`,
|
|
23
27
|
];
|
|
@@ -12,12 +12,12 @@ async function updatePodfile(iosPath) {
|
|
|
12
12
|
const podfile = await FileManager_1.FileManager.readFile(`${iosPath}/Podfile`);
|
|
13
13
|
const matches = podfile.match(iosConstants_1.NSE_PODFILE_REGEX);
|
|
14
14
|
if (matches) {
|
|
15
|
-
OneSignalLog_1.OneSignalLog.log(
|
|
15
|
+
OneSignalLog_1.OneSignalLog.log('OneSignalNotificationServiceExtension target already added to Podfile. Skipping...');
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
fs_1.default.appendFile(`${iosPath}/Podfile`, iosConstants_1.NSE_PODFILE_SNIPPET, (err) => {
|
|
19
19
|
if (err) {
|
|
20
|
-
OneSignalLog_1.OneSignalLog.error(
|
|
20
|
+
OneSignalLog_1.OneSignalLog.error('Error writing to Podfile');
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
package/build/types/types.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mode = exports.ONESIGNAL_PLUGIN_PROPS = void 0;
|
|
4
4
|
exports.ONESIGNAL_PLUGIN_PROPS = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
'mode',
|
|
6
|
+
'devTeam',
|
|
7
|
+
'iPhoneDeploymentTarget',
|
|
8
|
+
'smallIcons',
|
|
9
|
+
'largeIcons',
|
|
10
|
+
'iosNSEFilePath',
|
|
11
|
+
'smallIconAccentColor',
|
|
12
|
+
'appGroupName',
|
|
12
13
|
];
|
|
13
14
|
var Mode;
|
|
14
15
|
(function (Mode) {
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Some Changez",
|
|
5
5
|
"main": "./app.plugin.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"build",
|
|
8
8
|
"app.plugin.js"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "
|
|
11
|
+
"test": "bun test",
|
|
12
|
+
"test:coverage": "bun test --coverage",
|
|
12
13
|
"build": "bun run lint && rm -rf build && tsc && cp -a src/support/serviceExtensionFiles build/support/",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
14
|
+
"format:check": "prettier --check \"**/*.{ts,tsx}\" --ignore-path .prettierignore",
|
|
15
|
+
"format:fix": "prettier --write \"**/*.{ts,tsx}\" --ignore-path .prettierignore",
|
|
16
|
+
"lint": "oxlint src examples && bun run format:check",
|
|
17
|
+
"lint:fix": "oxlint src examples --fix && bun run format:fix"
|
|
15
18
|
},
|
|
16
19
|
"repository": {
|
|
17
20
|
"type": "git",
|
|
@@ -38,8 +41,10 @@
|
|
|
38
41
|
},
|
|
39
42
|
"homepage": "https://github.com/OneSignal/onesignal-expo-plugin#readme",
|
|
40
43
|
"devDependencies": {
|
|
44
|
+
"@types/bun": "^1.3.9",
|
|
41
45
|
"expo-module-scripts": "^5.0.8",
|
|
42
46
|
"oxlint": "^1.43.0",
|
|
47
|
+
"prettier": "^3.8.1",
|
|
43
48
|
"typescript": "^5.9.3"
|
|
44
49
|
},
|
|
45
50
|
"dependencies": {
|