diff --git a/README.md b/README.md index 9a1ee1cf..e24779ce 100644 --- a/README.md +++ b/README.md @@ -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 } // ... } @@ -275,22 +275,6 @@ apply from: file("../../node_modules/@react-native-community/cli-platform-androi ``` -- 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 `` inside `AndroidManifest.xml` @@ -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` - ---- - ### `Intercom.present()` Opens the Intercom Messenger automatically to the best place for your users. diff --git a/android/build.gradle b/android/build.gradle index 37a782c4..4d81c5e4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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" } @@ -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") } } @@ -53,7 +53,7 @@ android { minifyEnabled false } } - lintOptions { + lint { disable 'GradleCompatible' } buildFeatures { @@ -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.1' + implementation 'io.intercom.android:intercom-sdk-ui:18.0.1' } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index d951fac2..11581996 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/android/src/main/java/com/intercom/reactnative/IntercomErrorCodes.java b/android/src/main/java/com/intercom/reactnative/IntercomErrorCodes.java index 7bde7b81..9ac189e9 100644 --- a/android/src/main/java/com/intercom/reactnative/IntercomErrorCodes.java +++ b/android/src/main/java/com/intercom/reactnative/IntercomErrorCodes.java @@ -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"; diff --git a/android/src/newarch/IntercomModule.java b/android/src/newarch/IntercomModule.java index a6e4d8f3..88f4d342 100644 --- a/android/src/newarch/IntercomModule.java +++ b/android/src/newarch/IntercomModule.java @@ -4,8 +4,6 @@ import android.app.Application; import android.content.Intent; import android.util.Log; -import android.widget.Toast; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -13,7 +11,6 @@ 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; @@ -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 { diff --git a/android/src/oldarch/IntercomModule.java b/android/src/oldarch/IntercomModule.java index 06529479..6e8a34c9 100644 --- a/android/src/oldarch/IntercomModule.java +++ b/android/src/oldarch/IntercomModule.java @@ -4,8 +4,6 @@ import android.app.Application; import android.content.Intent; import android.util.Log; -import android.widget.Toast; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -13,7 +11,6 @@ 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; @@ -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 { diff --git a/examples/example/src/App.tsx b/examples/example/src/App.tsx index dab1315e..f3358139 100644 --- a/examples/example/src/App.tsx +++ b/examples/example/src/App.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { useEffect, useState } from 'react'; import { Alert, - AppState, Image, Linking, NativeEventEmitter, @@ -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 */ @@ -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 }; }, []); diff --git a/examples/expo-example/app/_layout.tsx b/examples/expo-example/app/_layout.tsx index 141e93ee..7b1c1a5d 100644 --- a/examples/expo-example/app/_layout.tsx +++ b/examples/expo-example/app/_layout.tsx @@ -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) { @@ -29,7 +21,6 @@ export default function RootLayout() { }); return () => { - subscription.remove(); urlListener.remove(); }; }, []); diff --git a/examples/with-notifications/src/screens/HomeScreen.tsx b/examples/with-notifications/src/screens/HomeScreen.tsx index 94c71475..87669f25 100644 --- a/examples/with-notifications/src/screens/HomeScreen.tsx +++ b/examples/with-notifications/src/screens/HomeScreen.tsx @@ -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 diff --git a/src/NativeIntercomSpec.ts b/src/NativeIntercomSpec.ts index 6f62da5f..a21a9ce6 100644 --- a/src/NativeIntercomSpec.ts +++ b/src/NativeIntercomSpec.ts @@ -80,7 +80,6 @@ export interface Spec extends TurboModule { setInAppMessageVisibility(visibility: string): Promise; setLauncherVisibility(visibility: string): Promise; setNeedsStatusBarAppearanceUpdate(): Promise; - handlePushMessage(): Promise; sendTokenToIntercom(token: string): Promise; setLogLevel(logLevel: string): Promise; setThemeMode(themeMode: string): Promise; diff --git a/src/index.tsx b/src/index.tsx index 074509bd..c0eb7bb7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -251,13 +251,6 @@ export type IntercomType = { */ setNeedsStatusBarAppearanceUpdate(): Promise; - /** - * Handle an Android push notification payload sent by Intercom. - * - * @note Android only. iOS handles push notifications automatically. - */ - handlePushMessage(): Promise; - /** * 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. @@ -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),