onesignal-expo-plugin 1.0.1 → 1.0.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/IOS_CREDENTIALS_EAS.md +57 -25
- package/build/onesignal/withOneSignalIos.js +11 -2
- package/build/support/NseUpdaterManager.js +1 -2
- package/build/support/eas/getEasManagedCredentialsConfigExtra.js +35 -0
- package/build/support/iosConstants.js +1 -2
- package/build/support/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements +0 -2
- package/onesignal/withOneSignalIos.ts +14 -4
- package/package.json +3 -2
- package/support/NseUpdaterManager.ts +1 -4
- package/support/eas/getEasManagedCredentialsConfigExtra.ts +33 -0
- package/support/iosConstants.ts +0 -1
- package/support/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements +0 -2
package/IOS_CREDENTIALS_EAS.md
CHANGED
|
@@ -5,20 +5,55 @@ To distribute your iOS application, you must set up all the credentials required
|
|
|
5
5
|
* Provisioning profiles
|
|
6
6
|
* Push notification certificate
|
|
7
7
|
|
|
8
|
-
If you are using EAS, you may be letting Expo handle all your credentials. This is fine for your distribution and provisioning credentials. However, the push notification certificate *must* be
|
|
8
|
+
If you are using EAS, you may be letting Expo handle all your credentials. This is fine for your distribution and provisioning credentials. However, the push notification certificate *must* be set up separately since you are using OneSignal.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Push Notification Certificate
|
|
11
|
+
To set up OneSignal on iOS, you will need a [push notification certificate](https://documentation.onesignal.com/docs/generate-an-ios-push-certificate). The push certificate is used to send notifications to devices and has nothing to do with the build process. After you have uploaded the certificate to OneSignal, it should just work.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
### Capabilities
|
|
14
|
+
As of eas-cli `v0.52.0`, the previous capabilities issues should now be resolved. See the [release notes](https://github.com/expo/eas-cli/releases/tag/v0.52.0) for details.
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
You can still view the old instructions by clicking below.
|
|
17
|
+
|
|
18
|
+
<details>
|
|
19
|
+
<summary>Click to expand</summary>
|
|
16
20
|
|
|
17
21
|
---
|
|
22
|
+
To receive notifications, you must add the `aps-environment` capability (Push Notifications) to your app at build time. The OneSignal plugin tries to facilitate this as much as possible but there could be complications if you added other capabilities/entitlements or another config plugin did. This is because EAS doesn't currently respect entitlement files on a per-target basis. If there are more than one entitlements files, it simply picks one and applies it to both targets.
|
|
23
|
+
|
|
24
|
+
Due to this, there are two setup paths:
|
|
25
|
+
1. A **simple setup** is one in which the only [capability](https://docs.expo.dev/build-reference/ios-capabilities/) on your main target is "Push Notifications."
|
|
26
|
+
2. A more **complex setup** is one in which you have other capabilities.
|
|
27
|
+
|
|
28
|
+
This also affects how you should set up your credentials. Use the following table to know whether to proceed with local or managed credentials:
|
|
29
|
+
| Push Notification capability only | |
|
|
30
|
+
|-----------------------------------|-----------------------------------------------------------------------|
|
|
31
|
+
| Local credentials | Works but unnecessary to go through extra effort to use local signing |
|
|
32
|
+
| Managed credentials | Works (simple setup) |
|
|
33
|
+
|
|
34
|
+
| Multiple capabilities | |
|
|
35
|
+
|-----------------------|----------------------------------|
|
|
36
|
+
| Local credentials | Works but requires complex setup |
|
|
37
|
+
| Managed credentials | Works unreliably |
|
|
38
|
+
|
|
39
|
+
If you are unsure, run `expo prebuild` and look at the native entitlements file of your main target (in `ios` directory). Other config plugins may be adding capabilities here. Or check the full [capabilities](https://docs.expo.dev/build-reference/ios-capabilities/#supported-capabilities) list supported by Expo.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
#### Simple setup explanation
|
|
43
|
+
Since there is only one capability (Push Notifications) required by your app, everything should just work. OneSignal will automatically add the capability to your app along with the necessary App Groups and EAS should sync them with your Apple Developer account. You can choose to use managed signing on EAS without a problem. This works because OneSignal will add the capability to both targets' entitlements files.
|
|
44
|
+
|
|
45
|
+
#### Complex setup explanation
|
|
46
|
+
Having additional capabilities on your app will result in a more complex setup, including having to use local credentials. The following is an explanation of why. It is not imperative to understand but we have included it for context.
|
|
47
|
+
|
|
48
|
+
The OneSignal plugin will create an additional target: `OneSignalNotificationServiceExtension`. This target is the iOS service extension that adds support for Confirmed Deliveries, badges, media attachments, action buttons, and influenced opens (Firebase Analytics). Learn more [here](https://documentation.onesignal.com/docs/service-extensions). The plugin will automatically add app groups to both targets' entitlements files which are required if you want to make use of these features. They allow your app to execute code when a notification is received, even if your app is not active.
|
|
18
49
|
|
|
19
|
-
|
|
50
|
+
Each target has an entitlement file. If there are multiple entitlements files per project, EAS will randomly pick one and apply it to both targets. To mitigate this, we have added the push capability entilement to both files (even though it's really only necessary in the main target). This can still pose a problem if it picks the NSE's entitlements file since it *could* break any other capabilities in your project, given that file will not have capabilities added to your main target by yourself or other plugins.
|
|
20
51
|
|
|
21
|
-
|
|
52
|
+
The following section details how to mitigate these issues and not break your other capabilities.
|
|
53
|
+
|
|
54
|
+
## Complex Setup
|
|
55
|
+
|
|
56
|
+
### 1. Credentials setup
|
|
22
57
|
To build successfully, you will need to create and use local credentials (one for production and development). Add `"credentialsSource": "local"` to your `eas.json` file.
|
|
23
58
|
|
|
24
59
|
**Example:**
|
|
@@ -39,23 +74,20 @@ To build successfully, you will need to create and use local credentials (one fo
|
|
|
39
74
|
"distribution": "internal",
|
|
40
75
|
"credentialsSource": "local"
|
|
41
76
|
}
|
|
42
|
-
},
|
|
43
|
-
"cli": {
|
|
44
|
-
"version": ">= 0.40.0"
|
|
45
77
|
}
|
|
46
78
|
}
|
|
47
79
|
```
|
|
48
80
|
|
|
49
|
-
|
|
81
|
+
### 2. Identifiers
|
|
50
82
|
In your [Apple developer console](https://developer.apple.com) create two identifiers with the following format:
|
|
51
|
-
-
|
|
52
|
-
-
|
|
83
|
+
- `<com.example.app>` <-- you likely already have this one
|
|
84
|
+
- `<com.example.app>.OneSignalNotificationServiceExtension`
|
|
53
85
|
|
|
54
|
-
|
|
86
|
+
#### When modifying your existing main app identifier:
|
|
55
87
|
- add the App Groups capability like so: `group.<identifier>.onesignal`
|
|
56
88
|
- keep / add the "Push Notifications" capability
|
|
57
89
|
|
|
58
|
-
|
|
90
|
+
#### When creating a new identifier for `OneSignalNotificationServiceExtension`:
|
|
59
91
|
- select AppId from the list of identifier types
|
|
60
92
|
- select App when choosing between App and App Clip
|
|
61
93
|
- add the App Groups capability like so: `group.<identifier>.onesignal`
|
|
@@ -64,10 +96,10 @@ In your [Apple developer console](https://developer.apple.com) create two identi
|
|
|
64
96
|
#### Note on App Groups at Build Time:
|
|
65
97
|
Make sure to build with both identifiers containing the AppGroup simultaneously. To troubleshoot, remove them both and then rebuild with both identifiers' AppGroup capabilities enabled.
|
|
66
98
|
|
|
67
|
-
|
|
99
|
+
### 3. Provisioning
|
|
68
100
|
Create AdHoc (local development) and AppStore (production) provisioning profiles with both identifiers (four provisioning profiles total). Both provisioning profiles should use the same distribution certificate that is used by your app. Download the profiles.
|
|
69
101
|
|
|
70
|
-
|
|
102
|
+
### 4. Add the profiles to your `credentials.json` file:
|
|
71
103
|
Use the same distribution certificate for the `OneSignalNotificationServiceExtension` as is used for your app (no need to create a new cert).
|
|
72
104
|
|
|
73
105
|
We recommend creating a `certs` directory in your project with subdirectories for each build type (e.g: `certs/adhoc` & `certs/appstore`). Doing so, you can more easily switch which provisioning profiles get used at build time.
|
|
@@ -103,16 +135,20 @@ We recommend creating a `certs` directory in your project with subdirectories fo
|
|
|
103
135
|
|
|
104
136
|
**Note:** your push certificate (p12) file should not appear anywhere in the `credentials.json` file.
|
|
105
137
|
|
|
106
|
-
|
|
138
|
+
## Build (complex setup continued)
|
|
139
|
+
|
|
140
|
+
**IMPORTANT**: run the `eas build` command with `EXPO_NO_CAPABILITY_SYNC` if you want to prevent EAS from syncing capabilities (e.g: overwriting the steps you took in the complex setup).
|
|
107
141
|
|
|
108
|
-
# Build
|
|
109
142
|
### Release
|
|
110
143
|
If you are ready for a production build, you should use the AppStore provisioning profiles you created. Make sure your `credentials.json` file is using the correct profiles.
|
|
111
144
|
|
|
112
145
|
### Development
|
|
113
146
|
The development build will use the AdHoc provisioning profiles you created. Make sure your `credentials.json` file is using the correct profiles.
|
|
114
147
|
|
|
115
|
-
|
|
148
|
+
---
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
### Expo development client
|
|
116
152
|
If you haven't already, add the expo development client to your project:
|
|
117
153
|
|
|
118
154
|
```sh
|
|
@@ -121,8 +157,6 @@ expo install expo-dev-client
|
|
|
121
157
|
|
|
122
158
|
Make sure `"developmentClient": true,` is set in your `eas.json` development build profile.
|
|
123
159
|
|
|
124
|
-
## All Builds
|
|
125
|
-
|
|
126
160
|
### Run the EAS build command
|
|
127
161
|
```sh
|
|
128
162
|
eas build --profile <build profile> --platform ios
|
|
@@ -132,7 +166,5 @@ where `<build profile>` refers to the build profile in your `eas.json` file (e.g
|
|
|
132
166
|
### Build success
|
|
133
167
|
At this point, your build should succeed. You can check its progress by opening the build link in the terminal.
|
|
134
168
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
# How to run on your device
|
|
169
|
+
## How to run on your device
|
|
138
170
|
See our [EAS guide](EAS.md) for instructions.
|
|
@@ -35,6 +35,8 @@ const updatePodfile_1 = require("../support/updatePodfile");
|
|
|
35
35
|
const NseUpdaterManager_1 = __importDefault(require("../support/NseUpdaterManager"));
|
|
36
36
|
const OneSignalLog_1 = require("../support/OneSignalLog");
|
|
37
37
|
const FileManager_1 = require("../support/FileManager");
|
|
38
|
+
const assert_1 = __importDefault(require("assert"));
|
|
39
|
+
const getEasManagedCredentialsConfigExtra_1 = __importDefault(require("../support/eas/getEasManagedCredentialsConfigExtra"));
|
|
38
40
|
/**
|
|
39
41
|
* Add 'aps-environment' record with current environment to '<project-name>.entitlements' file
|
|
40
42
|
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
@@ -105,16 +107,23 @@ const withOneSignalNSE = (config, onesignalProps) => {
|
|
|
105
107
|
return props;
|
|
106
108
|
});
|
|
107
109
|
};
|
|
110
|
+
const withEasManagedCredentials = (config) => {
|
|
111
|
+
var _a;
|
|
112
|
+
(0, assert_1.default)((_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.");
|
|
113
|
+
config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config);
|
|
114
|
+
return config;
|
|
115
|
+
};
|
|
108
116
|
const withOneSignalIos = (config, props) => {
|
|
109
117
|
withAppEnvironment(config, props);
|
|
110
118
|
withRemoteNotificationsPermissions(config, props);
|
|
111
119
|
withAppGroupPermissions(config, props);
|
|
112
120
|
withOneSignalNSE(config, props);
|
|
121
|
+
withEasManagedCredentials(config, props);
|
|
113
122
|
return config;
|
|
114
123
|
};
|
|
115
124
|
exports.withOneSignalIos = withOneSignalIos;
|
|
116
125
|
function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
117
|
-
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget
|
|
126
|
+
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options;
|
|
118
127
|
// not awaiting in order to not block main thread
|
|
119
128
|
(0, updatePodfile_1.updatePodfile)(iosPath).catch(err => { OneSignalLog_1.OneSignalLog.error(err); });
|
|
120
129
|
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
@@ -139,7 +148,7 @@ function xcodeProjectAddNse(appName, options, sourceDir) {
|
|
|
139
148
|
}
|
|
140
149
|
/* MODIFY COPIED EXTENSION FILES */
|
|
141
150
|
const nseUpdater = new NseUpdaterManager_1.default(iosPath);
|
|
142
|
-
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal
|
|
151
|
+
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`);
|
|
143
152
|
await nseUpdater.updateNSEBundleVersion(bundleVersion !== null && bundleVersion !== void 0 ? bundleVersion : iosConstants_1.DEFAULT_BUNDLE_VERSION);
|
|
144
153
|
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion !== null && bundleShortVersion !== void 0 ? bundleShortVersion : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
|
|
145
154
|
// Create new PBXGroup for the extension
|
|
@@ -10,10 +10,9 @@ class NseUpdaterManager {
|
|
|
10
10
|
this.nsePath = '';
|
|
11
11
|
this.nsePath = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`;
|
|
12
12
|
}
|
|
13
|
-
async updateNSEEntitlements(groupIdentifier
|
|
13
|
+
async updateNSEEntitlements(groupIdentifier) {
|
|
14
14
|
const entitlementsFilePath = `${this.nsePath}/${entitlementsFileName}`;
|
|
15
15
|
let entitlementsFile = await FileManager_1.FileManager.readFile(entitlementsFilePath);
|
|
16
|
-
entitlementsFile = entitlementsFile.replace(iosConstants_1.APS_ENVIRONMENT_MODE, mode);
|
|
17
16
|
entitlementsFile = entitlementsFile.replace(iosConstants_1.GROUP_IDENTIFIER_TEMPLATE_REGEX, groupIdentifier);
|
|
18
17
|
await FileManager_1.FileManager.writeFile(entitlementsFilePath, entitlementsFile);
|
|
19
18
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const iosConstants_1 = require("../iosConstants");
|
|
4
|
+
function getEasManagedCredentialsConfigExtra(config) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
6
|
+
return {
|
|
7
|
+
...config.extra,
|
|
8
|
+
eas: {
|
|
9
|
+
...(_a = config.extra) === null || _a === void 0 ? void 0 : _a.eas,
|
|
10
|
+
build: {
|
|
11
|
+
...(_c = (_b = config.extra) === null || _b === void 0 ? void 0 : _b.eas) === null || _c === void 0 ? void 0 : _c.build,
|
|
12
|
+
experimental: {
|
|
13
|
+
...(_f = (_e = (_d = config.extra) === null || _d === void 0 ? void 0 : _d.eas) === null || _e === void 0 ? void 0 : _e.build) === null || _f === void 0 ? void 0 : _f.experimental,
|
|
14
|
+
ios: {
|
|
15
|
+
...(_k = (_j = (_h = (_g = config.extra) === null || _g === void 0 ? void 0 : _g.eas) === null || _h === void 0 ? void 0 : _h.build) === null || _j === void 0 ? void 0 : _j.experimental) === null || _k === void 0 ? void 0 : _k.ios,
|
|
16
|
+
appExtensions: [
|
|
17
|
+
...((_r = (_q = (_p = (_o = (_m = (_l = config.extra) === null || _l === void 0 ? void 0 : _l.eas) === null || _m === void 0 ? void 0 : _m.build) === null || _o === void 0 ? void 0 : _o.experimental) === null || _p === void 0 ? void 0 : _p.ios) === null || _q === void 0 ? void 0 : _q.appExtensions) !== null && _r !== void 0 ? _r : []),
|
|
18
|
+
{
|
|
19
|
+
// keep in sync with native changes in NSE
|
|
20
|
+
targetName: iosConstants_1.NSE_TARGET_NAME,
|
|
21
|
+
bundleIdentifier: `${(_s = config === null || config === void 0 ? void 0 : config.ios) === null || _s === void 0 ? void 0 : _s.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`,
|
|
22
|
+
entitlements: {
|
|
23
|
+
'com.apple.security.application-groups': [
|
|
24
|
+
`group.${(_t = config === null || config === void 0 ? void 0 : config.ios) === null || _t === void 0 ? void 0 : _t.bundleIdentifier}.onesignal`
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.default = getEasManagedCredentialsConfigExtra;
|
|
@@ -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.
|
|
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;
|
|
4
4
|
exports.IPHONEOS_DEPLOYMENT_TARGET = "11.0";
|
|
5
5
|
exports.TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
6
6
|
exports.NSE_PODFILE_SNIPPET = `
|
|
@@ -9,7 +9,6 @@ target 'OneSignalNotificationServiceExtension' do
|
|
|
9
9
|
end`;
|
|
10
10
|
exports.NSE_PODFILE_REGEX = /target 'OneSignalNotificationServiceExtension'/;
|
|
11
11
|
exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
12
|
-
exports.APS_ENVIRONMENT_MODE = /{{APS_ENVIRONMENT_MODE}}/gm;
|
|
13
12
|
exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
14
13
|
exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
15
14
|
exports.DEFAULT_BUNDLE_VERSION = '1';
|
package/build/support/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
3
|
<plist version="1.0">
|
|
4
4
|
<dict>
|
|
5
|
-
<key>aps-environment</key>
|
|
6
|
-
<string>{{APS_ENVIRONMENT_MODE}}</string>
|
|
7
5
|
<key>com.apple.security.application-groups</key>
|
|
8
6
|
<array>
|
|
9
7
|
<string>{{GROUP_IDENTIFIER}}</string>
|
|
@@ -23,6 +23,9 @@ import NseUpdaterManager from "../support/NseUpdaterManager";
|
|
|
23
23
|
import { OneSignalLog } from "../support/OneSignalLog";
|
|
24
24
|
import { FileManager } from "../support/FileManager";
|
|
25
25
|
import { OneSignalPluginProps, PluginOptions } from "../types/types";
|
|
26
|
+
import assert from 'assert';
|
|
27
|
+
import getEasManagedCredentialsConfigExtra from "../support/eas/getEasManagedCredentialsConfigExtra";
|
|
28
|
+
import { ExpoConfig } from '@expo/config-types';
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Add 'aps-environment' record with current environment to '<project-name>.entitlements' file
|
|
@@ -112,6 +115,12 @@ const withOneSignalNSE: ConfigPlugin<OneSignalPluginProps> = (config, onesignalP
|
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
117
|
|
|
118
|
+
const withEasManagedCredentials: ConfigPlugin<OneSignalPluginProps> = (config) => {
|
|
119
|
+
assert(config.ios?.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.")
|
|
120
|
+
config.extra = getEasManagedCredentialsConfigExtra(config as ExpoConfig);
|
|
121
|
+
return config;
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
export const withOneSignalIos: ConfigPlugin<OneSignalPluginProps> = (
|
|
116
125
|
config,
|
|
117
126
|
props
|
|
@@ -120,6 +129,7 @@ export const withOneSignalIos: ConfigPlugin<OneSignalPluginProps> = (
|
|
|
120
129
|
withRemoteNotificationsPermissions(config, props);
|
|
121
130
|
withAppGroupPermissions(config, props);
|
|
122
131
|
withOneSignalNSE(config, props);
|
|
132
|
+
withEasManagedCredentials(config, props);
|
|
123
133
|
return config;
|
|
124
134
|
};
|
|
125
135
|
|
|
@@ -128,7 +138,7 @@ export function xcodeProjectAddNse(
|
|
|
128
138
|
options: PluginOptions,
|
|
129
139
|
sourceDir: string
|
|
130
140
|
): void {
|
|
131
|
-
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget
|
|
141
|
+
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options;
|
|
132
142
|
|
|
133
143
|
// not awaiting in order to not block main thread
|
|
134
144
|
updatePodfile(iosPath).catch(err => { OneSignalLog.error(err) });
|
|
@@ -153,7 +163,7 @@ export function xcodeProjectAddNse(
|
|
|
153
163
|
/* COPY OVER EXTENSION FILES */
|
|
154
164
|
fs.mkdirSync(`${iosPath}/${NSE_TARGET_NAME}`, { recursive: true });
|
|
155
165
|
|
|
156
|
-
for(let i = 0; i < extFiles.length; i++) {
|
|
166
|
+
for (let i = 0; i < extFiles.length; i++) {
|
|
157
167
|
const extFile = extFiles[i];
|
|
158
168
|
const targetFile = `${iosPath}/${NSE_TARGET_NAME}/${extFile}`;
|
|
159
169
|
await FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
|
|
@@ -161,7 +171,7 @@ export function xcodeProjectAddNse(
|
|
|
161
171
|
|
|
162
172
|
/* MODIFY COPIED EXTENSION FILES */
|
|
163
173
|
const nseUpdater = new NseUpdaterManager(iosPath);
|
|
164
|
-
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal
|
|
174
|
+
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`)
|
|
165
175
|
await nseUpdater.updateNSEBundleVersion(bundleVersion ?? DEFAULT_BUNDLE_VERSION);
|
|
166
176
|
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion ?? DEFAULT_BUNDLE_SHORT_VERSION);
|
|
167
177
|
|
|
@@ -171,7 +181,7 @@ export function xcodeProjectAddNse(
|
|
|
171
181
|
// Add the new PBXGroup to the top level group. This makes the
|
|
172
182
|
// files / folder appear in the file explorer in Xcode.
|
|
173
183
|
const groups = xcodeProject.hash.project.objects["PBXGroup"];
|
|
174
|
-
Object.keys(groups).forEach(function
|
|
184
|
+
Object.keys(groups).forEach(function(key) {
|
|
175
185
|
if (groups[key].name === undefined) {
|
|
176
186
|
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
177
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.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": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"contributors": [
|
|
25
25
|
"Karen Grigoryan",
|
|
26
26
|
"Rodrigo Gomez-Palacio",
|
|
27
|
-
"Charlie Cruzan"
|
|
27
|
+
"Charlie Cruzan",
|
|
28
|
+
"Wojciech Kozyra"
|
|
28
29
|
],
|
|
29
30
|
"license": "MIT",
|
|
30
31
|
"bugs": {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Mode } from '../types/types';
|
|
2
1
|
import { FileManager } from './FileManager';
|
|
3
2
|
import {
|
|
4
|
-
APS_ENVIRONMENT_MODE,
|
|
5
3
|
BUNDLE_SHORT_VERSION_TEMPLATE_REGEX,
|
|
6
4
|
BUNDLE_VERSION_TEMPLATE_REGEX,
|
|
7
5
|
GROUP_IDENTIFIER_TEMPLATE_REGEX,
|
|
@@ -18,11 +16,10 @@ export default class NseUpdaterManager {
|
|
|
18
16
|
this.nsePath = `${iosPath}/${NSE_TARGET_NAME}`;
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
async updateNSEEntitlements(groupIdentifier: string
|
|
19
|
+
async updateNSEEntitlements(groupIdentifier: string): Promise<void> {
|
|
22
20
|
const entitlementsFilePath = `${this.nsePath}/${entitlementsFileName}`;
|
|
23
21
|
let entitlementsFile = await FileManager.readFile(entitlementsFilePath);
|
|
24
22
|
|
|
25
|
-
entitlementsFile = entitlementsFile.replace(APS_ENVIRONMENT_MODE, mode);
|
|
26
23
|
entitlementsFile = entitlementsFile.replace(GROUP_IDENTIFIER_TEMPLATE_REGEX, groupIdentifier);
|
|
27
24
|
await FileManager.writeFile(entitlementsFilePath, entitlementsFile);
|
|
28
25
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NSE_TARGET_NAME } from "../iosConstants";
|
|
2
|
+
import { ExpoConfig } from '@expo/config-types';
|
|
3
|
+
|
|
4
|
+
export default function getEasManagedCredentialsConfigExtra(config: ExpoConfig): {[k: string]: any} {
|
|
5
|
+
return {
|
|
6
|
+
...config.extra,
|
|
7
|
+
eas: {
|
|
8
|
+
...config.extra?.eas,
|
|
9
|
+
build: {
|
|
10
|
+
...config.extra?.eas?.build,
|
|
11
|
+
experimental: {
|
|
12
|
+
...config.extra?.eas?.build?.experimental,
|
|
13
|
+
ios: {
|
|
14
|
+
...config.extra?.eas?.build?.experimental?.ios,
|
|
15
|
+
appExtensions: [
|
|
16
|
+
...(config.extra?.eas?.build?.experimental?.ios?.appExtensions ?? []),
|
|
17
|
+
{
|
|
18
|
+
// keep in sync with native changes in NSE
|
|
19
|
+
targetName: NSE_TARGET_NAME,
|
|
20
|
+
bundleIdentifier: `${config?.ios?.bundleIdentifier}.${NSE_TARGET_NAME}`,
|
|
21
|
+
entitlements: {
|
|
22
|
+
'com.apple.security.application-groups': [
|
|
23
|
+
`group.${config?.ios?.bundleIdentifier}.onesignal`
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/support/iosConstants.ts
CHANGED
|
@@ -9,7 +9,6 @@ end`;
|
|
|
9
9
|
export const NSE_PODFILE_REGEX = /target 'OneSignalNotificationServiceExtension'/;
|
|
10
10
|
|
|
11
11
|
export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
12
|
-
export const APS_ENVIRONMENT_MODE = /{{APS_ENVIRONMENT_MODE}}/gm;
|
|
13
12
|
export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
14
13
|
export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
15
14
|
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
3
|
<plist version="1.0">
|
|
4
4
|
<dict>
|
|
5
|
-
<key>aps-environment</key>
|
|
6
|
-
<string>{{APS_ENVIRONMENT_MODE}}</string>
|
|
7
5
|
<key>com.apple.security.application-groups</key>
|
|
8
6
|
<array>
|
|
9
7
|
<string>{{GROUP_IDENTIFIER}}</string>
|