onesignal-expo-plugin 1.0.0-beta9 → 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.
Files changed (38) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.js +18 -0
  3. package/.github/ISSUE_TEMPLATE/ask-question.yml +50 -0
  4. package/.github/ISSUE_TEMPLATE/bug-report.yml +71 -0
  5. package/.github/ISSUE_TEMPLATE/general-feedback.yml +27 -0
  6. package/CHANGELOG.md +42 -0
  7. package/EAS.md +21 -0
  8. package/IOS_CREDENTIALS_EAS.md +170 -0
  9. package/README.md +47 -8
  10. package/build/onesignal/withOneSignalAndroid.js +11 -15
  11. package/build/onesignal/withOneSignalIos.js +75 -39
  12. package/build/support/{ReaderManager.js → FileManager.js} +26 -8
  13. package/build/support/NseUpdaterManager.js +32 -0
  14. package/build/support/OneSignalLog.js +12 -0
  15. package/build/support/androidConstants.js +13 -0
  16. package/build/support/eas/getEasManagedCredentialsConfigExtra.js +35 -0
  17. package/build/support/iosConstants.js +7 -2
  18. package/build/support/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist +2 -2
  19. package/build/support/updatePodfile.js +5 -4
  20. package/build/testRuniOS.js +2 -0
  21. package/build/types/types.js +8 -0
  22. package/onesignal/withOneSignal.ts +1 -9
  23. package/onesignal/withOneSignalAndroid.ts +13 -19
  24. package/onesignal/withOneSignalIos.ts +65 -54
  25. package/package.json +10 -5
  26. package/support/FileManager.ts +38 -0
  27. package/support/NseUpdaterManager.ts +40 -0
  28. package/support/OneSignalLog.ts +9 -0
  29. package/support/androidConstants.ts +11 -0
  30. package/support/eas/getEasManagedCredentialsConfigExtra.ts +33 -0
  31. package/support/iosConstants.ts +8 -1
  32. package/support/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist +2 -2
  33. package/support/updatePodfile.ts +5 -4
  34. package/testRuniOS.ts +2 -0
  35. package/types/types.ts +30 -0
  36. package/build/support/updateNSEEntitlements.js +0 -20
  37. package/support/ReaderManager.ts +0 -18
  38. package/support/updateNSEEntitlements.ts +0 -16
package/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ # don't ever lint node_modules
2
+ node_modules
3
+ # don't lint build output (make sure it's set to your correct build folder name)
4
+ build
5
+ # don't lint the examples projects
6
+ examples
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,170 @@
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 set up separately since you are using OneSignal.
9
+
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.
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.
15
+
16
+ You can still view the old instructions by clicking below.
17
+
18
+ <details>
19
+ <summary>Click to expand</summary>
20
+
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.
49
+
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.
51
+
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
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.
58
+
59
+ **Example:**
60
+ ```json
61
+ {
62
+ "build": {
63
+ "release": {
64
+ "android": {
65
+ "gradleCommand": ":app:bundleRelease"
66
+ },
67
+ "ios": {
68
+ "credentialsSource": "local",
69
+ "buildConfiguration": "Release"
70
+ }
71
+ },
72
+ "development": {
73
+ "developmentClient": true,
74
+ "distribution": "internal",
75
+ "credentialsSource": "local"
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### 2. Identifiers
82
+ In your [Apple developer console](https://developer.apple.com) create two identifiers with the following format:
83
+ - `<com.example.app>` <-- you likely already have this one
84
+ - `<com.example.app>.OneSignalNotificationServiceExtension`
85
+
86
+ #### When modifying your existing main app identifier:
87
+ - add the App Groups capability like so: `group.<identifier>.onesignal`
88
+ - keep / add the "Push Notifications" capability
89
+
90
+ #### When creating a new identifier for `OneSignalNotificationServiceExtension`:
91
+ - select AppId from the list of identifier types
92
+ - select App when choosing between App and App Clip
93
+ - add the App Groups capability like so: `group.<identifier>.onesignal`
94
+ - do not add the "Push Notifications" capability
95
+
96
+ #### Note on App Groups at Build Time:
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.
98
+
99
+ ### 3. Provisioning
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.
101
+
102
+ ### 4. Add the profiles to your `credentials.json` file:
103
+ Use the same distribution certificate for the `OneSignalNotificationServiceExtension` as is used for your app (no need to create a new cert).
104
+
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.
106
+
107
+ **Directory structure:**
108
+ ```
109
+ /certs
110
+ - /adhoc
111
+ - /appstore
112
+ ```
113
+
114
+ **Example `credentials.json`:**
115
+ ```json
116
+ {
117
+ "ios": {
118
+ "<PROJECT>": {
119
+ "distributionCertificate": {
120
+ "path": "certs/ios_distribution_certificate.p12",
121
+ "password": "***"
122
+ },
123
+ "provisioningProfilePath": "certs/adhoc/***mobileappprofile.mobileprovision"
124
+ },
125
+ "OneSignalNotificationServiceExtension": {
126
+ "distributionCertificate": {
127
+ "path": "certs/ios_distribution_certificate.p12",
128
+ "password": "***"
129
+ },
130
+ "provisioningProfilePath": "certs/adhoc/***onesignalprofile.mobileprovision"
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ **Note:** your push certificate (p12) file should not appear anywhere in the `credentials.json` file.
137
+
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).
141
+
142
+ ### Release
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.
144
+
145
+ ### Development
146
+ The development build will use the AdHoc provisioning profiles you created. Make sure your `credentials.json` file is using the correct profiles.
147
+
148
+ ---
149
+ </details>
150
+
151
+ ### Expo development client
152
+ If you haven't already, add the expo development client to your project:
153
+
154
+ ```sh
155
+ expo install expo-dev-client
156
+ ```
157
+
158
+ Make sure `"developmentClient": true,` is set in your `eas.json` development build profile.
159
+
160
+ ### Run the EAS build command
161
+ ```sh
162
+ eas build --profile <build profile> --platform ios
163
+ ```
164
+ where `<build profile>` refers to the build profile in your `eas.json` file (e.g: "development" vs "release").
165
+
166
+ ### Build success
167
+ At this point, your build should succeed. You can check its progress by opening the build link in the terminal.
168
+
169
+ ## How to run on your device
170
+ 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.0--beta9-blue.svg?cacheSeconds=2592000" />
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,11 @@ 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
35
39
  yarn add react-native-onesignal
36
40
  ```
37
41
 
@@ -105,15 +109,50 @@ Alternatively, pass the app ID directly to the function:
105
109
  OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");
106
110
  ```
107
111
 
108
- ## Run
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
109
137
  ```sh
110
- $ expo prebuild --clean
138
+ expo prebuild
139
+ ```
111
140
 
112
- # Build your native iOS project
113
- $ expo run:ios
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
114
153
 
115
- # Build your native Android project
116
- $ expo run:android
154
+ # Build and run your native Android project
155
+ expo run:android
117
156
  ```
118
157
 
119
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 oneSignalGradle = `
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
- newConfig.modResults.contents = `${oneSignalGradle.trimStart()}\n\n${newConfig.modResults.contents}`;
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;