@trycourier/courier-react-native 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +382 -0
- package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +17 -0
- package/android/.idea/jarRepositories.xml +35 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +149 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +5 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/courierreactnative/CourierReactNativeActivity.kt +62 -0
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +199 -0
- package/android/src/main/java/com/courierreactnative/CourierReactNativePackage.kt +19 -0
- package/android/src/main/java/com/courierreactnative/NotificationPermissionStatus.kt +6 -0
- package/courier-react-native.podspec +37 -0
- package/ios/CourierReactNative-Bridging-Header.h +3 -0
- package/ios/CourierReactNative.m +53 -0
- package/ios/CourierReactNative.swift +286 -0
- package/ios/CourierReactNative.xcodeproj/project.pbxproj +283 -0
- package/ios/CourierReactNativeDelegate.h +20 -0
- package/ios/CourierReactNativeDelegate.m +125 -0
- package/lib/commonjs/index.js +305 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +295 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +140 -0
- package/package.json +156 -0
- package/src/index.ts +337 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 FahadAminShovon
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Courier React Native Overview
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
await Courier.setIsDebugging(!isDebugging);
|
|
5
|
+
|
|
6
|
+
const userId = await Courier.userId;
|
|
7
|
+
|
|
8
|
+
await Courier.signIn({
|
|
9
|
+
accessToken: 'asdf...',
|
|
10
|
+
userId: 'example_user_id',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
await Courier.signOut();
|
|
14
|
+
|
|
15
|
+
await Courier.iOSForegroundPresentationOptions({
|
|
16
|
+
options: ['badge', 'banner', 'list', 'sound'],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const currentPermissionStatus = await Courier.notificationPermissionStatus;
|
|
20
|
+
const requestNotificationPermission =
|
|
21
|
+
await Courier.requestNotificationPermission();
|
|
22
|
+
|
|
23
|
+
await Courier.shared.setFcmToken('asdf...');
|
|
24
|
+
|
|
25
|
+
const fcmToken = await Courier.fcmToken;
|
|
26
|
+
const apnsToken = await Courier.apnsToken;
|
|
27
|
+
|
|
28
|
+
const unsubscribe = Courier.registerPushNotificationListeners({
|
|
29
|
+
onPushNotificationClicked(push) {
|
|
30
|
+
console.log(push);
|
|
31
|
+
},
|
|
32
|
+
onPushNotificationDelivered(push) {
|
|
33
|
+
console.log(push);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const messageId = await Courier.sendPush({
|
|
38
|
+
authKey: 'asdf...',
|
|
39
|
+
userId: 'example_user_id',
|
|
40
|
+
title: 'Hey! 👋',
|
|
41
|
+
body: 'Courier is awesome!!',
|
|
42
|
+
isProduction: false,
|
|
43
|
+
providers: [CourierProvider.APNS, CourierProvider.FCM],
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# Requirements & Support
|
|
48
|
+
|
|
49
|
+
| Operating System | Minimum SDK | Compile Target SDK |
|
|
50
|
+
| :--------------- | ----------: | -----------------: |
|
|
51
|
+
| `iOS` | `13` | — |
|
|
52
|
+
| `Android` | `21` | `32` |
|
|
53
|
+
|
|
54
|
+
| Push Provider | Supported Platforms |
|
|
55
|
+
| :--------------------------------------- | ------------------: |
|
|
56
|
+
| `APNS (Apple Push Notification Service)` | `iOS` |
|
|
57
|
+
| `FCM (Firebase Cloud Messaging)` | `Android` |
|
|
58
|
+
|
|
59
|
+
> Most of this SDK depends on a Courier account: [`Create a Courier account here`](https://app.courier.com/signup)
|
|
60
|
+
|
|
61
|
+
> Testing push notifications requires a physical device. Simulators will not work.
|
|
62
|
+
|
|
63
|
+
# **Installation**
|
|
64
|
+
|
|
65
|
+
> Link to [`Example App`](https://github.com/trycourier/courier-react-native/tree/master/example)
|
|
66
|
+
|
|
67
|
+
- [Courier React Native Overview](#courier-react-native-overview)
|
|
68
|
+
- [Requirements & Support](#requirements--support)
|
|
69
|
+
- [**Installation**](#installation)
|
|
70
|
+
- [**1. Install the package**](#1-install-the-package)
|
|
71
|
+
- [**2. iOS Setup**](#2-ios-setup)
|
|
72
|
+
- [**Add the Notification Service Extension (Recommended)**](#add-the-notification-service-extension-recommended)
|
|
73
|
+
- [**3. Android Setup**](#3-android-setup)
|
|
74
|
+
- [**4. Configure Push Provider**](#4-configure-push-provider)
|
|
75
|
+
- [**5. Managing User State**](#5-managing-user-state)
|
|
76
|
+
- [**Going to Production**](#going-to-production)
|
|
77
|
+
- [**Share feedback with Courier**](#share-feedback-with-courier)
|
|
78
|
+
|
|
79
|
+
 
|
|
80
|
+
|
|
81
|
+
## **1. Install the package**
|
|
82
|
+
|
|
83
|
+
Run the following command at your project's root directory:
|
|
84
|
+
|
|
85
|
+
using npm:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm install @trycourier/courier-react-native
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
using yarn:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
yarn add @trycourier/courier-react-native
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
 
|
|
98
|
+
|
|
99
|
+
## **2. iOS Setup**
|
|
100
|
+
|
|
101
|
+
> If you don't need push notification support on iOS, you can skip this step.
|
|
102
|
+
|
|
103
|
+
https://user-images.githubusercontent.com/6370613/198094477-40f22b1e-b3ad-4029-9120-0eee22de02e0.mov
|
|
104
|
+
|
|
105
|
+
1. From your project's root directory, run: `cd ios && pod update`
|
|
106
|
+
2. Open your iOS project and increase the min SDK target to iOS 13.0+
|
|
107
|
+
3. Change your `AppDelegate` to extend the `CourierReactNativeDelegate`
|
|
108
|
+
- This automatically syncs APNS tokens to Courier
|
|
109
|
+
- Allows the React Native SDK to handle when push notifications are delivered and clicked
|
|
110
|
+
4. Enable the "Push Notifications" capability
|
|
111
|
+
|
|
112
|
+
### **Add the Notification Service Extension (Recommended)**
|
|
113
|
+
|
|
114
|
+
To make sure Courier can track when a notification is delivered to the device, you need to add a Notification Service Extension. Here is how to add one.
|
|
115
|
+
|
|
116
|
+
https://user-images.githubusercontent.com/6370613/198336479-45aeec9e-0c94-4c29-b132-ea8c777b9da1.mov
|
|
117
|
+
|
|
118
|
+
1. Download and Unzip the Courier Notification Service Extension: [`CourierNotificationServiceTemplate.zip`](https://github.com/trycourier/courier-notification-service-extension-template/archive/refs/heads/main.zip)
|
|
119
|
+
2. Open the folder in terminal and run `sh make_template.sh`
|
|
120
|
+
- This will create the Notification Service Extension on your mac to save you time
|
|
121
|
+
3. Open your iOS app in Xcode and go to File > New > Target
|
|
122
|
+
4. Select "Courier Service" and click "Next"
|
|
123
|
+
5. Give the Notification Service Extension a name (i.e. "CourierService"), select `Courier_iOS` as the Package, and click "Finish"
|
|
124
|
+
6. Click "Cancel" on the next popup
|
|
125
|
+
- You do NOT need to click "Activate" here. Your Notification Service Extension will still work just fine.
|
|
126
|
+
7. Open your `Podfile` and add the following snippet to the end of your Podfile
|
|
127
|
+
- This will link the `Courier-iOS` pod to your Notification Service Extension
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
target 'CourierService' do
|
|
131
|
+
use_frameworks!
|
|
132
|
+
pod 'Courier-iOS'
|
|
133
|
+
end
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
1. From the root of your React Native app, run: `cd ios && pod install`
|
|
137
|
+
|
|
138
|
+
 
|
|
139
|
+
|
|
140
|
+
## **3. Android Setup**
|
|
141
|
+
|
|
142
|
+
> If you don't need push notification support on Android, you can skip this step.
|
|
143
|
+
|
|
144
|
+
https://user-images.githubusercontent.com/6370613/198111372-09a29aba-6507-4cf7-a59d-87e8df2ba492.mov
|
|
145
|
+
|
|
146
|
+
1. Open Android project
|
|
147
|
+
2. Add support for Jitpack to `android/build.gradle`
|
|
148
|
+
- This is needed because the Courier Android SDK is hosted using Jitpack
|
|
149
|
+
- Maven support will be coming later
|
|
150
|
+
|
|
151
|
+
```gradle
|
|
152
|
+
allprojects {
|
|
153
|
+
repositories {
|
|
154
|
+
google()
|
|
155
|
+
mavenCentral()
|
|
156
|
+
maven { url 'https://jitpack.io' } // Add this line
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
3. Update your `app/build.gradle` to support the min and compile SDKs
|
|
162
|
+
- `minSdkVersion 21`
|
|
163
|
+
- `compileSdkVersion 33`
|
|
164
|
+
4. Run Gradle sync
|
|
165
|
+
5. add the `google-services` plugin as a dependency inside of your `/android/build.gradle` file:
|
|
166
|
+
|
|
167
|
+
```groovy
|
|
168
|
+
buildscript {
|
|
169
|
+
dependencies {
|
|
170
|
+
// ... other dependencies
|
|
171
|
+
classpath 'com.google.gms:google-services:4.3.14'
|
|
172
|
+
// Add me --- /\
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
6. execute the plugin by adding the following to your `/android/app/build.gradle` file:
|
|
178
|
+
|
|
179
|
+
```groovy
|
|
180
|
+
apply plugin: 'com.android.application'
|
|
181
|
+
apply plugin: 'com.google.gms.google-services' // <- Add this line
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
7. Change your `MainActivity` to extend the `CourierReactNativeActivity`
|
|
185
|
+
- This allows Courier to handle when push notifications are delivered and clicked
|
|
186
|
+
8. Setup a new Notification Service by creating a new file and pasting the code below in it
|
|
187
|
+
- This allows you to present a notification to your user when a new notification arrives
|
|
188
|
+
|
|
189
|
+
```java
|
|
190
|
+
import androidx.annotation.NonNull;
|
|
191
|
+
|
|
192
|
+
import com.courier.android.notifications.RemoteMessageExtensionsKt;
|
|
193
|
+
import com.courier.android.service.CourierService;
|
|
194
|
+
import com.google.firebase.messaging.RemoteMessage;
|
|
195
|
+
|
|
196
|
+
public class YourNotificationService extends CourierService {
|
|
197
|
+
@Override
|
|
198
|
+
public void showNotification(@NonNull RemoteMessage message) {
|
|
199
|
+
super.showNotification(message);
|
|
200
|
+
|
|
201
|
+
RemoteMessageExtensionsKt.presentNotification(
|
|
202
|
+
message,
|
|
203
|
+
this,
|
|
204
|
+
MainActivity.class,
|
|
205
|
+
android.R.drawable.ic_dialog_info,
|
|
206
|
+
"Notification Service"
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
7. Add the Notification Service entry in your `AndroidManifest.xml` file
|
|
213
|
+
|
|
214
|
+
```xml
|
|
215
|
+
<manifest>
|
|
216
|
+
<application>
|
|
217
|
+
|
|
218
|
+
<activity>
|
|
219
|
+
..
|
|
220
|
+
</activity>
|
|
221
|
+
|
|
222
|
+
// Add this 👇
|
|
223
|
+
<service
|
|
224
|
+
android:name=".YourNotificationService"
|
|
225
|
+
android:exported="false">
|
|
226
|
+
<intent-filter>
|
|
227
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
228
|
+
</intent-filter>
|
|
229
|
+
</service>
|
|
230
|
+
// Add this 👆
|
|
231
|
+
|
|
232
|
+
..
|
|
233
|
+
|
|
234
|
+
</application>
|
|
235
|
+
</manifest>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
 
|
|
239
|
+
|
|
240
|
+
## **4. Configure Push Provider**
|
|
241
|
+
|
|
242
|
+
> If you don't need push notification support, you can skip this step.
|
|
243
|
+
|
|
244
|
+
To get push notification to appear in your app, add support for the provider you would like to use:
|
|
245
|
+
|
|
246
|
+
- [`APNS (Apple Push Notification Service)`](https://www.courier.com/docs/guides/providers/push/apple-push-notification)
|
|
247
|
+
- [`FCM (Firebase Cloud Messaging)`](https://www.courier.com/docs/guides/providers/push/firebase-fcm/)
|
|
248
|
+
|
|
249
|
+
 
|
|
250
|
+
|
|
251
|
+
## **5. Managing User State**
|
|
252
|
+
|
|
253
|
+
Best user experience practice is to synchronize the current user's push notification tokens and the user's state. Courier does most of this for you automatically!
|
|
254
|
+
|
|
255
|
+
> You can use a Courier Auth Key [`found here`](https://app.courier.com/settings/api-keys) when developing.
|
|
256
|
+
|
|
257
|
+
> When you are ready for production release, you should be using a JWT as the `accessToken`.
|
|
258
|
+
> Here is more info about [`Going to Production`](#going-to-production)
|
|
259
|
+
|
|
260
|
+
Place these functions where you normally manage your user's state:
|
|
261
|
+
|
|
262
|
+
```dart
|
|
263
|
+
// Saves accessToken and userId to native level local storage
|
|
264
|
+
// This will persist between app sessions
|
|
265
|
+
await Courier.shared.signIn(
|
|
266
|
+
accessToken: accessToken,
|
|
267
|
+
userId: userId,
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
await Courier.shared.signOut();
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
If you followed the steps above:
|
|
274
|
+
|
|
275
|
+
- APNS tokens on iOS will automatically be synced to Courier
|
|
276
|
+
- FCM tokens on Android will automatically be synced to Courier
|
|
277
|
+
|
|
278
|
+
<!-- If you want FCM tokens to sync to Courier on iOS:
|
|
279
|
+
|
|
280
|
+
1. Add the following react native packages to your project
|
|
281
|
+
- [`React Native Firebase`](https://rnfirebase.io/)
|
|
282
|
+
|
|
283
|
+
2. Add code to manually sync FCM tokens
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
const fcmToken = await FirebaseMessaging.instance.getToken();
|
|
287
|
+
if (fcmToken != null) {
|
|
288
|
+
await Courier.shared.setFcmToken(token: fcmToken);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Handle FCM token refreshes
|
|
292
|
+
FirebaseMessaging.instance.onTokenRefresh.listen((fcmToken) {
|
|
293
|
+
Courier.shared.setFcmToken(token: fcmToken);
|
|
294
|
+
});
|
|
295
|
+
``` -->
|
|
296
|
+
|
|
297
|
+
 
|
|
298
|
+
|
|
299
|
+
## **6. Testing Push Notifications**
|
|
300
|
+
|
|
301
|
+
> If you don't need push notification support, you can skip this step.
|
|
302
|
+
|
|
303
|
+
Courier allows you to send a push notification directly from the SDK to a user id. No tokens juggling or backend needed!
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
const notificationPermission = await Courier.notificationPermissionStatus;;
|
|
307
|
+
print(notificationPermission);
|
|
308
|
+
|
|
309
|
+
// Notification permissions must be `authorized` on iOS to receive pushes
|
|
310
|
+
|
|
311
|
+
const requestedNotificationPermission = await Courier.requestNotificationPermission();
|
|
312
|
+
print(requestedNotificationPermission);
|
|
313
|
+
|
|
314
|
+
// This is how iOS will show the notification when the app is in the foreground
|
|
315
|
+
// Passing [] will not present anything
|
|
316
|
+
// `Courier.shared.onPushNotificationDelivered` will still get called
|
|
317
|
+
await Courier.iOSForegroundPresentationOptions({
|
|
318
|
+
options: ['badge', 'banner', 'list', 'sound'],
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
// the function returns an unsubscribe function
|
|
323
|
+
// call the function to stop listening to notifications
|
|
324
|
+
// Recommended to call the function while component mounts and unsubscribe when the component unmounts
|
|
325
|
+
const unsubscribe = Courier.registerPushNotificationListeners({
|
|
326
|
+
|
|
327
|
+
// Will be called if the app is in the foreground and a push notification arrives
|
|
328
|
+
onPushNotificationClicked(push) {
|
|
329
|
+
...
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
// Will be called when a user clicks a push notification
|
|
333
|
+
onPushNotificationDelivered(push) {
|
|
334
|
+
...
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// Sends a test push
|
|
339
|
+
const messageId = await Courier.shared.sendPush(
|
|
340
|
+
authKey: 'a_courier_auth_key_that_should_only_be_used_for_testing',
|
|
341
|
+
userId: 'example_user',
|
|
342
|
+
title: 'Chirp Chrip!',
|
|
343
|
+
body: 'Hello from Courier 🐣',
|
|
344
|
+
isProduction: false, // This only affects APNS pushes. false == sandbox / true == production
|
|
345
|
+
providers: [CourierProvider.APNS, CourierProvider.FCM],
|
|
346
|
+
);
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
 
|
|
350
|
+
|
|
351
|
+
## **Going to Production**
|
|
352
|
+
|
|
353
|
+
For security reasons, you should not keep your `authKey` (which looks like: `pk_prod_ABCD...`) in your production app. The `authKey` is safe to test with, but you will want to use an `accessToken` in production.
|
|
354
|
+
|
|
355
|
+
To create an `accessToken`, call this:
|
|
356
|
+
|
|
357
|
+
```curl
|
|
358
|
+
curl --request POST \
|
|
359
|
+
--url https://api.courier.com/auth/issue-token \
|
|
360
|
+
--header 'Accept: application/json' \
|
|
361
|
+
--header 'Authorization: Bearer $YOUR_AUTH_KEY' \
|
|
362
|
+
--header 'Content-Type: application/json' \
|
|
363
|
+
--data
|
|
364
|
+
'{
|
|
365
|
+
"scope": "user_id:$YOUR_USER_ID write:user-tokens",
|
|
366
|
+
"expires_in": "$YOUR_NUMBER days"
|
|
367
|
+
}'
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Or generate one here:
|
|
371
|
+
[`Issue Courier Access Token`](https://www.courier.com/docs/reference/auth/issue-token/)
|
|
372
|
+
|
|
373
|
+
> This request to issue a token should likely exist in a separate endpoint served on your backend.
|
|
374
|
+
|
|
375
|
+
 
|
|
376
|
+
|
|
377
|
+
## **Share feedback with Courier**
|
|
378
|
+
|
|
379
|
+
We want to make this the best SDK for managing notifications! Have an idea or feedback about our SDKs? Here are some links to contact us:
|
|
380
|
+
|
|
381
|
+
- [Courier Feedback](https://feedback.courier.com/)
|
|
382
|
+
- [Courier React native Issues](https://github.com/trycourier/courier-react-native/issues)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="GradleSettings">
|
|
4
|
+
<option name="linkedExternalProjectsSettings">
|
|
5
|
+
<GradleProjectSettings>
|
|
6
|
+
<option name="testRunner" value="GRADLE" />
|
|
7
|
+
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
8
|
+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
9
|
+
<option name="modules">
|
|
10
|
+
<set>
|
|
11
|
+
<option value="$PROJECT_DIR$" />
|
|
12
|
+
</set>
|
|
13
|
+
</option>
|
|
14
|
+
</GradleProjectSettings>
|
|
15
|
+
</option>
|
|
16
|
+
</component>
|
|
17
|
+
</project>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="RemoteRepositoriesConfiguration">
|
|
4
|
+
<remote-repository>
|
|
5
|
+
<option name="id" value="central" />
|
|
6
|
+
<option name="name" value="Maven Central repository" />
|
|
7
|
+
<option name="url" value="https://repo1.maven.org/maven2" />
|
|
8
|
+
</remote-repository>
|
|
9
|
+
<remote-repository>
|
|
10
|
+
<option name="id" value="jboss.community" />
|
|
11
|
+
<option name="name" value="JBoss Community repository" />
|
|
12
|
+
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
|
13
|
+
</remote-repository>
|
|
14
|
+
<remote-repository>
|
|
15
|
+
<option name="id" value="MavenRepo" />
|
|
16
|
+
<option name="name" value="MavenRepo" />
|
|
17
|
+
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
|
18
|
+
</remote-repository>
|
|
19
|
+
<remote-repository>
|
|
20
|
+
<option name="id" value="React Native sources" />
|
|
21
|
+
<option name="name" value="React Native sources" />
|
|
22
|
+
<option name="url" value="file:$PROJECT_DIR$/../node_modules/react-native/android/" />
|
|
23
|
+
</remote-repository>
|
|
24
|
+
<remote-repository>
|
|
25
|
+
<option name="id" value="maven" />
|
|
26
|
+
<option name="name" value="maven" />
|
|
27
|
+
<option name="url" value="https://jitpack.io" />
|
|
28
|
+
</remote-repository>
|
|
29
|
+
<remote-repository>
|
|
30
|
+
<option name="id" value="Google" />
|
|
31
|
+
<option name="name" value="Google" />
|
|
32
|
+
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
|
33
|
+
</remote-repository>
|
|
34
|
+
</component>
|
|
35
|
+
</project>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
4
|
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
|
5
|
+
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
6
|
+
</component>
|
|
7
|
+
<component name="ProjectType">
|
|
8
|
+
<option name="id" value="Android" />
|
|
9
|
+
</component>
|
|
10
|
+
</project>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['CourierReactNative_kotlinVersion']
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath 'com.android.tools.build:gradle:3.5.3'
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: 'com.android.library'
|
|
22
|
+
apply plugin: 'kotlin-android'
|
|
23
|
+
|
|
24
|
+
if (isNewArchitectureEnabled()) {
|
|
25
|
+
apply plugin: 'com.facebook.react'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['CourierReactNative_' + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['CourierReactNative_' + name]).toInteger()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
android {
|
|
37
|
+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
38
|
+
|
|
39
|
+
defaultConfig {
|
|
40
|
+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
41
|
+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
42
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
43
|
+
}
|
|
44
|
+
buildTypes {
|
|
45
|
+
release {
|
|
46
|
+
minifyEnabled false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
lintOptions {
|
|
51
|
+
disable 'GradleCompatible'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
compileOptions {
|
|
55
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
56
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
repositories {
|
|
61
|
+
mavenCentral()
|
|
62
|
+
google()
|
|
63
|
+
maven { url 'https://jitpack.io' }
|
|
64
|
+
|
|
65
|
+
def found = false
|
|
66
|
+
def defaultDir = null
|
|
67
|
+
def androidSourcesName = 'React Native sources'
|
|
68
|
+
|
|
69
|
+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
70
|
+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
71
|
+
} else {
|
|
72
|
+
defaultDir = new File(
|
|
73
|
+
projectDir,
|
|
74
|
+
'/../../../node_modules/react-native/android'
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (defaultDir.exists()) {
|
|
79
|
+
maven {
|
|
80
|
+
url defaultDir.toString()
|
|
81
|
+
name androidSourcesName
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
85
|
+
found = true
|
|
86
|
+
} else {
|
|
87
|
+
def parentDir = rootProject.projectDir
|
|
88
|
+
|
|
89
|
+
1.upto(5, {
|
|
90
|
+
if (found) return true
|
|
91
|
+
parentDir = parentDir.parentFile
|
|
92
|
+
|
|
93
|
+
def androidSourcesDir = new File(
|
|
94
|
+
parentDir,
|
|
95
|
+
'node_modules/react-native'
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def androidPrebuiltBinaryDir = new File(
|
|
99
|
+
parentDir,
|
|
100
|
+
'node_modules/react-native/android'
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if (androidPrebuiltBinaryDir.exists()) {
|
|
104
|
+
maven {
|
|
105
|
+
url androidPrebuiltBinaryDir.toString()
|
|
106
|
+
name androidSourcesName
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
110
|
+
found = true
|
|
111
|
+
} else if (androidSourcesDir.exists()) {
|
|
112
|
+
maven {
|
|
113
|
+
url androidSourcesDir.toString()
|
|
114
|
+
name androidSourcesName
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
118
|
+
found = true
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!found) {
|
|
124
|
+
throw new GradleException(
|
|
125
|
+
"${project.name}: unable to locate React Native android sources. " +
|
|
126
|
+
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
132
|
+
|
|
133
|
+
dependencies {
|
|
134
|
+
//noinspection GradleDynamicVersion
|
|
135
|
+
implementation "com.facebook.react:react-native:+"
|
|
136
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
137
|
+
|
|
138
|
+
// Courier Core SDK
|
|
139
|
+
api 'com.github.trycourier:courier-android:1.0.27'
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (isNewArchitectureEnabled()) {
|
|
144
|
+
react {
|
|
145
|
+
jsRootDir = file("../src/")
|
|
146
|
+
libraryName = "CourierReactNative"
|
|
147
|
+
codegenJavaPackageName = "com.courierreactnative"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
Binary file
|