onesignal-expo-plugin 1.3.1 → 1.3.2
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/withOneSignalIos.js +64 -72
- package/build/support/iosConstants.js +7 -1
- package/onesignal/withOneSignalIos.ts +67 -88
- package/package.json +1 -2
- package/support/iosConstants.ts +6 -0
- 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
|
|
@@ -30,11 +30,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.
|
|
33
|
+
exports.withOneSignalIos = void 0;
|
|
34
34
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
35
35
|
const fs = __importStar(require("fs"));
|
|
36
36
|
const path = __importStar(require("path"));
|
|
37
|
-
const xcode_1 = __importDefault(require("xcode"));
|
|
38
37
|
const iosConstants_1 = require("../support/iosConstants");
|
|
39
38
|
const updatePodfile_1 = require("../support/updatePodfile");
|
|
40
39
|
const NseUpdaterManager_1 = __importDefault(require("../support/NseUpdaterManager"));
|
|
@@ -96,75 +95,58 @@ const withAppGroupPermissions = (config) => {
|
|
|
96
95
|
return newConfig;
|
|
97
96
|
});
|
|
98
97
|
};
|
|
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
98
|
const withEasManagedCredentials = (config) => {
|
|
119
99
|
var _a;
|
|
120
100
|
(0, assert_1.default)((_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.");
|
|
121
101
|
config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config);
|
|
122
102
|
return config;
|
|
123
103
|
};
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
104
|
+
const withOneSignalPodfile = (config) => {
|
|
105
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
106
|
+
'ios',
|
|
107
|
+
async (config) => {
|
|
108
|
+
// not awaiting in order to not block main thread
|
|
109
|
+
const iosRoot = path.join(config.modRequest.projectRoot, "ios");
|
|
110
|
+
(0, updatePodfile_1.updatePodfile)(iosRoot).catch(err => { OneSignalLog_1.OneSignalLog.error(err); });
|
|
111
|
+
return config;
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
131
114
|
};
|
|
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);
|
|
115
|
+
const withOneSignalNSE = (config, props) => {
|
|
116
|
+
// support for monorepos where node_modules can be above the project directory.
|
|
117
|
+
const pluginDir = require.resolve("onesignal-expo-plugin/package.json");
|
|
118
|
+
const sourceDir = path.join(pluginDir, "../build/support/serviceExtensionFiles/");
|
|
119
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
120
|
+
'ios',
|
|
121
|
+
async (config) => {
|
|
122
|
+
var _a, _b, _c, _d, _e;
|
|
123
|
+
const iosPath = path.join(config.modRequest.projectRoot, "ios");
|
|
124
|
+
/* COPY OVER EXTENSION FILES */
|
|
125
|
+
fs.mkdirSync(`${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`, { recursive: true });
|
|
126
|
+
for (let i = 0; i < iosConstants_1.NSE_EXT_FILES.length; i++) {
|
|
127
|
+
const extFile = iosConstants_1.NSE_EXT_FILES[i];
|
|
128
|
+
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${extFile}`;
|
|
129
|
+
await FileManager_1.FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
|
|
130
|
+
}
|
|
131
|
+
// Copy NSE source file either from configuration-provided location, falling back to the default one.
|
|
132
|
+
const sourcePath = (_a = props.iosNSEFilePath) !== null && _a !== void 0 ? _a : `${sourceDir}${iosConstants_1.NSE_SOURCE_FILE}`;
|
|
133
|
+
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_SOURCE_FILE}`;
|
|
134
|
+
await FileManager_1.FileManager.copyFile(`${sourcePath}`, targetFile);
|
|
135
|
+
/* MODIFY COPIED EXTENSION FILES */
|
|
136
|
+
const nseUpdater = new NseUpdaterManager_1.default(iosPath);
|
|
137
|
+
await nseUpdater.updateNSEEntitlements(`group.${(_b = config.ios) === null || _b === void 0 ? void 0 : _b.bundleIdentifier}.onesignal`);
|
|
138
|
+
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);
|
|
139
|
+
await nseUpdater.updateNSEBundleShortVersion((_e = config === null || config === void 0 ? void 0 : config.version) !== null && _e !== void 0 ? _e : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
140
|
+
return config;
|
|
141
|
+
},
|
|
142
|
+
]);
|
|
143
|
+
};
|
|
144
|
+
const withOneSignalXcodeProject = (config, props) => {
|
|
145
|
+
return (0, config_plugins_1.withXcodeProject)(config, newConfig => {
|
|
146
|
+
var _a, _b;
|
|
147
|
+
const xcodeProject = newConfig.modResults;
|
|
166
148
|
// Create new PBXGroup for the extension
|
|
167
|
-
const extGroup = xcodeProject.addPbxGroup([...
|
|
149
|
+
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
150
|
// Add the new PBXGroup to the top level group. This makes the
|
|
169
151
|
// files / folder appear in the file explorer in Xcode.
|
|
170
152
|
const groups = xcodeProject.hash.project.objects["PBXGroup"];
|
|
@@ -182,11 +164,11 @@ function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
|
182
164
|
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
|
|
183
165
|
if (!!xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) {
|
|
184
166
|
OneSignalLog_1.OneSignalLog.log(`${iosConstants_1.NSE_TARGET_NAME} already exists in project. Skipping...`);
|
|
185
|
-
return;
|
|
167
|
+
return newConfig;
|
|
186
168
|
}
|
|
187
169
|
// Add the NSE target
|
|
188
170
|
// 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}`);
|
|
171
|
+
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
172
|
// Add build phases to the new target
|
|
191
173
|
xcodeProject.addBuildPhase(["NotificationService.m"], "PBXSourcesBuildPhase", "Sources", nseTarget.uuid);
|
|
192
174
|
xcodeProject.addBuildPhase([], "PBXResourcesBuildPhase", "Resources", nseTarget.uuid);
|
|
@@ -198,17 +180,27 @@ function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
|
198
180
|
if (typeof configurations[key].buildSettings !== "undefined" &&
|
|
199
181
|
configurations[key].buildSettings.PRODUCT_NAME == `"${iosConstants_1.NSE_TARGET_NAME}"`) {
|
|
200
182
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
201
|
-
buildSettingsObj.DEVELOPMENT_TEAM = devTeam;
|
|
202
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iPhoneDeploymentTarget !== null &&
|
|
183
|
+
buildSettingsObj.DEVELOPMENT_TEAM = props === null || props === void 0 ? void 0 : props.devTeam;
|
|
184
|
+
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
185
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = iosConstants_1.TARGETED_DEVICE_FAMILY;
|
|
204
186
|
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_TARGET_NAME}.entitlements`;
|
|
205
187
|
buildSettingsObj.CODE_SIGN_STYLE = "Automatic";
|
|
206
188
|
}
|
|
207
189
|
}
|
|
208
190
|
// Add development teams to both your target and the original project
|
|
209
|
-
xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam, nseTarget);
|
|
210
|
-
xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam);
|
|
211
|
-
|
|
191
|
+
xcodeProject.addTargetAttribute("DevelopmentTeam", props === null || props === void 0 ? void 0 : props.devTeam, nseTarget);
|
|
192
|
+
xcodeProject.addTargetAttribute("DevelopmentTeam", props === null || props === void 0 ? void 0 : props.devTeam);
|
|
193
|
+
return newConfig;
|
|
212
194
|
});
|
|
213
|
-
}
|
|
214
|
-
|
|
195
|
+
};
|
|
196
|
+
const withOneSignalIos = (config, props) => {
|
|
197
|
+
config = withAppEnvironment(config, props);
|
|
198
|
+
config = withRemoteNotificationsPermissions(config, props);
|
|
199
|
+
config = withAppGroupPermissions(config, props);
|
|
200
|
+
config = withOneSignalPodfile(config, props);
|
|
201
|
+
config = withOneSignalNSE(config, props);
|
|
202
|
+
config = withOneSignalXcodeProject(config, props);
|
|
203
|
+
config = withEasManagedCredentials(config, props);
|
|
204
|
+
return config;
|
|
205
|
+
};
|
|
206
|
+
exports.withOneSignalIos = withOneSignalIos;
|
|
@@ -1,6 +1,6 @@
|
|
|
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 = `
|
|
@@ -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
|
+
];
|
|
@@ -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": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
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": {
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"typescript": "^4.5.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"xcode": "^3.0.1",
|
|
45
44
|
"@expo/image-utils": "^0.3.22"
|
|
46
45
|
}
|
|
47
46
|
}
|
package/support/iosConstants.ts
CHANGED
|
@@ -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
|
-
);
|