Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 4 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ public void onCreate() {
}
```

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

```Gradle
buildscript {
// ...
ext {
buildToolsVersion = "35.0.0"
buildToolsVersion = "36.0.0"
minSdkVersion = 23 // <-- Here
compileSdkVersion = 35 // <-- Here
targetSdkVersion = 35 // <-- Here
compileSdkVersion = 36 // <-- Here
targetSdkVersion = 36 // <-- Here
}
// ...
}
Expand Down Expand Up @@ -275,22 +275,6 @@ apply from: file("../../node_modules/@react-native-community/cli-platform-androi
</manifest>
```

- Add below code to your React Native app

```jsx
useEffect(() => {
/**
* Handle PushNotification
*/
const appStateListener = AppState.addEventListener(
'change',
(nextAppState) => nextAppState === 'active' && Intercom.handlePushMessage()
);
return () => AppState.removeEventListener('change', () => true); // <- for RN < 0.65
return () => appStateListener.remove(); // <- for RN >= 0.65
}, []);
```

#### Android: Push notification deep links support

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

---

### `Intercom.handlePushMessage()`

Handles the opening of an Intercom push message. This will retrieve the URI from the last Intercom push message.

```javascript
useEffect(() => {
/**
* Handle PushNotification Open
*/
const appStateListener = AppState.addEventListener(
'change',
(nextAppState) => nextAppState === 'active' && Intercom.handlePushMessage()
);

return () => AppState.removeEventListener('change', () => {}); // <- for RN < 0.65
return () => appStateListener.remove(); // <- for RN >= 0.65
}, []);
```

### Returns

`Promise<boolean>`

---

### `Intercom.present()`

Opens the Intercom Messenger automatically to the best place for your users.
Expand Down
14 changes: 7 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ def packageVersion = '"' + packageJson.version + '"'

buildscript {
ext {
buildToolsVersion = "35.0.0"
buildToolsVersion = "36.0.0"
minSdkVersion = 23
compileSdkVersion = 35
targetSdkVersion = 35
compileSdkVersion = 36
targetSdkVersion = 36
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
}
Expand All @@ -19,7 +19,7 @@ buildscript {
}

dependencies {
classpath("com.android.tools.build:gradle:8.6.1")
classpath("com.android.tools.build:gradle:8.9.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
Expand Down Expand Up @@ -53,7 +53,7 @@ android {
minifyEnabled false
}
}
lintOptions {
lint {
disable 'GradleCompatible'
}
buildFeatures {
Expand Down Expand Up @@ -84,6 +84,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.firebase:firebase-messaging:24.1.2"
implementation 'io.intercom.android:intercom-sdk:17.4.7'
implementation 'io.intercom.android:intercom-sdk-ui:17.4.7'
implementation 'io.intercom.android:intercom-sdk:18.0.0'
implementation 'io.intercom.android:intercom-sdk-ui:18.0.0'
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class IntercomErrorCodes {
public static final String SET_LAUNCHER_VISIBILITY = "208";
public static final String SET_BOTTOM_PADDING = "209";
public static final String SET_THEME_MODE = "210";
public static final String HANDLE_PUSH_MESSAGE = "301";
public static final String SEND_TOKEN_TO_INTERCOM = "302";
public static final String FETCH_HELP_CENTER_COLLECTIONS = "901";
public static final String FETCH_HELP_CENTER_COLLECTION = "902";
Expand Down
16 changes: 0 additions & 16 deletions android/src/newarch/IntercomModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
import android.app.Application;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.google.firebase.messaging.RemoteMessage;
Expand Down Expand Up @@ -115,19 +112,6 @@ public static void sendTokenToIntercom(Application application, @NonNull String
}
}

@ReactMethod
public void handlePushMessage(Promise promise) {
try {
Intercom.client().handlePushMessage();
promise.resolve(true);
Log.d(NAME, "handlePushMessage");
} catch (Exception err) {
Log.e(NAME, "handlePushMessage error:");
Log.e(NAME, err.toString());
promise.reject(IntercomErrorCodes.HANDLE_PUSH_MESSAGE, err.toString());
}
}

@ReactMethod
public void sendTokenToIntercom(@NonNull String token, Promise promise) {
try {
Expand Down
16 changes: 0 additions & 16 deletions android/src/oldarch/IntercomModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
import android.app.Application;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.google.firebase.messaging.RemoteMessage;
Expand Down Expand Up @@ -98,19 +95,6 @@ public static void sendTokenToIntercom(Application application, @NonNull String
Log.d(NAME, "sendTokenToIntercom");
}

@ReactMethod
public void handlePushMessage(Promise promise) {
try {
Intercom.client().handlePushMessage();
promise.resolve(true);
Log.d(NAME, "handlePushMessage");
} catch (Exception err) {
Log.e(NAME, "handlePushMessage error:");
Log.e(NAME, err.toString());
promise.reject(IntercomErrorCodes.HANDLE_PUSH_MESSAGE, err.toString());
}
}

@ReactMethod
public void sendTokenToIntercom(@NonNull String token, Promise promise) {
try {
Expand Down
11 changes: 0 additions & 11 deletions examples/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { useEffect, useState } from 'react';
import {
Alert,
AppState,
Image,
Linking,
NativeEventEmitter,
Expand Down Expand Up @@ -134,12 +133,6 @@ export default function App() {
/**
* Handle PushNotification
*/
const appChangeListener = AppState.addEventListener(
'change',
(nextAppState) =>
nextAppState === 'active' && Intercom.handlePushMessage()
);

/**
* Handle Push Notification deep links
*/
Expand Down Expand Up @@ -184,10 +177,6 @@ export default function App() {
// @ts-ignore - type definitions haven't been updated to 0.65 yet
urlListener.remove(); // <- for RN 0.65+
// Linking.removeEventListener('url', () => {}); <- for RN < 0.65

// @ts-ignore - type definitions haven't been updated to 0.65 yet
appChangeListener.remove(); // <- for RN 0.65+
//AppState.removeEventListener('change', () => {}); <- for RN < 0.65
};
}, []);

Expand Down
11 changes: 1 addition & 10 deletions examples/expo-example/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ import { useFonts } from 'expo-font';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import React, { useEffect } from 'react';
import { Alert, AppState, Linking } from 'react-native';
import { Alert, Linking } from 'react-native';
import 'react-native-reanimated';

import Intercom from '@intercom/intercom-react-native';

export default function RootLayout() {
const [loaded] = useFonts({
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
});

useEffect(() => {
// Handle push notifications when app is active
const subscription = AppState.addEventListener(
'change',
(nextStatus) => nextStatus === 'active' && Intercom.handlePushMessage()
);

// Handle deep links
const urlListener = Linking.addEventListener('url', (event) => {
if (event) {
Expand All @@ -29,7 +21,6 @@ export default function RootLayout() {
});

return () => {
subscription.remove();
urlListener.remove();
};
}, []);
Expand Down
16 changes: 1 addition & 15 deletions examples/with-notifications/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import React, { useEffect } from 'react';
import {
AppState,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import { Text, TextInput, TouchableOpacity, View } from 'react-native';
import Intercom, { Visibility } from '@intercom/intercom-react-native';
import { requestNotifications } from 'react-native-permissions';
import { useIntercom } from '../hooks/useIntercom';
import { styles } from '../styles/App.styles';

export function HomeScreen(): React.JSX.Element {
useEffect(() => {
const subscription = AppState.addEventListener(
'change',
nextStatus => nextStatus === 'active' && Intercom?.handlePushMessage()
);
return subscription.remove;
}, []);

useEffect(() => {
(async () => {
// Request permissions
Expand Down
1 change: 0 additions & 1 deletion src/NativeIntercomSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export interface Spec extends TurboModule {
setInAppMessageVisibility(visibility: string): Promise<boolean>;
setLauncherVisibility(visibility: string): Promise<boolean>;
setNeedsStatusBarAppearanceUpdate(): Promise<boolean>;
handlePushMessage(): Promise<boolean>;
sendTokenToIntercom(token: string): Promise<boolean>;
setLogLevel(logLevel: string): Promise<boolean>;
setThemeMode(themeMode: string): Promise<boolean>;
Expand Down
12 changes: 0 additions & 12 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,6 @@ export type IntercomType = {
*/
setNeedsStatusBarAppearanceUpdate(): Promise<boolean>;

/**
* Handle an Android push notification payload sent by Intercom.
*
* @note Android only. iOS handles push notifications automatically.
*/
handlePushMessage(): Promise<boolean>;

/**
* Send a device token to Intercom to enable push notifications to be sent to the User.
* @param token The device token to send to the server.
Expand Down Expand Up @@ -404,11 +397,6 @@ const Intercom: IntercomType = {
default: async () => true,
}),

handlePushMessage: Platform.select({
android: IntercomModule.handlePushMessage,
default: async () => true,
}),

sendTokenToIntercom: (token) => IntercomModule.sendTokenToIntercom(token),
setLogLevel: (logLevel) => IntercomModule.setLogLevel(logLevel),
setThemeMode: (themeMode) => IntercomModule.setThemeMode(themeMode),
Expand Down
Loading