onesignal-expo-plugin 1.3.1 → 2.0.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/.github/workflows/Zapier.yml +6 -1
- package/CHANGELOG.md +9 -0
- package/build/onesignal/withOneSignalAndroid.js +1 -1
- package/build/onesignal/withOneSignalIos.js +65 -77
- package/build/support/FileManager.js +1 -5
- package/build/support/iosConstants.js +8 -2
- package/build/support/serviceExtensionFiles/NotificationService.m +1 -1
- package/onesignal/withOneSignalAndroid.ts +4 -4
- package/onesignal/withOneSignalIos.ts +67 -88
- package/package.json +3 -3
- package/support/iosConstants.ts +7 -1
- package/support/serviceExtensionFiles/NotificationService.m +1 -1
- package/types/types.ts +0 -15
- package/build/testRuniOS.js +0 -22
- package/testRuniOS.ts +0 -28
- package/types/xcode.d.ts +0 -8
|
@@ -7,6 +7,9 @@ on:
|
|
|
7
7
|
# Triggers the workflow on push or pull request events but only for the "main" branch
|
|
8
8
|
issues:
|
|
9
9
|
types: [closed]
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
issues: read
|
|
10
13
|
|
|
11
14
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
12
15
|
jobs:
|
|
@@ -20,10 +23,12 @@ jobs:
|
|
|
20
23
|
# Runs a set of commands using the runners shell
|
|
21
24
|
- name: Call Zapier web hook to close Asana task
|
|
22
25
|
if: ${{ !github.event.issue.pull_request }}
|
|
26
|
+
env:
|
|
27
|
+
ISSUE_TITLE: ${{ github.event.issue.title }}
|
|
23
28
|
run: |
|
|
24
29
|
curl --location --request POST 'https://hooks.zapier.com/hooks/catch/12728683/b7009qc/' \
|
|
25
30
|
--header 'Content-Type: application/json' \
|
|
26
31
|
--header 'Accept: application/json' \
|
|
27
32
|
--data-raw '{
|
|
28
|
-
"task_name" : "$
|
|
33
|
+
"task_name" : "$ISSUE_TITLE"
|
|
29
34
|
}'
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## April 2023
|
|
5
|
+
### `1.3.2` - 04/18/23
|
|
6
|
+
#### Changes
|
|
7
|
+
- Update iOS generation to write xcode project via expo mod rather than directly to file system.
|
|
8
|
+
- Bump qs from 6.5.2 to 6.5.3
|
|
9
|
+
- Bump decode-uri-component from 0.2.0 to 0.2.2
|
|
10
|
+
- Bump @xmldom/xmldom from 0.7.5 to 0.7.10
|
|
11
|
+
- Bump multiple dependency versions in OneSignal Example App (ua-parser-js, decode-uri-component, @sideway/formula, @xmldom/xmldom)
|
|
12
|
+
|
|
4
13
|
## March 2023
|
|
5
14
|
### `1.3.1` - 03/03/23
|
|
6
15
|
#### Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Expo config plugin for
|
|
3
|
+
* Expo config plugin for OneSignal (Android)
|
|
4
4
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
7
|
if (k2 === undefined) k2 = k;
|
|
8
|
-
|
|
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);
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
13
9
|
}) : (function(o, m, k, k2) {
|
|
14
10
|
if (k2 === undefined) k2 = k;
|
|
15
11
|
o[k2] = m[k];
|
|
@@ -30,11 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
27
|
};
|
|
32
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.
|
|
29
|
+
exports.withOneSignalIos = void 0;
|
|
34
30
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
35
31
|
const fs = __importStar(require("fs"));
|
|
36
32
|
const path = __importStar(require("path"));
|
|
37
|
-
const xcode_1 = __importDefault(require("xcode"));
|
|
38
33
|
const iosConstants_1 = require("../support/iosConstants");
|
|
39
34
|
const updatePodfile_1 = require("../support/updatePodfile");
|
|
40
35
|
const NseUpdaterManager_1 = __importDefault(require("../support/NseUpdaterManager"));
|
|
@@ -96,75 +91,58 @@ const withAppGroupPermissions = (config) => {
|
|
|
96
91
|
return newConfig;
|
|
97
92
|
});
|
|
98
93
|
};
|
|
99
|
-
const withOneSignalNSE = (config, onesignalProps) => {
|
|
100
|
-
return (0, config_plugins_1.withXcodeProject)(config, async (props) => {
|
|
101
|
-
var _a, _b;
|
|
102
|
-
const options = {
|
|
103
|
-
iosPath: props.modRequest.platformProjectRoot,
|
|
104
|
-
bundleIdentifier: (_a = props.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier,
|
|
105
|
-
devTeam: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.devTeam,
|
|
106
|
-
bundleVersion: (_b = props.ios) === null || _b === void 0 ? void 0 : _b.buildNumber,
|
|
107
|
-
bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
|
|
108
|
-
mode: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.mode,
|
|
109
|
-
iPhoneDeploymentTarget: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.iPhoneDeploymentTarget,
|
|
110
|
-
iosNSEFilePath: onesignalProps.iosNSEFilePath
|
|
111
|
-
};
|
|
112
|
-
// support for monorepos where node_modules can be above the project directory.
|
|
113
|
-
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
114
|
-
xcodeProjectAddNse(props.modRequest.projectName || "", options, path.join(pluginDir, "../build/support/serviceExtensionFiles/"));
|
|
115
|
-
return props;
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
94
|
const withEasManagedCredentials = (config) => {
|
|
119
95
|
var _a;
|
|
120
96
|
(0, assert_1.default)((_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.");
|
|
121
97
|
config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config);
|
|
122
98
|
return config;
|
|
123
99
|
};
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
100
|
+
const withOneSignalPodfile = (config) => {
|
|
101
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
102
|
+
'ios',
|
|
103
|
+
async (config) => {
|
|
104
|
+
// not awaiting in order to not block main thread
|
|
105
|
+
const iosRoot = path.join(config.modRequest.projectRoot, "ios");
|
|
106
|
+
(0, updatePodfile_1.updatePodfile)(iosRoot).catch(err => { OneSignalLog_1.OneSignalLog.error(err); });
|
|
107
|
+
return config;
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
131
110
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
(0,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
await
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion !== null && bundleShortVersion !== void 0 ? bundleShortVersion : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
111
|
+
const withOneSignalNSE = (config, props) => {
|
|
112
|
+
// support for monorepos where node_modules can be above the project directory.
|
|
113
|
+
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
114
|
+
const sourceDir = path.join(pluginDir, "../build/support/serviceExtensionFiles/");
|
|
115
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
116
|
+
'ios',
|
|
117
|
+
async (config) => {
|
|
118
|
+
var _a, _b, _c, _d, _e;
|
|
119
|
+
const iosPath = path.join(config.modRequest.projectRoot, "ios");
|
|
120
|
+
/* COPY OVER EXTENSION FILES */
|
|
121
|
+
fs.mkdirSync(`${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`, { recursive: true });
|
|
122
|
+
for (let i = 0; i < iosConstants_1.NSE_EXT_FILES.length; i++) {
|
|
123
|
+
const extFile = iosConstants_1.NSE_EXT_FILES[i];
|
|
124
|
+
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${extFile}`;
|
|
125
|
+
await FileManager_1.FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
|
|
126
|
+
}
|
|
127
|
+
// Copy NSE source file either from configuration-provided location, falling back to the default one.
|
|
128
|
+
const sourcePath = (_a = props.iosNSEFilePath) !== null && _a !== void 0 ? _a : `${sourceDir}${iosConstants_1.NSE_SOURCE_FILE}`;
|
|
129
|
+
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_SOURCE_FILE}`;
|
|
130
|
+
await FileManager_1.FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
131
|
+
/* MODIFY COPIED EXTENSION FILES */
|
|
132
|
+
const nseUpdater = new NseUpdaterManager_1.default(iosPath);
|
|
133
|
+
await nseUpdater.updateNSEEntitlements(`group.${(_b = config.ios) === null || _b === void 0 ? void 0 : _b.bundleIdentifier}.onesignal`);
|
|
134
|
+
await nseUpdater.updateNSEBundleVersion((_d = (_c = config.ios) === null || _c === void 0 ? void 0 : _c.buildNumber) !== null && _d !== void 0 ? _d : iosConstants_1.DEFAULT_BUNDLE_VERSION);
|
|
135
|
+
await nseUpdater.updateNSEBundleShortVersion((_e = config === null || config === void 0 ? void 0 : config.version) !== null && _e !== void 0 ? _e : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
136
|
+
return config;
|
|
137
|
+
},
|
|
138
|
+
]);
|
|
139
|
+
};
|
|
140
|
+
const withOneSignalXcodeProject = (config, props) => {
|
|
141
|
+
return (0, config_plugins_1.withXcodeProject)(config, newConfig => {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const xcodeProject = newConfig.modResults;
|
|
166
144
|
// Create new PBXGroup for the extension
|
|
167
|
-
const extGroup = xcodeProject.addPbxGroup([...
|
|
145
|
+
const extGroup = xcodeProject.addPbxGroup([...iosConstants_1.NSE_EXT_FILES, iosConstants_1.NSE_SOURCE_FILE], iosConstants_1.NSE_TARGET_NAME, iosConstants_1.NSE_TARGET_NAME);
|
|
168
146
|
// Add the new PBXGroup to the top level group. This makes the
|
|
169
147
|
// files / folder appear in the file explorer in Xcode.
|
|
170
148
|
const groups = xcodeProject.hash.project.objects["PBXGroup"];
|
|
@@ -182,11 +160,11 @@ function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
|
182
160
|
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
|
|
183
161
|
if (!!xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) {
|
|
184
162
|
OneSignalLog_1.OneSignalLog.log(`${iosConstants_1.NSE_TARGET_NAME} already exists in project. Skipping...`);
|
|
185
|
-
return;
|
|
163
|
+
return newConfig;
|
|
186
164
|
}
|
|
187
165
|
// Add the NSE target
|
|
188
166
|
// This adds PBXTargetDependency and PBXContainerItemProxy for you
|
|
189
|
-
const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, "app_extension", iosConstants_1.NSE_TARGET_NAME, `${bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`);
|
|
167
|
+
const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, "app_extension", iosConstants_1.NSE_TARGET_NAME, `${(_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`);
|
|
190
168
|
// Add build phases to the new target
|
|
191
169
|
xcodeProject.addBuildPhase(["NotificationService.m"], "PBXSourcesBuildPhase", "Sources", nseTarget.uuid);
|
|
192
170
|
xcodeProject.addBuildPhase([], "PBXResourcesBuildPhase", "Resources", nseTarget.uuid);
|
|
@@ -198,17 +176,27 @@ function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
|
198
176
|
if (typeof configurations[key].buildSettings !== "undefined" &&
|
|
199
177
|
configurations[key].buildSettings.PRODUCT_NAME == `"${iosConstants_1.NSE_TARGET_NAME}"`) {
|
|
200
178
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
201
|
-
buildSettingsObj.DEVELOPMENT_TEAM = devTeam;
|
|
202
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iPhoneDeploymentTarget !== null &&
|
|
179
|
+
buildSettingsObj.DEVELOPMENT_TEAM = props === null || props === void 0 ? void 0 : props.devTeam;
|
|
180
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = (_b = props === null || props === void 0 ? void 0 : props.iPhoneDeploymentTarget) !== null && _b !== void 0 ? _b : iosConstants_1.IPHONEOS_DEPLOYMENT_TARGET;
|
|
203
181
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = iosConstants_1.TARGETED_DEVICE_FAMILY;
|
|
204
182
|
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_TARGET_NAME}.entitlements`;
|
|
205
183
|
buildSettingsObj.CODE_SIGN_STYLE = "Automatic";
|
|
206
184
|
}
|
|
207
185
|
}
|
|
208
186
|
// Add development teams to both your target and the original project
|
|
209
|
-
xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam, nseTarget);
|
|
210
|
-
xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam);
|
|
211
|
-
|
|
187
|
+
xcodeProject.addTargetAttribute("DevelopmentTeam", props === null || props === void 0 ? void 0 : props.devTeam, nseTarget);
|
|
188
|
+
xcodeProject.addTargetAttribute("DevelopmentTeam", props === null || props === void 0 ? void 0 : props.devTeam);
|
|
189
|
+
return newConfig;
|
|
212
190
|
});
|
|
213
|
-
}
|
|
214
|
-
|
|
191
|
+
};
|
|
192
|
+
const withOneSignalIos = (config, props) => {
|
|
193
|
+
config = withAppEnvironment(config, props);
|
|
194
|
+
config = withRemoteNotificationsPermissions(config, props);
|
|
195
|
+
config = withAppGroupPermissions(config, props);
|
|
196
|
+
config = withOneSignalPodfile(config, props);
|
|
197
|
+
config = withOneSignalNSE(config, props);
|
|
198
|
+
config = withOneSignalXcodeProject(config, props);
|
|
199
|
+
config = withEasManagedCredentials(config, props);
|
|
200
|
+
return config;
|
|
201
|
+
};
|
|
202
|
+
exports.withOneSignalIos = withOneSignalIos;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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;
|
|
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
4
|
exports.IPHONEOS_DEPLOYMENT_TARGET = "11.0";
|
|
5
5
|
exports.TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
6
6
|
exports.NSE_PODFILE_SNIPPET = `
|
|
7
7
|
target 'OneSignalNotificationServiceExtension' do
|
|
8
|
-
pod 'OneSignalXCFramework', '>=
|
|
8
|
+
pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
|
|
9
9
|
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
10
10
|
end`;
|
|
11
11
|
exports.NSE_PODFILE_REGEX = /target 'OneSignalNotificationServiceExtension'/;
|
|
@@ -15,3 +15,9 @@ exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
|
15
15
|
exports.DEFAULT_BUNDLE_VERSION = '1';
|
|
16
16
|
exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
17
17
|
exports.NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";
|
|
18
|
+
exports.NSE_SOURCE_FILE = "NotificationService.m";
|
|
19
|
+
exports.NSE_EXT_FILES = [
|
|
20
|
+
"NotificationService.h",
|
|
21
|
+
`${exports.NSE_TARGET_NAME}.entitlements`,
|
|
22
|
+
`${exports.NSE_TARGET_NAME}-Info.plist`
|
|
23
|
+
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Expo config plugin for
|
|
2
|
+
* Expo config plugin for OneSignal (Android)
|
|
3
3
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -13,8 +13,8 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
|
13
13
|
const RESOURCE_ROOT_PATH = 'android/app/src/main/res/';
|
|
14
14
|
|
|
15
15
|
// The name of each small icon folder resource, and the icon size for that folder.
|
|
16
|
-
const SMALL_ICON_DIRS_TO_SIZE: { [name: string]: number } = {
|
|
17
|
-
'drawable-mdpi': 24,
|
|
16
|
+
const SMALL_ICON_DIRS_TO_SIZE: { [name: string]: number } = {
|
|
17
|
+
'drawable-mdpi': 24,
|
|
18
18
|
'drawable-hdpi': 36,
|
|
19
19
|
'drawable-xhdpi': 48,
|
|
20
20
|
'drawable-xxhdpi': 72,
|
|
@@ -22,7 +22,7 @@ const SMALL_ICON_DIRS_TO_SIZE: { [name: string]: number } = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// The name of each large icon folder resource, and the icon size for that folder.
|
|
25
|
-
const LARGE_ICON_DIRS_TO_SIZE: { [name: string]: number } = {
|
|
25
|
+
const LARGE_ICON_DIRS_TO_SIZE: { [name: string]: number } = {
|
|
26
26
|
'drawable-xxxhdpi': 256
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -8,22 +8,24 @@ import {
|
|
|
8
8
|
withEntitlementsPlist,
|
|
9
9
|
withInfoPlist,
|
|
10
10
|
withXcodeProject,
|
|
11
|
+
withDangerousMod
|
|
11
12
|
} from "@expo/config-plugins";
|
|
12
13
|
import * as fs from 'fs';
|
|
13
14
|
import * as path from 'path';
|
|
14
|
-
import xcode from 'xcode';
|
|
15
15
|
import {
|
|
16
16
|
DEFAULT_BUNDLE_SHORT_VERSION,
|
|
17
17
|
DEFAULT_BUNDLE_VERSION,
|
|
18
18
|
IPHONEOS_DEPLOYMENT_TARGET,
|
|
19
19
|
NSE_TARGET_NAME,
|
|
20
|
+
NSE_SOURCE_FILE,
|
|
21
|
+
NSE_EXT_FILES,
|
|
20
22
|
TARGETED_DEVICE_FAMILY
|
|
21
23
|
} from "../support/iosConstants";
|
|
22
24
|
import { updatePodfile } from "../support/updatePodfile";
|
|
23
25
|
import NseUpdaterManager from "../support/NseUpdaterManager";
|
|
24
26
|
import { OneSignalLog } from "../support/OneSignalLog";
|
|
25
27
|
import { FileManager } from "../support/FileManager";
|
|
26
|
-
import { OneSignalPluginProps
|
|
28
|
+
import { OneSignalPluginProps } from "../types/types";
|
|
27
29
|
import assert from 'assert';
|
|
28
30
|
import getEasManagedCredentialsConfigExtra from "../support/eas/getEasManagedCredentialsConfigExtra";
|
|
29
31
|
import { ExpoConfig } from '@expo/config-types';
|
|
@@ -94,100 +96,67 @@ const withAppGroupPermissions: ConfigPlugin<OneSignalPluginProps> = (
|
|
|
94
96
|
});
|
|
95
97
|
};
|
|
96
98
|
|
|
97
|
-
const withOneSignalNSE: ConfigPlugin<OneSignalPluginProps> = (config, onesignalProps) => {
|
|
98
|
-
return withXcodeProject(config, async props => {
|
|
99
|
-
const options: PluginOptions = {
|
|
100
|
-
iosPath: props.modRequest.platformProjectRoot,
|
|
101
|
-
bundleIdentifier: props.ios?.bundleIdentifier,
|
|
102
|
-
devTeam: onesignalProps?.devTeam,
|
|
103
|
-
bundleVersion: props.ios?.buildNumber,
|
|
104
|
-
bundleShortVersion: props?.version,
|
|
105
|
-
mode: onesignalProps?.mode,
|
|
106
|
-
iPhoneDeploymentTarget: onesignalProps?.iPhoneDeploymentTarget,
|
|
107
|
-
iosNSEFilePath: onesignalProps.iosNSEFilePath
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// support for monorepos where node_modules can be above the project directory.
|
|
111
|
-
const pluginDir = require.resolve("onesignal-expo-plugin/package.json")
|
|
112
|
-
|
|
113
|
-
xcodeProjectAddNse(
|
|
114
|
-
props.modRequest.projectName || "",
|
|
115
|
-
options,
|
|
116
|
-
path.join(pluginDir, "../build/support/serviceExtensionFiles/")
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
return props;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
99
|
const withEasManagedCredentials: ConfigPlugin<OneSignalPluginProps> = (config) => {
|
|
124
100
|
assert(config.ios?.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.")
|
|
125
101
|
config.extra = getEasManagedCredentialsConfigExtra(config as ExpoConfig);
|
|
126
102
|
return config;
|
|
127
103
|
}
|
|
128
104
|
|
|
129
|
-
|
|
130
|
-
config,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
export function xcodeProjectAddNse(
|
|
142
|
-
appName: string,
|
|
143
|
-
options: PluginOptions,
|
|
144
|
-
sourceDir: string
|
|
145
|
-
): void {
|
|
146
|
-
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget, iosNSEFilePath } = options;
|
|
147
|
-
|
|
148
|
-
// not awaiting in order to not block main thread
|
|
149
|
-
updatePodfile(iosPath).catch(err => { OneSignalLog.error(err) });
|
|
105
|
+
const withOneSignalPodfile: ConfigPlugin<OneSignalPluginProps> = (config) => {
|
|
106
|
+
return withDangerousMod(config, [
|
|
107
|
+
'ios',
|
|
108
|
+
async config => {
|
|
109
|
+
// not awaiting in order to not block main thread
|
|
110
|
+
const iosRoot = path.join(config.modRequest.projectRoot, "ios")
|
|
111
|
+
updatePodfile(iosRoot).catch(err => { OneSignalLog.error(err) });
|
|
112
|
+
|
|
113
|
+
return config;
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
150
117
|
|
|
151
|
-
|
|
118
|
+
const withOneSignalNSE: ConfigPlugin<OneSignalPluginProps> = (config, props) => {
|
|
119
|
+
// support for monorepos where node_modules can be above the project directory.
|
|
120
|
+
const pluginDir = require.resolve("onesignal-expo-plugin/package.json")
|
|
121
|
+
const sourceDir = path.join(pluginDir, "../build/support/serviceExtensionFiles/")
|
|
152
122
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
`${NSE_TARGET_NAME}-Info.plist`
|
|
158
|
-
];
|
|
123
|
+
return withDangerousMod(config, [
|
|
124
|
+
'ios',
|
|
125
|
+
async config => {
|
|
126
|
+
const iosPath = path.join(config.modRequest.projectRoot, "ios")
|
|
159
127
|
|
|
160
|
-
|
|
128
|
+
/* COPY OVER EXTENSION FILES */
|
|
129
|
+
fs.mkdirSync(`${iosPath}/${NSE_TARGET_NAME}`, { recursive: true });
|
|
161
130
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
131
|
+
for (let i = 0; i < NSE_EXT_FILES.length; i++) {
|
|
132
|
+
const extFile = NSE_EXT_FILES[i];
|
|
133
|
+
const targetFile = `${iosPath}/${NSE_TARGET_NAME}/${extFile}`;
|
|
134
|
+
await FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
|
|
135
|
+
}
|
|
167
136
|
|
|
168
|
-
|
|
169
|
-
|
|
137
|
+
// Copy NSE source file either from configuration-provided location, falling back to the default one.
|
|
138
|
+
const sourcePath = props.iosNSEFilePath ?? `${sourceDir}${NSE_SOURCE_FILE}`
|
|
139
|
+
const targetFile = `${iosPath}/${NSE_TARGET_NAME}/${NSE_SOURCE_FILE}`;
|
|
140
|
+
await FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
170
141
|
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
await
|
|
175
|
-
|
|
142
|
+
/* MODIFY COPIED EXTENSION FILES */
|
|
143
|
+
const nseUpdater = new NseUpdaterManager(iosPath);
|
|
144
|
+
await nseUpdater.updateNSEEntitlements(`group.${config.ios?.bundleIdentifier}.onesignal`)
|
|
145
|
+
await nseUpdater.updateNSEBundleVersion(config.ios?.buildNumber ?? DEFAULT_BUNDLE_VERSION);
|
|
146
|
+
await nseUpdater.updateNSEBundleShortVersion(config?.version ?? DEFAULT_BUNDLE_SHORT_VERSION);
|
|
176
147
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
148
|
+
return config;
|
|
149
|
+
},
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
181
152
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
await nseUpdater.updateNSEBundleVersion(bundleVersion ?? DEFAULT_BUNDLE_VERSION);
|
|
186
|
-
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion ?? DEFAULT_BUNDLE_SHORT_VERSION);
|
|
153
|
+
const withOneSignalXcodeProject: ConfigPlugin<OneSignalPluginProps> = (config, props) => {
|
|
154
|
+
return withXcodeProject(config, newConfig => {
|
|
155
|
+
const xcodeProject = newConfig.modResults
|
|
187
156
|
|
|
188
157
|
// Create new PBXGroup for the extension
|
|
189
|
-
const extGroup = xcodeProject.addPbxGroup([...
|
|
190
|
-
|
|
158
|
+
const extGroup = xcodeProject.addPbxGroup([...NSE_EXT_FILES, NSE_SOURCE_FILE], NSE_TARGET_NAME, NSE_TARGET_NAME);
|
|
159
|
+
|
|
191
160
|
// Add the new PBXGroup to the top level group. This makes the
|
|
192
161
|
// files / folder appear in the file explorer in Xcode.
|
|
193
162
|
const groups = xcodeProject.hash.project.objects["PBXGroup"];
|
|
@@ -207,12 +176,12 @@ export function xcodeProjectAddNse(
|
|
|
207
176
|
|
|
208
177
|
if (!!xcodeProject.pbxTargetByName(NSE_TARGET_NAME)) {
|
|
209
178
|
OneSignalLog.log(`${NSE_TARGET_NAME} already exists in project. Skipping...`);
|
|
210
|
-
return;
|
|
179
|
+
return newConfig;
|
|
211
180
|
}
|
|
212
181
|
|
|
213
182
|
// Add the NSE target
|
|
214
183
|
// This adds PBXTargetDependency and PBXContainerItemProxy for you
|
|
215
|
-
const nseTarget = xcodeProject.addTarget(NSE_TARGET_NAME, "app_extension", NSE_TARGET_NAME, `${bundleIdentifier}.${NSE_TARGET_NAME}`);
|
|
184
|
+
const nseTarget = xcodeProject.addTarget(NSE_TARGET_NAME, "app_extension", NSE_TARGET_NAME, `${config.ios?.bundleIdentifier}.${NSE_TARGET_NAME}`);
|
|
216
185
|
|
|
217
186
|
// Add build phases to the new target
|
|
218
187
|
xcodeProject.addBuildPhase(
|
|
@@ -239,8 +208,8 @@ export function xcodeProjectAddNse(
|
|
|
239
208
|
configurations[key].buildSettings.PRODUCT_NAME == `"${NSE_TARGET_NAME}"`
|
|
240
209
|
) {
|
|
241
210
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
242
|
-
buildSettingsObj.DEVELOPMENT_TEAM = devTeam;
|
|
243
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iPhoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
|
|
211
|
+
buildSettingsObj.DEVELOPMENT_TEAM = props?.devTeam;
|
|
212
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = props?.iPhoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
|
|
244
213
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
245
214
|
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${NSE_TARGET_NAME}/${NSE_TARGET_NAME}.entitlements`;
|
|
246
215
|
buildSettingsObj.CODE_SIGN_STYLE = "Automatic";
|
|
@@ -248,9 +217,19 @@ export function xcodeProjectAddNse(
|
|
|
248
217
|
}
|
|
249
218
|
|
|
250
219
|
// Add development teams to both your target and the original project
|
|
251
|
-
xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam, nseTarget);
|
|
252
|
-
xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam);
|
|
253
|
-
|
|
254
|
-
fs.writeFileSync(projPath, xcodeProject.writeSync());
|
|
220
|
+
xcodeProject.addTargetAttribute("DevelopmentTeam", props?.devTeam, nseTarget);
|
|
221
|
+
xcodeProject.addTargetAttribute("DevelopmentTeam", props?.devTeam);
|
|
222
|
+
return newConfig;
|
|
255
223
|
})
|
|
256
224
|
}
|
|
225
|
+
|
|
226
|
+
export const withOneSignalIos: ConfigPlugin<OneSignalPluginProps> = (config, props) => {
|
|
227
|
+
config = withAppEnvironment(config, props);
|
|
228
|
+
config = withRemoteNotificationsPermissions(config, props);
|
|
229
|
+
config = withAppGroupPermissions(config, props);
|
|
230
|
+
config = withOneSignalPodfile(config, props)
|
|
231
|
+
config = withOneSignalNSE(config, props)
|
|
232
|
+
config = withOneSignalXcodeProject(config, props)
|
|
233
|
+
config = withEasManagedCredentials(config, props);
|
|
234
|
+
return config;
|
|
235
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"Karen Grigoryan",
|
|
26
26
|
"Rodrigo Gomez-Palacio",
|
|
27
27
|
"Charlie Cruzan",
|
|
28
|
-
"Wojciech Kozyra"
|
|
28
|
+
"Wojciech Kozyra",
|
|
29
|
+
"Brian Smith"
|
|
29
30
|
],
|
|
30
31
|
"license": "MIT",
|
|
31
32
|
"bugs": {
|
|
@@ -41,7 +42,6 @@
|
|
|
41
42
|
"typescript": "^4.5.5"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"xcode": "^3.0.1",
|
|
45
45
|
"@expo/image-utils": "^0.3.22"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/support/iosConstants.ts
CHANGED
|
@@ -3,7 +3,7 @@ export const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
|
3
3
|
|
|
4
4
|
export const NSE_PODFILE_SNIPPET = `
|
|
5
5
|
target 'OneSignalNotificationServiceExtension' do
|
|
6
|
-
pod 'OneSignalXCFramework', '>=
|
|
6
|
+
pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
|
|
7
7
|
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
8
8
|
end`;
|
|
9
9
|
|
|
@@ -17,3 +17,9 @@ export const DEFAULT_BUNDLE_VERSION = '1';
|
|
|
17
17
|
export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
18
18
|
|
|
19
19
|
export const NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";
|
|
20
|
+
export const NSE_SOURCE_FILE = "NotificationService.m"
|
|
21
|
+
export const NSE_EXT_FILES = [
|
|
22
|
+
"NotificationService.h",
|
|
23
|
+
`${NSE_TARGET_NAME}.entitlements`,
|
|
24
|
+
`${NSE_TARGET_NAME}-Info.plist`
|
|
25
|
+
];
|
package/types/types.ts
CHANGED
|
@@ -37,21 +37,6 @@
|
|
|
37
37
|
iosNSEFilePath?: string;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Not to be confused with OneSignalPluginProps, PluginOptions are the *internal* properties used by the config plugin
|
|
42
|
-
* These include a combination of user-defined properties (from OneSignalPluginProps) and other data to pass between functions
|
|
43
|
-
*/
|
|
44
|
-
export type PluginOptions = {
|
|
45
|
-
iosPath: string,
|
|
46
|
-
mode: Mode,
|
|
47
|
-
devTeam?: string,
|
|
48
|
-
bundleVersion?: string,
|
|
49
|
-
bundleShortVersion?: string,
|
|
50
|
-
bundleIdentifier?: string,
|
|
51
|
-
iPhoneDeploymentTarget?: string,
|
|
52
|
-
iosNSEFilePath?: string
|
|
53
|
-
}
|
|
54
|
-
|
|
55
40
|
export enum Mode {
|
|
56
41
|
Dev = "development",
|
|
57
42
|
Prod = "production"
|
package/build/testRuniOS.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const withOneSignalIos_1 = require("./onesignal/withOneSignalIos");
|
|
4
|
-
const types_1 = require("./types/types");
|
|
5
|
-
// Quick testing on any Xcode project
|
|
6
|
-
// 1. Update values for your project
|
|
7
|
-
// 2. Run `yarn build` from here
|
|
8
|
-
// 3. Open a terminal to the root of your Xcode project
|
|
9
|
-
// 4. Run `node ~/WHERE_YOU_CLONED_ME/onesignal-expo-plugin/build/testRuniOS.js`
|
|
10
|
-
// 5. Run `pod init`, if you haven't already.
|
|
11
|
-
// - Make sure you are testing with 2 targets in your Podfile, your main target AND your NSE
|
|
12
|
-
// - If you forget your main target in your Podfile you will get the
|
|
13
|
-
// "Please add the host targets for the embedded targets to the Podfile." error
|
|
14
|
-
// even if your .xcodeproj is correct.
|
|
15
|
-
const options = {
|
|
16
|
-
iosPath: '.',
|
|
17
|
-
mode: types_1.Mode.Dev,
|
|
18
|
-
bundleIdentifier: "com.onesignal.XcodeTestProj",
|
|
19
|
-
devTeam: "99SW8E36CT",
|
|
20
|
-
iPhoneDeploymentTarget: '12.0'
|
|
21
|
-
};
|
|
22
|
-
(0, withOneSignalIos_1.xcodeProjectAddNse)("XcodeTestProj", options, "../../repos/onesignal-expo-plugin/support/serviceExtensionFiles/");
|
package/testRuniOS.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { xcodeProjectAddNse } from "./onesignal/withOneSignalIos";
|
|
2
|
-
import { Mode } from "./types/types";
|
|
3
|
-
|
|
4
|
-
// Quick testing on any Xcode project
|
|
5
|
-
|
|
6
|
-
// 1. Update values for your project
|
|
7
|
-
// 2. Run `yarn build` from here
|
|
8
|
-
// 3. Open a terminal to the root of your Xcode project
|
|
9
|
-
// 4. Run `node ~/WHERE_YOU_CLONED_ME/onesignal-expo-plugin/build/testRuniOS.js`
|
|
10
|
-
// 5. Run `pod init`, if you haven't already.
|
|
11
|
-
// - Make sure you are testing with 2 targets in your Podfile, your main target AND your NSE
|
|
12
|
-
// - If you forget your main target in your Podfile you will get the
|
|
13
|
-
// "Please add the host targets for the embedded targets to the Podfile." error
|
|
14
|
-
// even if your .xcodeproj is correct.
|
|
15
|
-
|
|
16
|
-
const options = {
|
|
17
|
-
iosPath: '.',
|
|
18
|
-
mode: Mode.Dev,
|
|
19
|
-
bundleIdentifier: "com.onesignal.XcodeTestProj",
|
|
20
|
-
devTeam: "99SW8E36CT",
|
|
21
|
-
iPhoneDeploymentTarget: '12.0'
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
xcodeProjectAddNse(
|
|
25
|
-
"XcodeTestProj",
|
|
26
|
-
options,
|
|
27
|
-
"../../repos/onesignal-expo-plugin/support/serviceExtensionFiles/"
|
|
28
|
-
);
|