onesignal-expo-plugin 2.4.0 → 2.5.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 +66 -16
- package/dist/index.d.ts +101 -0
- package/dist/index.js +711 -0
- package/package.json +43 -45
- package/serviceExtensionFiles/NotificationService.swift +32 -0
- package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/OneSignalNotificationServiceExtension-Info.plist +1 -1
- package/widgetExtensionFiles/OneSignalWidget-Info.plist +29 -0
- package/widgetExtensionFiles/OneSignalWidgetBundle.swift +9 -0
- package/widgetExtensionFiles/OneSignalWidgetLiveActivity.swift +58 -0
- package/app.plugin.js +0 -1
- package/build/onesignal/withOneSignal.d.ts +0 -8
- package/build/onesignal/withOneSignal.js +0 -20
- package/build/onesignal/withOneSignalAndroid.d.ts +0 -7
- package/build/onesignal/withOneSignalAndroid.js +0 -136
- package/build/onesignal/withOneSignalIos.d.ts +0 -13
- package/build/onesignal/withOneSignalIos.js +0 -288
- package/build/support/FileManager.d.ts +0 -9
- package/build/support/FileManager.js +0 -75
- package/build/support/NseUpdaterManager.d.ts +0 -8
- package/build/support/NseUpdaterManager.js +0 -38
- package/build/support/OneSignalLog.d.ts +0 -4
- package/build/support/OneSignalLog.js +0 -12
- package/build/support/eas/getEasManagedCredentialsConfigExtra.d.ts +0 -4
- package/build/support/eas/getEasManagedCredentialsConfigExtra.js +0 -36
- package/build/support/helpers.d.ts +0 -7
- package/build/support/helpers.js +0 -91
- package/build/support/iosConstants.d.ts +0 -12
- package/build/support/iosConstants.js +0 -23
- package/build/support/serviceExtensionFiles/NotificationService.m +0 -34
- package/build/support/updatePodfile.d.ts +0 -1
- package/build/support/updatePodfile.js +0 -20
- package/build/types/types.d.ts +0 -62
- package/build/types/types.js +0 -16
- /package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/NotificationService.h +0 -0
- /package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/OneSignalNotificationServiceExtension.entitlements +0 -0
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Expo config plugin for One Signal (iOS)
|
|
4
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.withOneSignalIos = void 0;
|
|
44
|
-
exports.resolveDevTeam = resolveDevTeam;
|
|
45
|
-
const config_plugins_1 = require("@expo/config-plugins");
|
|
46
|
-
const fs = __importStar(require("fs"));
|
|
47
|
-
const path = __importStar(require("path"));
|
|
48
|
-
const iosConstants_1 = require("../support/iosConstants");
|
|
49
|
-
const helpers_1 = require("../support/helpers");
|
|
50
|
-
const updatePodfile_1 = require("../support/updatePodfile");
|
|
51
|
-
const NseUpdaterManager_1 = __importDefault(require("../support/NseUpdaterManager"));
|
|
52
|
-
const OneSignalLog_1 = require("../support/OneSignalLog");
|
|
53
|
-
const FileManager_1 = require("../support/FileManager");
|
|
54
|
-
const getEasManagedCredentialsConfigExtra_1 = __importDefault(require("../support/eas/getEasManagedCredentialsConfigExtra"));
|
|
55
|
-
/**
|
|
56
|
-
* Add 'aps-environment' record with current environment to '<project-name>.entitlements' file
|
|
57
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
58
|
-
*/
|
|
59
|
-
const withAppEnvironment = (config, onesignalProps) => {
|
|
60
|
-
return (0, config_plugins_1.withEntitlementsPlist)(config, (newConfig) => {
|
|
61
|
-
if (onesignalProps?.mode == null) {
|
|
62
|
-
throw new Error(`
|
|
63
|
-
Missing required "mode" key in your app.json or app.config.js file for "onesignal-expo-plugin".
|
|
64
|
-
"mode" can be either "development" or "production".
|
|
65
|
-
Please see onesignal-expo-plugin's README.md for more details.`);
|
|
66
|
-
}
|
|
67
|
-
newConfig.modResults['aps-environment'] = onesignalProps.mode;
|
|
68
|
-
return newConfig;
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Add "Background Modes -> Remote notifications" and "App Group" permissions
|
|
73
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
74
|
-
*/
|
|
75
|
-
const withRemoteNotificationsPermissions = (config) => {
|
|
76
|
-
const BACKGROUND_MODE_KEYS = ['remote-notification'];
|
|
77
|
-
return (0, config_plugins_1.withInfoPlist)(config, (newConfig) => {
|
|
78
|
-
if (!Array.isArray(newConfig.modResults.UIBackgroundModes)) {
|
|
79
|
-
newConfig.modResults.UIBackgroundModes = [];
|
|
80
|
-
}
|
|
81
|
-
for (const key of BACKGROUND_MODE_KEYS) {
|
|
82
|
-
if (!newConfig.modResults.UIBackgroundModes.includes(key)) {
|
|
83
|
-
newConfig.modResults.UIBackgroundModes.push(key);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return newConfig;
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Add "App Group" permission
|
|
91
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps (step 4.4)
|
|
92
|
-
*/
|
|
93
|
-
const withAppGroupPermissions = (config, props) => {
|
|
94
|
-
const APP_GROUP_KEY = 'com.apple.security.application-groups';
|
|
95
|
-
return (0, config_plugins_1.withEntitlementsPlist)(config, (newConfig) => {
|
|
96
|
-
if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) {
|
|
97
|
-
newConfig.modResults[APP_GROUP_KEY] = [];
|
|
98
|
-
}
|
|
99
|
-
const modResultsArray = newConfig.modResults[APP_GROUP_KEY];
|
|
100
|
-
const entitlement = (0, helpers_1.getAppGroupIdentifier)(newConfig?.ios?.bundleIdentifier || '', props?.appGroupName);
|
|
101
|
-
if (modResultsArray.indexOf(entitlement) !== -1) {
|
|
102
|
-
return newConfig;
|
|
103
|
-
}
|
|
104
|
-
modResultsArray.push(entitlement);
|
|
105
|
-
return newConfig;
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Add OneSignal_app_groups_key to Info.plist when a custom app group name is provided.
|
|
110
|
-
* @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
|
|
111
|
-
*/
|
|
112
|
-
const withCustomAppGroupsKey = (config, props) => {
|
|
113
|
-
return (0, config_plugins_1.withInfoPlist)(config, (newConfig) => {
|
|
114
|
-
if (props?.appGroupName) {
|
|
115
|
-
newConfig.modResults.OneSignal_app_groups_key = props.appGroupName;
|
|
116
|
-
}
|
|
117
|
-
return newConfig;
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
const withEasManagedCredentials = (config, props) => {
|
|
121
|
-
if (!config.ios?.bundleIdentifier) {
|
|
122
|
-
return config;
|
|
123
|
-
}
|
|
124
|
-
config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config, props?.appGroupName, props?.nseBundleIdentifier);
|
|
125
|
-
return config;
|
|
126
|
-
};
|
|
127
|
-
const withOneSignalPodfile = (config) => {
|
|
128
|
-
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
129
|
-
'ios',
|
|
130
|
-
async (config) => {
|
|
131
|
-
const iosRoot = path.join(config.modRequest.projectRoot, 'ios');
|
|
132
|
-
await (0, updatePodfile_1.updatePodfile)(iosRoot);
|
|
133
|
-
return config;
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
136
|
-
};
|
|
137
|
-
const withOneSignalNSE = (config, props) => {
|
|
138
|
-
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
139
|
-
'ios',
|
|
140
|
-
async (config) => {
|
|
141
|
-
// support for monorepos where node_modules can be above the project directory.
|
|
142
|
-
const pluginDir = require.resolve('onesignal-expo-plugin/package.json');
|
|
143
|
-
const sourceDir = path.join(pluginDir, '../build/support/serviceExtensionFiles/');
|
|
144
|
-
const iosPath = path.join(config.modRequest.projectRoot, 'ios');
|
|
145
|
-
/* COPY OVER EXTENSION FILES */
|
|
146
|
-
fs.mkdirSync(`${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`, {
|
|
147
|
-
recursive: true,
|
|
148
|
-
});
|
|
149
|
-
for (const file of iosConstants_1.NSE_EXT_FILES) {
|
|
150
|
-
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${file}`;
|
|
151
|
-
await FileManager_1.FileManager.copyFile(`${sourceDir}${file}`, targetFile);
|
|
152
|
-
}
|
|
153
|
-
const sourcePath = props.iosNSEFilePath ?? `${sourceDir}${iosConstants_1.NSE_SOURCE_FILE}`;
|
|
154
|
-
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_SOURCE_FILE}`;
|
|
155
|
-
await FileManager_1.FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
156
|
-
/* MODIFY COPIED EXTENSION FILES */
|
|
157
|
-
const nseUpdater = new NseUpdaterManager_1.default(iosPath);
|
|
158
|
-
const appGroupId = (0, helpers_1.getAppGroupIdentifier)(config.ios?.bundleIdentifier ?? '', props.appGroupName);
|
|
159
|
-
await nseUpdater.updateNSEEntitlements(appGroupId);
|
|
160
|
-
if (props.appGroupName) {
|
|
161
|
-
await nseUpdater.updateNSEInfoPlistAppGroupKey(props.appGroupName);
|
|
162
|
-
}
|
|
163
|
-
await nseUpdater.updateNSEBundleVersion(config.ios?.buildNumber ?? iosConstants_1.DEFAULT_BUNDLE_VERSION);
|
|
164
|
-
await nseUpdater.updateNSEBundleShortVersion(config?.version ?? iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
165
|
-
return config;
|
|
166
|
-
},
|
|
167
|
-
]);
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Resolve the Apple development team ID. Prefers `ios.appleTeamId` from the
|
|
171
|
-
* Expo config, falling back to the plugin's deprecated `devTeam` prop.
|
|
172
|
-
*/
|
|
173
|
-
function resolveDevTeam(config, props) {
|
|
174
|
-
if (config.ios?.appleTeamId) {
|
|
175
|
-
if (props.devTeam) {
|
|
176
|
-
OneSignalLog_1.OneSignalLog.log('Warning: Both "ios.appleTeamId" and the deprecated "devTeam" plugin prop are set. ' +
|
|
177
|
-
'"devTeam" will be ignored. Remove "devTeam" from your plugin config.');
|
|
178
|
-
}
|
|
179
|
-
return config.ios.appleTeamId;
|
|
180
|
-
}
|
|
181
|
-
if (props.devTeam) {
|
|
182
|
-
OneSignalLog_1.OneSignalLog.log('Warning: The "devTeam" plugin prop is deprecated and will be removed in a future major release. ' +
|
|
183
|
-
'Set "ios.appleTeamId" in your Expo config instead.');
|
|
184
|
-
return props.devTeam;
|
|
185
|
-
}
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
const withOneSignalXcodeProject = (config, props) => {
|
|
189
|
-
return (0, config_plugins_1.withXcodeProject)(config, (newConfig) => {
|
|
190
|
-
const xcodeProject = newConfig.modResults;
|
|
191
|
-
const nseBundleId = `${config.ios?.bundleIdentifier}.${props.nseBundleIdentifier ?? iosConstants_1.NSE_TARGET_NAME}`;
|
|
192
|
-
const devTeam = resolveDevTeam(config, props);
|
|
193
|
-
if (xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) {
|
|
194
|
-
OneSignalLog_1.OneSignalLog.log(`${iosConstants_1.NSE_TARGET_NAME} already exists in project. Skipping...`);
|
|
195
|
-
return newConfig;
|
|
196
|
-
}
|
|
197
|
-
// Create new PBXGroup for the extension
|
|
198
|
-
const extGroup = xcodeProject.addPbxGroup([...iosConstants_1.NSE_EXT_FILES, iosConstants_1.NSE_SOURCE_FILE], iosConstants_1.NSE_TARGET_NAME, iosConstants_1.NSE_TARGET_NAME);
|
|
199
|
-
// Add the new PBXGroup to the top level group. This makes the
|
|
200
|
-
// files / folder appear in the file explorer in Xcode.
|
|
201
|
-
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
202
|
-
Object.keys(groups).forEach(function (key) {
|
|
203
|
-
if (typeof groups[key] === 'object' &&
|
|
204
|
-
groups[key].name === undefined &&
|
|
205
|
-
groups[key].path === undefined) {
|
|
206
|
-
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
// WORK AROUND for codeProject.addTarget BUG
|
|
210
|
-
// Xcode projects don't contain these if there is only one target
|
|
211
|
-
// An upstream fix should be made to the code referenced in this link:
|
|
212
|
-
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
|
|
213
|
-
const projObjects = xcodeProject.hash.project.objects;
|
|
214
|
-
projObjects['PBXTargetDependency'] =
|
|
215
|
-
projObjects['PBXTargetDependency'] || {};
|
|
216
|
-
projObjects['PBXContainerItemProxy'] =
|
|
217
|
-
projObjects['PBXTargetDependency'] || {};
|
|
218
|
-
// Add the NSE target
|
|
219
|
-
// This adds PBXTargetDependency and PBXContainerItemProxy for you
|
|
220
|
-
const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, 'app_extension', iosConstants_1.NSE_TARGET_NAME, nseBundleId);
|
|
221
|
-
// Add build phases to the new target
|
|
222
|
-
xcodeProject.addBuildPhase(['NotificationService.m'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
|
|
223
|
-
xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
|
|
224
|
-
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
|
|
225
|
-
// Edit the Deployment info of the new Target, only IphoneOS and Targeted Device Family
|
|
226
|
-
// However, can be more
|
|
227
|
-
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
|
|
228
|
-
for (const key in configurations) {
|
|
229
|
-
if (typeof configurations[key].buildSettings !== 'undefined' &&
|
|
230
|
-
configurations[key].buildSettings.PRODUCT_NAME == `"${iosConstants_1.NSE_TARGET_NAME}"`) {
|
|
231
|
-
const buildSettingsObj = configurations[key].buildSettings;
|
|
232
|
-
buildSettingsObj.DEVELOPMENT_TEAM = devTeam;
|
|
233
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
|
|
234
|
-
props?.iPhoneDeploymentTarget ?? iosConstants_1.IPHONEOS_DEPLOYMENT_TARGET;
|
|
235
|
-
buildSettingsObj.TARGETED_DEVICE_FAMILY = iosConstants_1.TARGETED_DEVICE_FAMILY;
|
|
236
|
-
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_TARGET_NAME}.entitlements`;
|
|
237
|
-
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// Add development teams to both your target and the original project
|
|
241
|
-
xcodeProject.addTargetAttribute('DevelopmentTeam', devTeam, nseTarget);
|
|
242
|
-
xcodeProject.addTargetAttribute('DevelopmentTeam', devTeam);
|
|
243
|
-
return newConfig;
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
const withSoundFiles = (config, onesignalProps) => {
|
|
247
|
-
if (!onesignalProps.sounds) {
|
|
248
|
-
return config;
|
|
249
|
-
}
|
|
250
|
-
return (0, config_plugins_1.withXcodeProject)(config, (config) => {
|
|
251
|
-
const projectRoot = config.modRequest.projectRoot;
|
|
252
|
-
const projectName = config.modRequest.projectName;
|
|
253
|
-
const sourceRoot = config_plugins_1.IOSConfig.Paths.getSourceRoot(projectRoot);
|
|
254
|
-
let project = config.modResults;
|
|
255
|
-
for (const soundFile of onesignalProps.sounds) {
|
|
256
|
-
const fileName = path.basename(soundFile);
|
|
257
|
-
const sourcePath = path.resolve(projectRoot, soundFile);
|
|
258
|
-
const destPath = path.resolve(sourceRoot, fileName);
|
|
259
|
-
OneSignalLog_1.OneSignalLog.log(`Copying sound file ${soundFile} to iOS project`);
|
|
260
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
261
|
-
if (!project.hasFile(`${projectName}/${fileName}`)) {
|
|
262
|
-
project = config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
263
|
-
filepath: `${projectName}/${fileName}`,
|
|
264
|
-
groupName: projectName,
|
|
265
|
-
project,
|
|
266
|
-
isBuildFile: true,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
config.modResults = project;
|
|
271
|
-
return config;
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
const withOneSignalIos = (config, props) => {
|
|
275
|
-
config = withAppEnvironment(config, props);
|
|
276
|
-
config = withRemoteNotificationsPermissions(config, props);
|
|
277
|
-
if (!props.disableNSE) {
|
|
278
|
-
config = withCustomAppGroupsKey(config, props);
|
|
279
|
-
config = withAppGroupPermissions(config, props);
|
|
280
|
-
config = withOneSignalPodfile(config, props);
|
|
281
|
-
config = withOneSignalNSE(config, props);
|
|
282
|
-
config = withOneSignalXcodeProject(config, props);
|
|
283
|
-
config = withEasManagedCredentials(config, props);
|
|
284
|
-
}
|
|
285
|
-
config = withSoundFiles(config, props);
|
|
286
|
-
return config;
|
|
287
|
-
};
|
|
288
|
-
exports.withOneSignalIos = withOneSignalIos;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FileManager contains static *awaitable* file-system functions
|
|
3
|
-
*/
|
|
4
|
-
export declare class FileManager {
|
|
5
|
-
static readFile(path: string): Promise<string>;
|
|
6
|
-
static writeFile(path: string, contents: string): Promise<void>;
|
|
7
|
-
static copyFile(path1: string, path2: string): Promise<void>;
|
|
8
|
-
static dirExists(path: string): boolean;
|
|
9
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FileManager = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const OneSignalLog_1 = require("./OneSignalLog");
|
|
39
|
-
/**
|
|
40
|
-
* FileManager contains static *awaitable* file-system functions
|
|
41
|
-
*/
|
|
42
|
-
class FileManager {
|
|
43
|
-
static async readFile(path) {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
fs.readFile(path, 'utf8', (err, data) => {
|
|
46
|
-
if (err || !data) {
|
|
47
|
-
OneSignalLog_1.OneSignalLog.error("Couldn't read file:" + path);
|
|
48
|
-
reject(err);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
resolve(data);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
static async writeFile(path, contents) {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
fs.writeFile(path, contents, 'utf8', (err) => {
|
|
58
|
-
if (err) {
|
|
59
|
-
OneSignalLog_1.OneSignalLog.error("Couldn't write file:" + path);
|
|
60
|
-
reject(err);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
resolve();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
static async copyFile(path1, path2) {
|
|
68
|
-
const fileContents = await FileManager.readFile(path1);
|
|
69
|
-
await FileManager.writeFile(path2, fileContents);
|
|
70
|
-
}
|
|
71
|
-
static dirExists(path) {
|
|
72
|
-
return fs.existsSync(path);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.FileManager = FileManager;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export default class NseUpdaterManager {
|
|
2
|
-
private nsePath;
|
|
3
|
-
constructor(iosPath: string);
|
|
4
|
-
updateNSEEntitlements(groupIdentifier: string): Promise<void>;
|
|
5
|
-
updateNSEBundleVersion(version: string): Promise<void>;
|
|
6
|
-
updateNSEBundleShortVersion(version: string): Promise<void>;
|
|
7
|
-
updateNSEInfoPlistAppGroupKey(appGroupName: string): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const FileManager_1 = require("./FileManager");
|
|
4
|
-
const iosConstants_1 = require("./iosConstants");
|
|
5
|
-
const entitlementsFileName = `${iosConstants_1.NSE_TARGET_NAME}.entitlements`;
|
|
6
|
-
const plistFileName = `${iosConstants_1.NSE_TARGET_NAME}-Info.plist`;
|
|
7
|
-
class NseUpdaterManager {
|
|
8
|
-
nsePath;
|
|
9
|
-
constructor(iosPath) {
|
|
10
|
-
this.nsePath = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`;
|
|
11
|
-
}
|
|
12
|
-
async updateNSEEntitlements(groupIdentifier) {
|
|
13
|
-
const entitlementsFilePath = `${this.nsePath}/${entitlementsFileName}`;
|
|
14
|
-
let entitlementsFile = await FileManager_1.FileManager.readFile(entitlementsFilePath);
|
|
15
|
-
entitlementsFile = entitlementsFile.replace(iosConstants_1.GROUP_IDENTIFIER_TEMPLATE_REGEX, groupIdentifier);
|
|
16
|
-
await FileManager_1.FileManager.writeFile(entitlementsFilePath, entitlementsFile);
|
|
17
|
-
}
|
|
18
|
-
async updateNSEBundleVersion(version) {
|
|
19
|
-
const plistFilePath = `${this.nsePath}/${plistFileName}`;
|
|
20
|
-
let plistFile = await FileManager_1.FileManager.readFile(plistFilePath);
|
|
21
|
-
plistFile = plistFile.replace(iosConstants_1.BUNDLE_VERSION_TEMPLATE_REGEX, version);
|
|
22
|
-
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile);
|
|
23
|
-
}
|
|
24
|
-
async updateNSEBundleShortVersion(version) {
|
|
25
|
-
const plistFilePath = `${this.nsePath}/${plistFileName}`;
|
|
26
|
-
let plistFile = await FileManager_1.FileManager.readFile(plistFilePath);
|
|
27
|
-
plistFile = plistFile.replace(iosConstants_1.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX, version);
|
|
28
|
-
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile);
|
|
29
|
-
}
|
|
30
|
-
async updateNSEInfoPlistAppGroupKey(appGroupName) {
|
|
31
|
-
const plistFilePath = `${this.nsePath}/${plistFileName}`;
|
|
32
|
-
let plistFile = await FileManager_1.FileManager.readFile(plistFilePath);
|
|
33
|
-
const appGroupEntry = `\t<key>OneSignal_app_groups_key</key>\n\t<string>${appGroupName}</string>\n</dict>\n</plist>`;
|
|
34
|
-
plistFile = plistFile.replace('</dict>\n</plist>', appGroupEntry);
|
|
35
|
-
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.default = NseUpdaterManager;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OneSignalLog = void 0;
|
|
4
|
-
class OneSignalLog {
|
|
5
|
-
static log(str) {
|
|
6
|
-
console.log(`\tonesignal-expo-plugin: ${str}`);
|
|
7
|
-
}
|
|
8
|
-
static error(str) {
|
|
9
|
-
console.error(`\tonesignal-expo-plugin: ${str}`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.OneSignalLog = OneSignalLog;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getEasManagedCredentialsConfigExtra;
|
|
4
|
-
const iosConstants_1 = require("../iosConstants");
|
|
5
|
-
const helpers_1 = require("../helpers");
|
|
6
|
-
function getEasManagedCredentialsConfigExtra(config, appGroupName, nseBundleIdentifier) {
|
|
7
|
-
const bundleId = `${config?.ios?.bundleIdentifier}.${nseBundleIdentifier ?? iosConstants_1.NSE_TARGET_NAME}`;
|
|
8
|
-
return {
|
|
9
|
-
...config.extra,
|
|
10
|
-
eas: {
|
|
11
|
-
...config.extra?.eas,
|
|
12
|
-
build: {
|
|
13
|
-
...config.extra?.eas?.build,
|
|
14
|
-
experimental: {
|
|
15
|
-
...config.extra?.eas?.build?.experimental,
|
|
16
|
-
ios: {
|
|
17
|
-
...config.extra?.eas?.build?.experimental?.ios,
|
|
18
|
-
appExtensions: [
|
|
19
|
-
...(config.extra?.eas?.build?.experimental?.ios?.appExtensions ??
|
|
20
|
-
[]),
|
|
21
|
-
{
|
|
22
|
-
targetName: iosConstants_1.NSE_TARGET_NAME,
|
|
23
|
-
bundleIdentifier: bundleId,
|
|
24
|
-
entitlements: {
|
|
25
|
-
'com.apple.security.application-groups': [
|
|
26
|
-
(0, helpers_1.getAppGroupIdentifier)(config?.ios?.bundleIdentifier ?? '', appGroupName),
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a hex color string (#RGB, #RRGGBB, or #AARRGGBB) to an
|
|
3
|
-
* 8-character ARGB hex string (no '#') expected by the OneSignal Android SDK.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseColorToARGB(color: string): string;
|
|
6
|
-
export declare function validatePluginProps(props: any): void;
|
|
7
|
-
export declare function getAppGroupIdentifier(bundleIdentifier: string, customAppGroupName?: string): string;
|
package/build/support/helpers.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseColorToARGB = parseColorToARGB;
|
|
4
|
-
exports.validatePluginProps = validatePluginProps;
|
|
5
|
-
exports.getAppGroupIdentifier = getAppGroupIdentifier;
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const types_1 = require("../types/types");
|
|
8
|
-
const HEX_COLOR_6_REGEX = /^#?[0-9A-Fa-f]{6}$/;
|
|
9
|
-
const HEX_COLOR_8_REGEX = /^#?[0-9A-Fa-f]{8}$/;
|
|
10
|
-
/**
|
|
11
|
-
* Converts a hex color string (#RGB, #RRGGBB, or #AARRGGBB) to an
|
|
12
|
-
* 8-character ARGB hex string (no '#') expected by the OneSignal Android SDK.
|
|
13
|
-
*/
|
|
14
|
-
function parseColorToARGB(color) {
|
|
15
|
-
const hex = color.replace('#', '');
|
|
16
|
-
if (HEX_COLOR_8_REGEX.test(hex)) {
|
|
17
|
-
return hex.toUpperCase();
|
|
18
|
-
}
|
|
19
|
-
if (HEX_COLOR_6_REGEX.test(hex)) {
|
|
20
|
-
return `FF${hex.toUpperCase()}`;
|
|
21
|
-
}
|
|
22
|
-
if (/^[0-9A-Fa-f]{3}$/.test(hex)) {
|
|
23
|
-
const expanded = hex
|
|
24
|
-
.split('')
|
|
25
|
-
.map((c) => c + c)
|
|
26
|
-
.join('');
|
|
27
|
-
return `FF${expanded.toUpperCase()}`;
|
|
28
|
-
}
|
|
29
|
-
throw new Error(`OneSignal Expo Plugin: 'smallIconAccentColor' must be a valid hex color (e.g. "#FF0000"), got "${color}".`);
|
|
30
|
-
}
|
|
31
|
-
function validatePluginProps(props) {
|
|
32
|
-
// check the type of each property
|
|
33
|
-
if (typeof props.mode !== 'string') {
|
|
34
|
-
throw new Error("OneSignal Expo Plugin: 'mode' must be a string.");
|
|
35
|
-
}
|
|
36
|
-
if (props.devTeam && typeof props.devTeam !== 'string') {
|
|
37
|
-
throw new Error("OneSignal Expo Plugin: 'devTeam' must be a string.");
|
|
38
|
-
}
|
|
39
|
-
if (props.iPhoneDeploymentTarget &&
|
|
40
|
-
typeof props.iPhoneDeploymentTarget !== 'string') {
|
|
41
|
-
throw new Error("OneSignal Expo Plugin: 'iPhoneDeploymentTarget' must be a string.");
|
|
42
|
-
}
|
|
43
|
-
if (props.smallIcons && !Array.isArray(props.smallIcons)) {
|
|
44
|
-
throw new Error("OneSignal Expo Plugin: 'smallIcons' must be an array.");
|
|
45
|
-
}
|
|
46
|
-
if (props.smallIconAccentColor != null) {
|
|
47
|
-
if (typeof props.smallIconAccentColor !== 'string') {
|
|
48
|
-
throw new Error("OneSignal Expo Plugin: 'smallIconAccentColor' must be a string.");
|
|
49
|
-
}
|
|
50
|
-
parseColorToARGB(props.smallIconAccentColor);
|
|
51
|
-
}
|
|
52
|
-
if (props.largeIcons && !Array.isArray(props.largeIcons)) {
|
|
53
|
-
throw new Error("OneSignal Expo Plugin: 'largeIcons' must be an array.");
|
|
54
|
-
}
|
|
55
|
-
if (props.iosNSEFilePath && typeof props.iosNSEFilePath !== 'string') {
|
|
56
|
-
throw new Error("OneSignal Expo Plugin: 'iosNSEFilePath' must be a string.");
|
|
57
|
-
}
|
|
58
|
-
if (props.appGroupName && typeof props.appGroupName !== 'string') {
|
|
59
|
-
throw new Error("OneSignal Expo Plugin: 'appGroupName' must be a string.");
|
|
60
|
-
}
|
|
61
|
-
if (props.nseBundleIdentifier &&
|
|
62
|
-
typeof props.nseBundleIdentifier !== 'string') {
|
|
63
|
-
throw new Error("OneSignal Expo Plugin: 'nseBundleIdentifier' must be a string.");
|
|
64
|
-
}
|
|
65
|
-
if (props.disableNSE !== undefined && typeof props.disableNSE !== 'boolean') {
|
|
66
|
-
throw new Error("OneSignal Expo Plugin: 'disableNSE' must be a boolean.");
|
|
67
|
-
}
|
|
68
|
-
if (props.sounds !== undefined) {
|
|
69
|
-
if (!Array.isArray(props.sounds)) {
|
|
70
|
-
throw new Error("OneSignal Expo Plugin: 'sounds' must be an array.");
|
|
71
|
-
}
|
|
72
|
-
for (const sound of props.sounds) {
|
|
73
|
-
if (typeof sound !== 'string') {
|
|
74
|
-
throw new Error("OneSignal Expo Plugin: each entry in 'sounds' must be a string path.");
|
|
75
|
-
}
|
|
76
|
-
if ((0, path_1.extname)(sound).toLowerCase() !== '.wav') {
|
|
77
|
-
throw new Error(`OneSignal Expo Plugin: sound file "${sound}" must be a .wav file. Only .wav is supported (works on both iOS and Android).`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// check for extra properties
|
|
82
|
-
const inputProps = Object.keys(props);
|
|
83
|
-
for (const prop of inputProps) {
|
|
84
|
-
if (!types_1.ONESIGNAL_PLUGIN_PROPS.includes(prop)) {
|
|
85
|
-
throw new Error(`OneSignal Expo Plugin: You have provided an invalid property "${prop}" to the OneSignal plugin.`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function getAppGroupIdentifier(bundleIdentifier, customAppGroupName) {
|
|
90
|
-
return customAppGroupName ?? `group.${bundleIdentifier}.onesignal`;
|
|
91
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const IPHONEOS_DEPLOYMENT_TARGET = "11.0";
|
|
2
|
-
export declare const TARGETED_DEVICE_FAMILY = "\"1,2\"";
|
|
3
|
-
export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
|
|
4
|
-
export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
|
|
5
|
-
export declare const BUNDLE_VERSION_TEMPLATE_REGEX: RegExp;
|
|
6
|
-
export declare const DEFAULT_BUNDLE_VERSION = "1";
|
|
7
|
-
export declare const DEFAULT_BUNDLE_SHORT_VERSION = "1.0";
|
|
8
|
-
export declare const NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";
|
|
9
|
-
export declare const NSE_SOURCE_FILE = "NotificationService.m";
|
|
10
|
-
export declare const NSE_PODFILE_SNIPPET = "\ntarget 'OneSignalNotificationServiceExtension' do\n pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'\n use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']\nend";
|
|
11
|
-
export declare const NSE_PODFILE_REGEX: RegExp;
|
|
12
|
-
export declare const NSE_EXT_FILES: string[];
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NSE_EXT_FILES = exports.NSE_PODFILE_REGEX = exports.NSE_PODFILE_SNIPPET = 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.TARGETED_DEVICE_FAMILY = exports.IPHONEOS_DEPLOYMENT_TARGET = void 0;
|
|
4
|
-
exports.IPHONEOS_DEPLOYMENT_TARGET = '11.0';
|
|
5
|
-
exports.TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
6
|
-
exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
7
|
-
exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
8
|
-
exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
9
|
-
exports.DEFAULT_BUNDLE_VERSION = '1';
|
|
10
|
-
exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
11
|
-
exports.NSE_TARGET_NAME = 'OneSignalNotificationServiceExtension';
|
|
12
|
-
exports.NSE_SOURCE_FILE = 'NotificationService.m';
|
|
13
|
-
exports.NSE_PODFILE_SNIPPET = `
|
|
14
|
-
target '${exports.NSE_TARGET_NAME}' do
|
|
15
|
-
pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
|
|
16
|
-
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
17
|
-
end`;
|
|
18
|
-
exports.NSE_PODFILE_REGEX = new RegExp(`target '${exports.NSE_TARGET_NAME}'`);
|
|
19
|
-
exports.NSE_EXT_FILES = [
|
|
20
|
-
'NotificationService.h',
|
|
21
|
-
`${exports.NSE_TARGET_NAME}.entitlements`,
|
|
22
|
-
`${exports.NSE_TARGET_NAME}-Info.plist`,
|
|
23
|
-
];
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#import <OneSignalFramework/OneSignalFramework.h>
|
|
2
|
-
|
|
3
|
-
#import "NotificationService.h"
|
|
4
|
-
|
|
5
|
-
@interface NotificationService ()
|
|
6
|
-
|
|
7
|
-
@property(nonatomic, strong) void (^contentHandler)
|
|
8
|
-
(UNNotificationContent *contentToDeliver);
|
|
9
|
-
@property(nonatomic, strong) UNNotificationRequest *receivedRequest;
|
|
10
|
-
@property(nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
|
|
11
|
-
|
|
12
|
-
@end
|
|
13
|
-
|
|
14
|
-
@implementation NotificationService
|
|
15
|
-
|
|
16
|
-
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request
|
|
17
|
-
withContentHandler:
|
|
18
|
-
(void (^)(UNNotificationContent *_Nonnull))
|
|
19
|
-
contentHandler {
|
|
20
|
-
self.receivedRequest = request;
|
|
21
|
-
self.contentHandler = contentHandler;
|
|
22
|
-
self.bestAttemptContent = [request.content mutableCopy];
|
|
23
|
-
[OneSignal didReceiveNotificationExtensionRequest:self.receivedRequest
|
|
24
|
-
withMutableNotificationContent:self.bestAttemptContent
|
|
25
|
-
withContentHandler:self.contentHandler];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
- (void)serviceExtensionTimeWillExpire {
|
|
29
|
-
[OneSignal serviceExtensionTimeWillExpireRequest:self.receivedRequest
|
|
30
|
-
withMutableNotificationContent:self.bestAttemptContent];
|
|
31
|
-
self.contentHandler(self.bestAttemptContent);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function updatePodfile(iosPath: string): Promise<void>;
|