Skip to content

Commit 57d9b07

Browse files
authored
Merge branch 'main' into ullrich/firebaseMessagingVersion
2 parents 756fb1d + 07e1885 commit 57d9b07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+31216
-6105
lines changed

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

.circleci/config.yml

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ version: 2.1
33
# Default VM config to be used for macOS builds
44
macos_config: &macos_config
55
macos:
6-
xcode: 12.5.0
6+
xcode: 14.0.0
7+
resource_class: macos.x86.medium.gen2
78
shell: /bin/bash --login -eo pipefail
89

910
setup_env_file: &setup_env_file
@@ -15,16 +16,26 @@ setup_env_file: &setup_env_file
1516
executors:
1617
default:
1718
docker:
18-
- image: circleci/node:12
19+
- image: circleci/node:14
1920
working_directory: ~/project
2021

2122
orbs:
2223
android: circleci/[email protected]
2324

24-
run_on_master: &run_on_master
25+
# Always run job
26+
run_always: &run_always
2527
filters:
28+
tags:
29+
only: /.*/
30+
31+
# Only run on release
32+
run_on_release: &run_on_release
33+
filters:
34+
tags:
35+
only: /.*/
2636
branches:
27-
only: main
37+
ignore: /.*/
38+
2839

2940
commands:
3041
attach_project:
@@ -34,22 +45,11 @@ commands:
3445

3546
jobs:
3647
install-dependencies:
37-
executor: default
48+
<<: *macos_config
3849
steps:
3950
- checkout
4051
- attach_project
41-
- restore_cache:
42-
keys:
43-
- dependencies-{{ checksum "package.json" }}
44-
- dependencies-
45-
- restore_cache:
46-
keys:
47-
- dependencies-example-{{ checksum "package.json" }}
48-
- dependencies-
49-
- restore_cache:
50-
keys:
51-
- dependencies-example-e2e-{{ checksum "example/e2e/package.json" }}
52-
- dependencies-example-e2e-
52+
5353
- run:
5454
name: Install dependencies
5555
command: |
@@ -219,42 +219,50 @@ jobs:
219219
yarn install
220220
221221
- run:
222-
name: Release package
223-
command: npm run release --ci
222+
name: Publish the package
223+
command: npm publish
224224

225225

226226
workflows:
227+
version: 2.1
227228
build-and-test:
228229
jobs:
229-
- install-dependencies
230+
- install-dependencies:
231+
<<: *run_always
230232
- lint:
233+
<<: *run_always
231234
requires:
232235
- install-dependencies
233236
- typescript:
237+
<<: *run_always
234238
requires:
235239
- install-dependencies
236240
- unit-tests:
241+
<<: *run_always
237242
requires:
238243
- install-dependencies
239244
- build-package:
245+
<<: *run_always
240246
requires:
241247
- install-dependencies
242-
- android-e2e-test:
243-
requires:
244-
- install-dependencies
245-
- lint
246-
- typescript
247-
- unit-tests
248-
- build-package
249-
- ios-e2e-test:
250-
requires:
251-
- install-dependencies
252-
- lint
253-
- typescript
254-
- unit-tests
255-
- build-package
248+
# - android-e2e-test:
249+
# <<: *run_always
250+
# requires:
251+
# - install-dependencies
252+
# - lint
253+
# - typescript
254+
# - unit-tests
255+
# - build-package
256+
# - ios-e2e-test:
257+
# <<: *run_always
258+
# requires:
259+
# - install-dependencies
260+
# - lint
261+
# - typescript
262+
# - unit-tests
263+
# - build-package
256264
- release-to-npm:
257-
<<: *run_on_master
265+
<<: *run_on_release
258266
context:
259267
- react-native-context
260268
requires:
@@ -263,5 +271,5 @@ workflows:
263271
- typescript
264272
- unit-tests
265273
- build-package
266-
- ios-e2e-test
267-
- android-e2e-test
274+
# - ios-e2e-test
275+
# - android-e2e-test
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# More information on this workflow can be found here: https://stackoverflow.com/c/intercom/questions/1270
2+
3+
name: FOSSA License Scan
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
fossa:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Attempt build
17+
uses: intercom/attempt-build-action@main
18+
continue-on-error: true
19+
- name: Run FOSSA
20+
uses: intercom/fossa-action@main
21+
with:
22+
fossa-api-key: ${{ secrets.FOSSA_API_KEY }}
23+
fossa-event-receiver-token: ${{ secrets.FOSSA_EVENT_RECEIVER_TOKEN }}
24+
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '2.7.5'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ implementation project(':intercom-react-native')
6969

7070
#### Android: Setup
7171

72-
- Add below lines to `MainApplication.java` inside `onCreate` method, replacing `apiKey` and `appId` which can be found in your [workspace settings](https://app.intercom.com/a/apps/_/settings/android).
72+
- Add below lines to `android/app/src/main/java/com/YOUR_APP/app/MainApplication.java` inside `onCreate` method, replacing `apiKey` and `appId` which can be found in your [workspace settings](https://app.intercom.com/a/apps/_/settings/android).
7373

7474
```java
7575
import com.intercom.reactnative.IntercomModule; // <-- Add this line
@@ -89,16 +89,16 @@ public void onCreate() {
8989
}
9090
```
9191

92-
- Open `android/build.gradle` and change `minSdkVersion` to **21**
92+
- Open `android/build.gradle` and change `minSdkVersion` to **21**, `compileSdkVersion` and `targetSdkVersion` to at least **33**
9393

9494
```Gradle
9595
buildscript {
9696
// ...
9797
ext {
9898
buildToolsVersion = "29.0.2"
9999
minSdkVersion = 21 // <-- Here
100-
compileSdkVersion = 29
101-
targetSdkVersion = 29
100+
compileSdkVersion = 33 // <-- Here
101+
targetSdkVersion = 33 // <-- Here
102102
}
103103
// ...
104104
}
@@ -115,7 +115,7 @@ dependencies {
115115

116116
#### Android: Permissions
117117

118-
You will need to include the [READ\_EXTERNAL\_STORAGE](http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE) permission if you have enabled attachments:
118+
You will need to include the [READ\_EXTERNAL\_STORAGE](http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE) permission in `android/app/src/main/AndroidManifest.xml` if you have enabled attachments:
119119

120120
```xml
121121
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
@@ -177,6 +177,12 @@ import com.intercom.reactnative.IntercomModule;
177177

178178
public class MainNotificationService extends FirebaseMessagingService {
179179

180+
@Override
181+
public void onNewToken(String refreshedToken) {
182+
IntercomModule.sendTokenToIntercom(getApplication(), refreshedToken);
183+
//DO LOGIC HERE
184+
}
185+
180186
public void onMessageReceived(RemoteMessage remoteMessage) {
181187
if (IntercomModule.isIntercomPush(remoteMessage)) {
182188
IntercomModule.handleRemotePushMessage(getApplication(), remoteMessage);
@@ -347,7 +353,7 @@ Notifications.events().registerRemoteNotificationsRegistered(({ deviceToken }: R
347353
#import <UserNotifications/UserNotifications.h>
348354
```
349355

350-
- Request notification permissions when app launches by adding the folloowing to `didFinishLaunchingWithOptions` before `return YES;`:
356+
- Request notification permissions when app launches by adding the following to `didFinishLaunchingWithOptions` before `return YES;`:
351357

352358
```Objective-C
353359
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@@ -820,7 +826,7 @@ Sets a listener for listed events:
820826

821827
```javascript
822828
useEffect(() => {
823-
const listener = Intercom.addEventListener('IntercomUnreadConversationCountDidChangeNotification', ({count}) => alert(count);
829+
const listener = Intercom.addEventListener('IntercomUnreadConversationCountDidChangeNotification', ({count}) => alert(count));
824830
return () => {
825831
listener.remove();
826832
}
@@ -897,6 +903,14 @@ ___
897903
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
898904
```
899905
906+
907+
- #### When tests with Jest fail mentioning "Cannot read property 'UNREAD_CHANGE_NOTIFICATION' of undefined"
908+
- Make a `jest.mock` function with the library:
909+
```
910+
// jest/setup.ts
911+
jest.mock('@intercom/intercom-react-native', () => jest.fn());
912+
```
913+
900914
___
901915
902916
## Author
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package com.rndiffapp.newarchitecture;
2+
3+
import android.app.Application;
4+
import androidx.annotation.NonNull;
5+
import com.facebook.react.PackageList;
6+
import com.facebook.react.ReactInstanceManager;
7+
import com.facebook.react.ReactNativeHost;
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
10+
import com.facebook.react.bridge.JSIModulePackage;
11+
import com.facebook.react.bridge.JSIModuleProvider;
12+
import com.facebook.react.bridge.JSIModuleSpec;
13+
import com.facebook.react.bridge.JSIModuleType;
14+
import com.facebook.react.bridge.JavaScriptContextHolder;
15+
import com.facebook.react.bridge.ReactApplicationContext;
16+
import com.facebook.react.bridge.UIManager;
17+
import com.facebook.react.fabric.ComponentFactory;
18+
import com.facebook.react.fabric.CoreComponentsRegistry;
19+
import com.facebook.react.fabric.FabricJSIModuleProvider;
20+
import com.facebook.react.fabric.ReactNativeConfig;
21+
import com.facebook.react.uimanager.ViewManagerRegistry;
22+
import com.rndiffapp.BuildConfig;
23+
import com.rndiffapp.newarchitecture.components.MainComponentsRegistry;
24+
import com.rndiffapp.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
28+
/**
29+
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
30+
* TurboModule delegates and the Fabric Renderer.
31+
*
32+
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
33+
* `newArchEnabled` property). Is ignored otherwise.
34+
*/
35+
public class MainApplicationReactNativeHost extends ReactNativeHost {
36+
public MainApplicationReactNativeHost(Application application) {
37+
super(application);
38+
}
39+
40+
@Override
41+
public boolean getUseDeveloperSupport() {
42+
return BuildConfig.DEBUG;
43+
}
44+
45+
@Override
46+
protected List<ReactPackage> getPackages() {
47+
List<ReactPackage> packages = new PackageList(this).getPackages();
48+
// Packages that cannot be autolinked yet can be added manually here, for example:
49+
// packages.add(new MyReactNativePackage());
50+
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
51+
// packages.add(new TurboReactPackage() { ... });
52+
// If you have custom Fabric Components, their ViewManagers should also be loaded here
53+
// inside a ReactPackage.
54+
return packages;
55+
}
56+
57+
@Override
58+
protected String getJSMainModuleName() {
59+
return "index";
60+
}
61+
62+
@NonNull
63+
@Override
64+
protected ReactPackageTurboModuleManagerDelegate.Builder
65+
getReactPackageTurboModuleManagerDelegateBuilder() {
66+
// Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
67+
// for the new architecture and to use TurboModules correctly.
68+
return new MainApplicationTurboModuleManagerDelegate.Builder();
69+
}
70+
71+
@Override
72+
protected JSIModulePackage getJSIModulePackage() {
73+
return new JSIModulePackage() {
74+
@Override
75+
public List<JSIModuleSpec> getJSIModules(
76+
final ReactApplicationContext reactApplicationContext,
77+
final JavaScriptContextHolder jsContext) {
78+
final List<JSIModuleSpec> specs = new ArrayList<>();
79+
80+
// Here we provide a new JSIModuleSpec that will be responsible of providing the
81+
// custom Fabric Components.
82+
specs.add(
83+
new JSIModuleSpec() {
84+
@Override
85+
public JSIModuleType getJSIModuleType() {
86+
return JSIModuleType.UIManager;
87+
}
88+
89+
@Override
90+
public JSIModuleProvider<UIManager> getJSIModuleProvider() {
91+
final ComponentFactory componentFactory = new ComponentFactory();
92+
CoreComponentsRegistry.register(componentFactory);
93+
94+
// Here we register a Components Registry.
95+
// The one that is generated with the template contains no components
96+
// and just provides you the one from React Native core.
97+
MainComponentsRegistry.register(componentFactory);
98+
99+
final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
100+
101+
ViewManagerRegistry viewManagerRegistry =
102+
new ViewManagerRegistry(
103+
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
104+
105+
return new FabricJSIModuleProvider(
106+
reactApplicationContext,
107+
componentFactory,
108+
ReactNativeConfig.DEFAULT_CONFIG,
109+
viewManagerRegistry);
110+
}
111+
});
112+
return specs;
113+
}
114+
};
115+
}
116+
}

0 commit comments

Comments
 (0)