onesignal-expo-plugin 1.0.0-beta8 → 1.0.1
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/.eslintignore +6 -0
- package/.eslintrc.js +18 -0
- package/.github/ISSUE_TEMPLATE/ask-question.yml +50 -0
- package/.github/ISSUE_TEMPLATE/bug-report.yml +71 -0
- package/.github/ISSUE_TEMPLATE/general-feedback.yml +27 -0
- package/CHANGELOG.md +42 -0
- package/EAS.md +21 -0
- package/IOS_CREDENTIALS_EAS.md +138 -0
- package/README.md +57 -16
- package/build/onesignal/withOneSignalAndroid.js +11 -15
- package/build/onesignal/withOneSignalIos.js +75 -41
- package/build/support/{ReaderManager.js → FileManager.js} +26 -8
- package/build/support/NseUpdaterManager.js +33 -0
- package/build/support/OneSignalLog.js +12 -0
- package/build/support/androidConstants.js +13 -0
- package/build/support/iosConstants.js +9 -3
- package/build/support/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist +2 -2
- package/build/support/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements +2 -0
- package/build/support/updatePodfile.js +5 -4
- package/build/testRuniOS.js +9 -1
- package/build/types/types.js +8 -0
- package/onesignal/withOneSignal.ts +1 -9
- package/onesignal/withOneSignalAndroid.ts +13 -19
- package/onesignal/withOneSignalIos.ts +65 -51
- package/package.json +8 -4
- package/support/FileManager.ts +38 -0
- package/support/NseUpdaterManager.ts +43 -0
- package/support/OneSignalLog.ts +9 -0
- package/support/androidConstants.ts +11 -0
- package/support/iosConstants.ts +10 -2
- package/support/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist +2 -2
- package/support/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements +2 -0
- package/support/updatePodfile.ts +5 -4
- package/testRuniOS.ts +13 -5
- package/types/types.ts +30 -0
- package/build/support/updateNSEEntitlements.js +0 -20
- package/support/ReaderManager.ts +0 -18
- package/support/updateNSEEntitlements.ts +0 -16
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
plugins: [
|
|
5
|
+
'@typescript-eslint',
|
|
6
|
+
],
|
|
7
|
+
parserOptions: {
|
|
8
|
+
project: "tsconfig.json",
|
|
9
|
+
},
|
|
10
|
+
extends: [
|
|
11
|
+
'eslint:recommended',
|
|
12
|
+
'plugin:@typescript-eslint/recommended',
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
16
|
+
"no-extra-boolean-cast": "off"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: 🙋♂️ Ask a question
|
|
2
|
+
description: Tell us what's on your mind
|
|
3
|
+
title: "[question]: "
|
|
4
|
+
labels: ["triage"]
|
|
5
|
+
# assignees:
|
|
6
|
+
# - assign your sdk team e.g., onesignal/unity
|
|
7
|
+
body:
|
|
8
|
+
- type: markdown
|
|
9
|
+
attributes:
|
|
10
|
+
value: |
|
|
11
|
+
Having issues integrating this SDK?
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: question
|
|
14
|
+
attributes:
|
|
15
|
+
label: How can we help?
|
|
16
|
+
description: Specific question regarding integrating this SDK.
|
|
17
|
+
placeholder: How do I...?
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: expo-sdk-version
|
|
22
|
+
attributes:
|
|
23
|
+
label: OneSignal Expo SDK version
|
|
24
|
+
description: The version of the OneSignal Expo SDK you have a question for.
|
|
25
|
+
placeholder: 1.0.0
|
|
26
|
+
validations:
|
|
27
|
+
required: true
|
|
28
|
+
- type: dropdown
|
|
29
|
+
id: platform
|
|
30
|
+
attributes:
|
|
31
|
+
label: Platform
|
|
32
|
+
description: Which platform are you having an issue with?
|
|
33
|
+
multiple: true
|
|
34
|
+
options:
|
|
35
|
+
- iOS
|
|
36
|
+
- Android
|
|
37
|
+
- type: textarea
|
|
38
|
+
id: logs
|
|
39
|
+
attributes:
|
|
40
|
+
label: Relevant log output
|
|
41
|
+
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
|
42
|
+
render: Shell
|
|
43
|
+
- type: checkboxes
|
|
44
|
+
id: terms
|
|
45
|
+
attributes:
|
|
46
|
+
label: Code of Conduct
|
|
47
|
+
description: By submitting this issue, you agree to follow our [Code of Conduct](#insert-project-code-of-conduct-here)
|
|
48
|
+
options:
|
|
49
|
+
- label: I agree to follow this project's Code of Conduct
|
|
50
|
+
required: true
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: 🪳 Bug Report
|
|
2
|
+
description: File a bug report
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: ["bug", "triage"]
|
|
5
|
+
# assignees:
|
|
6
|
+
# - assign your sdk team e.g., onesignal/unity
|
|
7
|
+
body:
|
|
8
|
+
- type: markdown
|
|
9
|
+
attributes:
|
|
10
|
+
value: |
|
|
11
|
+
Thanks for taking the time to fill out this bug report!
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: what-happened
|
|
14
|
+
attributes:
|
|
15
|
+
label: What happened?
|
|
16
|
+
description: Provide a thorough description of whats going on.
|
|
17
|
+
placeholder: The latest version of the SDK causes my screen to go blank when I tap on the screen three times.
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: reproduction-steps
|
|
22
|
+
attributes:
|
|
23
|
+
label: Steps to reproduce?
|
|
24
|
+
description: Provide as much detail as posible to reproduce the issue.
|
|
25
|
+
placeholder: |
|
|
26
|
+
1. Install vX.Y.Z of dependency
|
|
27
|
+
2. Launch the app on iOS device
|
|
28
|
+
3. Tap the screen three times
|
|
29
|
+
4. Note that the app crashes
|
|
30
|
+
render: Markdown
|
|
31
|
+
validations:
|
|
32
|
+
required: true
|
|
33
|
+
- type: textarea
|
|
34
|
+
id: what-are-expectations
|
|
35
|
+
attributes:
|
|
36
|
+
label: What did you expect to happen?
|
|
37
|
+
description: Also tell us, what did you expect to happen?
|
|
38
|
+
placeholder: I expected the app to continue running no matter how many times I tap the screen.
|
|
39
|
+
validations:
|
|
40
|
+
required: true
|
|
41
|
+
- type: textarea
|
|
42
|
+
id: expo-sdk-version
|
|
43
|
+
attributes:
|
|
44
|
+
label: OneSignal Expo SDK version
|
|
45
|
+
description: The version of the OneSignal Expo SDK used in your app.
|
|
46
|
+
placeholder: 1.0.0
|
|
47
|
+
validations:
|
|
48
|
+
required: true
|
|
49
|
+
- type: dropdown
|
|
50
|
+
id: platform
|
|
51
|
+
attributes:
|
|
52
|
+
label: Platform
|
|
53
|
+
description: Which platform are you having an issue with?
|
|
54
|
+
multiple: true
|
|
55
|
+
options:
|
|
56
|
+
- iOS
|
|
57
|
+
- Android
|
|
58
|
+
- type: textarea
|
|
59
|
+
id: logs
|
|
60
|
+
attributes:
|
|
61
|
+
label: Relevant log output
|
|
62
|
+
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
|
63
|
+
render: Shell
|
|
64
|
+
- type: checkboxes
|
|
65
|
+
id: terms
|
|
66
|
+
attributes:
|
|
67
|
+
label: Code of Conduct
|
|
68
|
+
description: By submitting this issue, you agree to follow our [Code of Conduct](#insert-project-code-of-conduct-here)
|
|
69
|
+
options:
|
|
70
|
+
- label: I agree to follow this project's Code of Conduct
|
|
71
|
+
required: true
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: 📣 General feedback
|
|
2
|
+
description: Tell us what's on your mind
|
|
3
|
+
title: "[feedback]: "
|
|
4
|
+
labels: ["triage"]
|
|
5
|
+
# assignees:
|
|
6
|
+
# - assign your sdk team e.g., onesignal/unity
|
|
7
|
+
body:
|
|
8
|
+
- type: markdown
|
|
9
|
+
attributes:
|
|
10
|
+
value: |
|
|
11
|
+
Thanks for sharing your valuable feedback!
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: feedback
|
|
14
|
+
attributes:
|
|
15
|
+
label: What's on your mind?
|
|
16
|
+
description: Feedback regarding this SDK.
|
|
17
|
+
placeholder: Share your feedback...
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: checkboxes
|
|
21
|
+
id: terms
|
|
22
|
+
attributes:
|
|
23
|
+
label: Code of Conduct
|
|
24
|
+
description: By submitting this issue, you agree to follow our [Code of Conduct](#insert-project-code-of-conduct-here)
|
|
25
|
+
options:
|
|
26
|
+
- label: I agree to follow this project's Code of Conduct
|
|
27
|
+
required: true
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
## April 2022
|
|
5
|
+
### `1.0.1` - 04/11/22
|
|
6
|
+
|
|
7
|
+
#### Changes
|
|
8
|
+
- Add more info regarding the `expo prebuild` command to README.
|
|
9
|
+
#### Fixes
|
|
10
|
+
- Upstream EAS workaround for "Missing Push Capability on iOS" issue. Adds `aps-environment` entitlement to NSE template. Although it is **not** required in normal builds, there is an upstream limitation from EAS that is resolved by including the push entitlement in both target entitlement files. As of 4/8/22, EAS builds will randomly pick an entitlement file if there are multiple in a project without differentiating among targets. This is resulting in flaky builds where half the time they work and half the time they don't. This can be seen as a temporary fix. Note it carries no side-effects / repercussions (i.e: the entitlement is superfluous but not critical to remove in the future).
|
|
11
|
+
|
|
12
|
+
## March 2022
|
|
13
|
+
### `1.0.0` - 03/28/22
|
|
14
|
+
|
|
15
|
+
#### Fixes
|
|
16
|
+
- Upgrade dependencies (via dependabot)
|
|
17
|
+
#### Changes
|
|
18
|
+
- Add credentials guide and update README
|
|
19
|
+
- Advance to General Availability
|
|
20
|
+
|
|
21
|
+
## February 2022
|
|
22
|
+
### `1.0.0-beta11` - 02/18/2022
|
|
23
|
+
#### Added
|
|
24
|
+
- Linting
|
|
25
|
+
- Instead of creating a "WriterManager", we repurpose the ReaderManager class by renaming it to FileManager and adding a synchronized write helper function (synchronous in the sense that it block further execution until complete).
|
|
26
|
+
- iOS constants file
|
|
27
|
+
|
|
28
|
+
#### Fixes
|
|
29
|
+
- Import cleanups
|
|
30
|
+
- Linting errors
|
|
31
|
+
- Write safety issu. NSE updater helper functions were previously writing to the entitlements & plist files asynchronously. We should await on each to ensure we don't have multiple writes to the same file at once (which is unsafe).
|
|
32
|
+
|
|
33
|
+
## January 2022
|
|
34
|
+
|
|
35
|
+
### `1.0.0-beta10` - 01/24/2022
|
|
36
|
+
#### Added
|
|
37
|
+
- ability to configure version numbers used in the NSE target's plist file.
|
|
38
|
+
- `OneSignalLog` class for better console logging.
|
|
39
|
+
- this changelog file.
|
|
40
|
+
|
|
41
|
+
#### Fixed
|
|
42
|
+
- re-running `expo prebuild` will no longer result in duplicate entitlements and dependencies added to native files.
|
package/EAS.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Expo Application Services
|
|
2
|
+
EAS is Expo's cloud-build service.
|
|
3
|
+
|
|
4
|
+
## [EAS Homepage](https://expo.dev/eas)
|
|
5
|
+
|
|
6
|
+
## EAS + OneSignal Setup
|
|
7
|
+
To get OneSignal push notifications working in an EAS-built app, see our guide on how to configure your [iOS credentials](IOS_CREDENTIALS_EAS.md).
|
|
8
|
+
|
|
9
|
+
## How to run an iOS EAS-built app
|
|
10
|
+
### Run in a production environment
|
|
11
|
+
For production builds, your generated ipa file should to be distributed to the App Store or Testflight.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Run in custom development client
|
|
15
|
+
For development/internal distribution builds, you will need to install a [development client](https://docs.expo.dev/development/getting-started/) on your iOS device.
|
|
16
|
+
|
|
17
|
+
1. Scan the QR code shown in the terminal after EAS build success and install the development client application to your device.
|
|
18
|
+
2. In the terminal, run `expo start --dev-client` to be able to serve the application to the client.
|
|
19
|
+
3. Scan the generated QR code to open the dev client and fetch the app bundle from the running Expo process.
|
|
20
|
+
4. You may be prompted to allow the app to find local area network devices. Approve.
|
|
21
|
+
5. Rescan the QR code & open the app. At this point, you should see the mero bundler working. As soon as the bundle is complete, your working app should open!
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# iOS Credentials Guide: OneSignal + EAS
|
|
2
|
+
## Overview
|
|
3
|
+
To distribute your iOS application, you must set up all the credentials required by Apple. The 3 primary iOS credentials are:
|
|
4
|
+
* Distribution certificate
|
|
5
|
+
* Provisioning profiles
|
|
6
|
+
* Push notification certificate
|
|
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 handled separately since you are using OneSignal.
|
|
9
|
+
|
|
10
|
+
As of 3/22/2022, OneSignal does not support p8 files and EAS does not support p12 files which results in a particlar issue when cloud building through EAS while using the Expo managed credentials service. Since the EAS CLI only prompts for p8 files at the time of writing, the only way to complete the cloud build is to input "n" (no) when prompted for setting up push notifications through the CLI. However, this leads to the identifier not having the push capability required to set up push successfully. Until EAS adds more granular control over credentials or OneSignal adds p8 support or Expo adds p12 support, developers will have no option except to use local credentials only.
|
|
11
|
+
|
|
12
|
+
If you have developed on iOS before, you may be used to XCode helping with syncing things like capabilities across app targets. In Expo/EAS, we are likely not using XCode at all. Thus, we need to make sure that we set up everything manually via the Apple Developers portal.
|
|
13
|
+
|
|
14
|
+
### TLDR
|
|
15
|
+
To set up push notifications with OneSignal + Expo, you *must* manage all credentials yourself and use local credentials when cloud building through EAS.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Setup
|
|
20
|
+
|
|
21
|
+
## 1. Credentials setup
|
|
22
|
+
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
|
+
|
|
24
|
+
**Example:**
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"build": {
|
|
28
|
+
"release": {
|
|
29
|
+
"android": {
|
|
30
|
+
"gradleCommand": ":app:bundleRelease"
|
|
31
|
+
},
|
|
32
|
+
"ios": {
|
|
33
|
+
"credentialsSource": "local",
|
|
34
|
+
"buildConfiguration": "Release"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"development": {
|
|
38
|
+
"developmentClient": true,
|
|
39
|
+
"distribution": "internal",
|
|
40
|
+
"credentialsSource": "local"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"cli": {
|
|
44
|
+
"version": ">= 0.40.0"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 2. Identifiers
|
|
50
|
+
In your [Apple developer console](https://developer.apple.com) create two identifiers with the following format:
|
|
51
|
+
- `com.example.app` <-- you likely already have this one
|
|
52
|
+
- `com.example.app.OneSignalNotificationServiceExtension`
|
|
53
|
+
|
|
54
|
+
### When modifying your existing main app identifier:
|
|
55
|
+
- add the App Groups capability like so: `group.<identifier>.onesignal`
|
|
56
|
+
- keep / add the "Push Notifications" capability
|
|
57
|
+
|
|
58
|
+
### When creating a new identifier for `OneSignalNotificationServiceExtension`:
|
|
59
|
+
- select AppId from the list of identifier types
|
|
60
|
+
- select App when choosing between App and App Clip
|
|
61
|
+
- add the App Groups capability like so: `group.<identifier>.onesignal`
|
|
62
|
+
- do not add the "Push Notifications" capability
|
|
63
|
+
|
|
64
|
+
#### Note on App Groups at Build Time:
|
|
65
|
+
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
|
+
|
|
67
|
+
## 3. Provisioning
|
|
68
|
+
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
|
+
|
|
70
|
+
## 4. Add the profiles to your `credentials.json` file:
|
|
71
|
+
Use the same distribution certificate for the `OneSignalNotificationServiceExtension` as is used for your app (no need to create a new cert).
|
|
72
|
+
|
|
73
|
+
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.
|
|
74
|
+
|
|
75
|
+
**Directory structure:**
|
|
76
|
+
```
|
|
77
|
+
/certs
|
|
78
|
+
- /adhoc
|
|
79
|
+
- /appstore
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Example `credentials.json`:**
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"ios": {
|
|
86
|
+
"<PROJECT>": {
|
|
87
|
+
"distributionCertificate": {
|
|
88
|
+
"path": "certs/ios_distribution_certificate.p12",
|
|
89
|
+
"password": "***"
|
|
90
|
+
},
|
|
91
|
+
"provisioningProfilePath": "certs/adhoc/***mobileappprofile.mobileprovision"
|
|
92
|
+
},
|
|
93
|
+
"OneSignalNotificationServiceExtension": {
|
|
94
|
+
"distributionCertificate": {
|
|
95
|
+
"path": "certs/ios_distribution_certificate.p12",
|
|
96
|
+
"password": "***"
|
|
97
|
+
},
|
|
98
|
+
"provisioningProfilePath": "certs/adhoc/***onesignalprofile.mobileprovision"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Note:** your push certificate (p12) file should not appear anywhere in the `credentials.json` file.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
# Build
|
|
109
|
+
### Release
|
|
110
|
+
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
|
+
|
|
112
|
+
### Development
|
|
113
|
+
The development build will use the AdHoc provisioning profiles you created. Make sure your `credentials.json` file is using the correct profiles.
|
|
114
|
+
|
|
115
|
+
#### Expo development client
|
|
116
|
+
If you haven't already, add the expo development client to your project:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
expo install expo-dev-client
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Make sure `"developmentClient": true,` is set in your `eas.json` development build profile.
|
|
123
|
+
|
|
124
|
+
## All Builds
|
|
125
|
+
|
|
126
|
+
### Run the EAS build command
|
|
127
|
+
```sh
|
|
128
|
+
eas build --profile <build profile> --platform ios
|
|
129
|
+
```
|
|
130
|
+
where `<build profile>` refers to the build profile in your `eas.json` file (e.g: "development" vs "release").
|
|
131
|
+
|
|
132
|
+
### Build success
|
|
133
|
+
At this point, your build should succeed. You can check its progress by opening the build link in the terminal.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
# How to run on your device
|
|
138
|
+
See our [EAS guide](EAS.md) for instructions.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align="center">Welcome to onesignal-expo-plugin 👋</h1>
|
|
2
2
|
<p>
|
|
3
|
-
<img alt="Version" src="https://img.shields.io/badge/version-1.0.
|
|
3
|
+
<img alt="Version" src="https://img.shields.io/badge/version-1.0.1-blue.svg?cacheSeconds=2592000" />
|
|
4
4
|
<a href="https://github.com/OneSignal/onesignal-expo-plugin#readme" target="_blank">
|
|
5
5
|
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
|
|
6
6
|
</a>
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
* 🏠 [Homepage](https://github.com/OneSignal/onesignal-expo-plugin#readme)
|
|
18
18
|
* 🖤 [npm](https://www.npmjs.com/package/onesignal-expo-plugin)
|
|
19
19
|
|
|
20
|
-
## 🚧 In Beta 🚧
|
|
21
20
|
## Overview
|
|
22
21
|
This plugin is an [Expo Config Plugin](https://docs.expo.dev/guides/config-plugins/). It extends the Expo config to allow customizing the prebuild phase of managed workflow builds (no need to eject to a bare workflow). For the purposes of OneSignal integration, the plugin facilitates automatically generating/configuring the necessary native code files needed to get the [OneSignal React-Native SDK](https://github.com/OneSignal/react-native-onesignal) to work. You can think of adding a plugin as adding custom native code.
|
|
23
22
|
|
|
@@ -32,6 +31,12 @@ This plugin is an [Expo Config Plugin](https://docs.expo.dev/guides/config-plugi
|
|
|
32
31
|
|
|
33
32
|
```sh
|
|
34
33
|
expo install onesignal-expo-plugin
|
|
34
|
+
|
|
35
|
+
# npm
|
|
36
|
+
npm install react-native-onesignal
|
|
37
|
+
|
|
38
|
+
# yarn
|
|
39
|
+
yarn add react-native-onesignal
|
|
35
40
|
```
|
|
36
41
|
|
|
37
42
|
## Configuration in app.json / app.config.js
|
|
@@ -46,7 +51,6 @@ Add the plugin to the [plugin array](https://docs.expo.dev/versions/latest/confi
|
|
|
46
51
|
"onesignal-expo-plugin",
|
|
47
52
|
{
|
|
48
53
|
"mode": "development",
|
|
49
|
-
"devTeam": "91SW8A37CR"
|
|
50
54
|
}
|
|
51
55
|
]
|
|
52
56
|
]
|
|
@@ -63,19 +67,21 @@ export default {
|
|
|
63
67
|
[
|
|
64
68
|
"onesignal-expo-plugin",
|
|
65
69
|
{
|
|
66
|
-
mode:
|
|
67
|
-
devTeam: "91SW8A37CR"
|
|
70
|
+
mode: "development",
|
|
68
71
|
}
|
|
69
72
|
]
|
|
70
73
|
]
|
|
71
74
|
};
|
|
72
75
|
```
|
|
73
76
|
|
|
74
|
-
#### Plugin
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
#### Plugin Prop
|
|
78
|
+
You can pass props to the plugin config object to configure:
|
|
79
|
+
|
|
80
|
+
| Plugin Prop | | |
|
|
81
|
+
|--------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
82
|
+
| `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` |
|
|
83
|
+
| `devTeam` | optional | Used to configure Apple Team ID. You can find your Apple Team ID by running `expo credentials:manager` e.g: `"91SW8A37CR"` |
|
|
84
|
+
| `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"12.0"`. |
|
|
79
85
|
|
|
80
86
|
### OneSignal App ID
|
|
81
87
|
Add your OneSignal App ID to your [Expo constants via the `extra` param](https://docs.expo.dev/versions/latest/config/app/):
|
|
@@ -103,15 +109,50 @@ Alternatively, pass the app ID directly to the function:
|
|
|
103
109
|
OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");
|
|
104
110
|
```
|
|
105
111
|
|
|
106
|
-
|
|
112
|
+
### Versioning
|
|
113
|
+
In your configuration file, make sure you set:
|
|
114
|
+
|
|
115
|
+
| Property | Details |
|
|
116
|
+
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
117
|
+
| `version` | Your app version. Corresponds to `CFBundleShortVersionString` on iOS. This value will be used in your NSE* target's plist file. |
|
|
118
|
+
| `ios.buildNumber` | Build number for your iOS standalone app. Corresponds to `CFBundleVersion` and must match Apple's specified format. This value will be used in your NSE* target's plist file. |
|
|
119
|
+
|
|
120
|
+
\* NSE = Notification Service Extension. Learn more about the NSE [here](https://documentation.onesignal.com/docs/service-extensions).
|
|
121
|
+
|
|
122
|
+
## EAS (Expo Application Services)
|
|
123
|
+
See our [EAS documentation](EAS.md) for help with EAS.
|
|
124
|
+
|
|
125
|
+
### iOS Credentials: OneSignal + EAS
|
|
126
|
+
To distribute your iOS application via EAS, you will need to ensure your credentials are set up correctly. See our [credentials setup guide for instructions](IOS_CREDENTIALS_EAS.md).
|
|
127
|
+
|
|
128
|
+
## Prebuild (optional)
|
|
129
|
+
Prebuilding in Expo will result in the generation of the native runtime code for the project (and `ios` and `android` directories being built). By prebuilding, we automatically link and configure the native modules that have implemented CocoaPods, autolinking, and other config plugins. You can think of prebuild like a native code bundler.
|
|
130
|
+
|
|
131
|
+
When you run `expo prebuild` we enter into a custom managed workflow which provides most of the benefits of bare workflows and managed workflows at the same time.
|
|
132
|
+
|
|
133
|
+
#### Why should I prebuild?
|
|
134
|
+
It may make sense to prebuild locally to inspect config plugin changes and help in debugging issues.
|
|
135
|
+
|
|
136
|
+
#### Run
|
|
107
137
|
```sh
|
|
108
|
-
|
|
138
|
+
expo prebuild
|
|
139
|
+
```
|
|
109
140
|
|
|
110
|
-
|
|
111
|
-
|
|
141
|
+
```sh
|
|
142
|
+
# nukes changes and rebuilds
|
|
143
|
+
expo prebuild --clean
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**EAS Note:** if you choose to stay in a fully managed workflow by not prebuilding, EAS will still run `expo prebuild` at build time. You can also prebuild locally but remain in a fully managed workflow by adding the `android` and `ios` directories to your .gitignore.
|
|
147
|
+
|
|
148
|
+
## Run
|
|
149
|
+
The following commands will prebuild *and* run your application. Note that for iOS, push notifications will **not** work in the Simulator.
|
|
150
|
+
```sh
|
|
151
|
+
# Build and run your native iOS project
|
|
152
|
+
expo run:ios
|
|
112
153
|
|
|
113
|
-
# Build your native Android project
|
|
114
|
-
|
|
154
|
+
# Build and run your native Android project
|
|
155
|
+
expo run:android
|
|
115
156
|
```
|
|
116
157
|
|
|
117
158
|
---
|
|
@@ -6,26 +6,22 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.withOneSignalAndroid = void 0;
|
|
8
8
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
buildscript {
|
|
12
|
-
repositories {
|
|
13
|
-
gradlePluginPortal()
|
|
14
|
-
}
|
|
15
|
-
dependencies {
|
|
16
|
-
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'`;
|
|
21
|
-
// ---------- ---------- ---------- ----------
|
|
9
|
+
const androidConstants_1 = require("../support/androidConstants");
|
|
10
|
+
const OneSignalLog_1 = require("../support/OneSignalLog");
|
|
22
11
|
const withGradleBuildConfig = (config) => {
|
|
23
12
|
return (0, config_plugins_1.withAppBuildGradle)(config, (newConfig) => {
|
|
24
|
-
|
|
13
|
+
let { contents } = newConfig.modResults;
|
|
14
|
+
// make sure we haven't previously added dependencies
|
|
15
|
+
if (!contents.includes(androidConstants_1.ONESIGNAL_GRADLE)) {
|
|
16
|
+
contents = `${androidConstants_1.ONESIGNAL_GRADLE}\n${contents}`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
OneSignalLog_1.OneSignalLog.log("OneSignal dependencies already added to build.gradle. Skipping...");
|
|
20
|
+
}
|
|
21
|
+
newConfig.modResults.contents = contents;
|
|
25
22
|
return newConfig;
|
|
26
23
|
});
|
|
27
24
|
};
|
|
28
|
-
// ---------- ---------- ---------- ----------
|
|
29
25
|
const withOneSignalAndroid = (config, props) => {
|
|
30
26
|
withGradleBuildConfig(config, props);
|
|
31
27
|
return config;
|