Skip to content

Commit bb56b79

Browse files
imSzukalaclaude
andauthored
feat(android)!: upgrade Intercom Android SDK to 18.0.1 (#411)
* feat(android)!: upgrade Intercom Android SDK to 18.0.0 Upgrade the Android SDK from 17.4.7 to 18.0.0, a major release that removes the `handlePushMessage()` API — the SDK now automatically opens conversations when push notifications are tapped. Breaking changes: - Remove `handlePushMessage()` from native modules, TurboModule spec, and public JS API - Raise compileSdk/targetSdk to 36 and buildToolsVersion to 36.0.0 - Upgrade AGP to 8.9.0 and Gradle to 8.11.1 Cleanup: - Remove dead HANDLE_PUSH_MESSAGE error code constant - Remove unused Toast and ReadableArray imports from both arch modules - Migrate deprecated lintOptions to lint block in build.gradle - Update README to remove handlePushMessage docs and fix SDK versions - Remove handlePushMessage AppState listeners from all example apps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(lint): fix prettier formatting in HomeScreen import Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat(android)!: upgrade Intercom Android SDK to 18.0.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore(example): remove orphan comment left after handlePushMessage removal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: bump version to 10.0.0 for Android SDK 18.0.1 breaking change Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9d46ea6 commit bb56b79

File tree

12 files changed

+15
-139
lines changed

12 files changed

+15
-139
lines changed

README.md

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ public void onCreate() {
111111
}
112112
```
113113

114-
- Open `android/build.gradle` and change `minSdkVersion` to **23**, `compileSdkVersion` and `targetSdkVersion` to **35**
114+
- Open `android/build.gradle` and change `minSdkVersion` to **23**, `compileSdkVersion` and `targetSdkVersion` to **36**
115115

116116
```Gradle
117117
buildscript {
118118
// ...
119119
ext {
120-
buildToolsVersion = "35.0.0"
120+
buildToolsVersion = "36.0.0"
121121
minSdkVersion = 23 // <-- Here
122-
compileSdkVersion = 35 // <-- Here
123-
targetSdkVersion = 35 // <-- Here
122+
compileSdkVersion = 36 // <-- Here
123+
targetSdkVersion = 36 // <-- Here
124124
}
125125
// ...
126126
}
@@ -275,22 +275,6 @@ apply from: file("../../node_modules/@react-native-community/cli-platform-androi
275275
</manifest>
276276
```
277277

278-
- Add below code to your React Native app
279-
280-
```jsx
281-
useEffect(() => {
282-
/**
283-
* Handle PushNotification
284-
*/
285-
const appStateListener = AppState.addEventListener(
286-
'change',
287-
(nextAppState) => nextAppState === 'active' && Intercom.handlePushMessage()
288-
);
289-
return () => AppState.removeEventListener('change', () => true); // <- for RN < 0.65
290-
return () => appStateListener.remove(); // <- for RN >= 0.65
291-
}, []);
292-
```
293-
294278
#### Android: Push notification deep links support
295279

296280
- Add below code to `<activity>` inside `AndroidManifest.xml`
@@ -996,31 +980,6 @@ Gets the number of unread conversations for a user.
996980

997981
---
998982

999-
### `Intercom.handlePushMessage()`
1000-
1001-
Handles the opening of an Intercom push message. This will retrieve the URI from the last Intercom push message.
1002-
1003-
```javascript
1004-
useEffect(() => {
1005-
/**
1006-
* Handle PushNotification Open
1007-
*/
1008-
const appStateListener = AppState.addEventListener(
1009-
'change',
1010-
(nextAppState) => nextAppState === 'active' && Intercom.handlePushMessage()
1011-
);
1012-
1013-
return () => AppState.removeEventListener('change', () => {}); // <- for RN < 0.65
1014-
return () => appStateListener.remove(); // <- for RN >= 0.65
1015-
}, []);
1016-
```
1017-
1018-
### Returns
1019-
1020-
`Promise<boolean>`
1021-
1022-
---
1023-
1024983
### `Intercom.present()`
1025984

1026985
Opens the Intercom Messenger automatically to the best place for your users.

android/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ def packageVersion = '"' + packageJson.version + '"'
55

66
buildscript {
77
ext {
8-
buildToolsVersion = "35.0.0"
8+
buildToolsVersion = "36.0.0"
99
minSdkVersion = 23
10-
compileSdkVersion = 35
11-
targetSdkVersion = 35
10+
compileSdkVersion = 36
11+
targetSdkVersion = 36
1212
ndkVersion = "26.1.10909125"
1313
kotlinVersion = "1.9.22"
1414
}
@@ -19,7 +19,7 @@ buildscript {
1919
}
2020

2121
dependencies {
22-
classpath("com.android.tools.build:gradle:8.6.1")
22+
classpath("com.android.tools.build:gradle:8.9.0")
2323
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
2424
}
2525
}
@@ -53,7 +53,7 @@ android {
5353
minifyEnabled false
5454
}
5555
}
56-
lintOptions {
56+
lint {
5757
disable 'GradleCompatible'
5858
}
5959
buildFeatures {
@@ -84,6 +84,6 @@ dependencies {
8484
//noinspection GradleDynamicVersion
8585
implementation "com.facebook.react:react-native:+" // From node_modules
8686
implementation "com.google.firebase:firebase-messaging:24.1.2"
87-
implementation 'io.intercom.android:intercom-sdk:17.4.7'
88-
implementation 'io.intercom.android:intercom-sdk-ui:17.4.7'
87+
implementation 'io.intercom.android:intercom-sdk:18.0.1'
88+
implementation 'io.intercom.android:intercom-sdk-ui:18.0.1'
8989
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

android/src/main/java/com/intercom/reactnative/IntercomErrorCodes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class IntercomErrorCodes {
2020
public static final String SET_LAUNCHER_VISIBILITY = "208";
2121
public static final String SET_BOTTOM_PADDING = "209";
2222
public static final String SET_THEME_MODE = "210";
23-
public static final String HANDLE_PUSH_MESSAGE = "301";
2423
public static final String SEND_TOKEN_TO_INTERCOM = "302";
2524
public static final String FETCH_HELP_CENTER_COLLECTIONS = "901";
2625
public static final String FETCH_HELP_CENTER_COLLECTION = "902";

android/src/newarch/IntercomModule.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
import android.app.Application;
55
import android.content.Intent;
66
import android.util.Log;
7-
import android.widget.Toast;
8-
97
import androidx.annotation.NonNull;
108
import androidx.annotation.Nullable;
119

1210
import com.facebook.react.bridge.Promise;
1311
import com.facebook.react.bridge.ReactApplicationContext;
1412
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1513
import com.facebook.react.bridge.ReactMethod;
16-
import com.facebook.react.bridge.ReadableArray;
1714
import com.facebook.react.bridge.ReadableMap;
1815
import com.facebook.react.module.annotations.ReactModule;
1916
import com.google.firebase.messaging.RemoteMessage;
@@ -115,19 +112,6 @@ public static void sendTokenToIntercom(Application application, @NonNull String
115112
}
116113
}
117114

118-
@ReactMethod
119-
public void handlePushMessage(Promise promise) {
120-
try {
121-
Intercom.client().handlePushMessage();
122-
promise.resolve(true);
123-
Log.d(NAME, "handlePushMessage");
124-
} catch (Exception err) {
125-
Log.e(NAME, "handlePushMessage error:");
126-
Log.e(NAME, err.toString());
127-
promise.reject(IntercomErrorCodes.HANDLE_PUSH_MESSAGE, err.toString());
128-
}
129-
}
130-
131115
@ReactMethod
132116
public void sendTokenToIntercom(@NonNull String token, Promise promise) {
133117
try {

android/src/oldarch/IntercomModule.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
import android.app.Application;
55
import android.content.Intent;
66
import android.util.Log;
7-
import android.widget.Toast;
8-
97
import androidx.annotation.NonNull;
108
import androidx.annotation.Nullable;
119

1210
import com.facebook.react.bridge.Promise;
1311
import com.facebook.react.bridge.ReactApplicationContext;
1412
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1513
import com.facebook.react.bridge.ReactMethod;
16-
import com.facebook.react.bridge.ReadableArray;
1714
import com.facebook.react.bridge.ReadableMap;
1815
import com.facebook.react.module.annotations.ReactModule;
1916
import com.google.firebase.messaging.RemoteMessage;
@@ -98,19 +95,6 @@ public static void sendTokenToIntercom(Application application, @NonNull String
9895
Log.d(NAME, "sendTokenToIntercom");
9996
}
10097

101-
@ReactMethod
102-
public void handlePushMessage(Promise promise) {
103-
try {
104-
Intercom.client().handlePushMessage();
105-
promise.resolve(true);
106-
Log.d(NAME, "handlePushMessage");
107-
} catch (Exception err) {
108-
Log.e(NAME, "handlePushMessage error:");
109-
Log.e(NAME, err.toString());
110-
promise.reject(IntercomErrorCodes.HANDLE_PUSH_MESSAGE, err.toString());
111-
}
112-
}
113-
11498
@ReactMethod
11599
public void sendTokenToIntercom(@NonNull String token, Promise promise) {
116100
try {

examples/example/src/App.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react';
22
import { useEffect, useState } from 'react';
33
import {
44
Alert,
5-
AppState,
65
Image,
76
Linking,
87
NativeEventEmitter,
@@ -131,15 +130,6 @@ export default function App() {
131130
}
132131
});
133132

134-
/**
135-
* Handle PushNotification
136-
*/
137-
const appChangeListener = AppState.addEventListener(
138-
'change',
139-
(nextAppState) =>
140-
nextAppState === 'active' && Intercom.handlePushMessage()
141-
);
142-
143133
/**
144134
* Handle Push Notification deep links
145135
*/
@@ -184,10 +174,6 @@ export default function App() {
184174
// @ts-ignore - type definitions haven't been updated to 0.65 yet
185175
urlListener.remove(); // <- for RN 0.65+
186176
// Linking.removeEventListener('url', () => {}); <- for RN < 0.65
187-
188-
// @ts-ignore - type definitions haven't been updated to 0.65 yet
189-
appChangeListener.remove(); // <- for RN 0.65+
190-
//AppState.removeEventListener('change', () => {}); <- for RN < 0.65
191177
};
192178
}, []);
193179

examples/expo-example/app/_layout.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@ import { useFonts } from 'expo-font';
44
import { Stack } from 'expo-router';
55
import { StatusBar } from 'expo-status-bar';
66
import React, { useEffect } from 'react';
7-
import { Alert, AppState, Linking } from 'react-native';
7+
import { Alert, Linking } from 'react-native';
88
import 'react-native-reanimated';
99

10-
import Intercom from '@intercom/intercom-react-native';
11-
1210
export default function RootLayout() {
1311
const [loaded] = useFonts({
1412
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
1513
});
1614

1715
useEffect(() => {
18-
// Handle push notifications when app is active
19-
const subscription = AppState.addEventListener(
20-
'change',
21-
(nextStatus) => nextStatus === 'active' && Intercom.handlePushMessage()
22-
);
23-
2416
// Handle deep links
2517
const urlListener = Linking.addEventListener('url', (event) => {
2618
if (event) {
@@ -29,7 +21,6 @@ export default function RootLayout() {
2921
});
3022

3123
return () => {
32-
subscription.remove();
3324
urlListener.remove();
3425
};
3526
}, []);

examples/with-notifications/src/screens/HomeScreen.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import React, { useEffect } from 'react';
2-
import {
3-
AppState,
4-
Text,
5-
TextInput,
6-
TouchableOpacity,
7-
View,
8-
} from 'react-native';
2+
import { Text, TextInput, TouchableOpacity, View } from 'react-native';
93
import Intercom, { Visibility } from '@intercom/intercom-react-native';
104
import { requestNotifications } from 'react-native-permissions';
115
import { useIntercom } from '../hooks/useIntercom';
126
import { styles } from '../styles/App.styles';
137

148
export function HomeScreen(): React.JSX.Element {
15-
useEffect(() => {
16-
const subscription = AppState.addEventListener(
17-
'change',
18-
nextStatus => nextStatus === 'active' && Intercom?.handlePushMessage()
19-
);
20-
return subscription.remove;
21-
}, []);
22-
239
useEffect(() => {
2410
(async () => {
2511
// Request permissions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@intercom/intercom-react-native",
3-
"version": "9.8.1",
3+
"version": "10.0.0",
44
"description": "React Native wrapper to bridge our iOS and Android SDK",
55
"source": "./src/index.tsx",
66
"main": "./lib/commonjs/index.js",

0 commit comments

Comments
 (0)