diff --git a/README.md b/README.md index f29e048..7693bcf 100644 --- a/README.md +++ b/README.md @@ -281,7 +281,16 @@ public class MainNotificationService extends FirebaseMessagingService { ``` -See the [example app](https://github.com/intercom/intercom-react-native/blob/main/example/src/App.tsx) for an example of how to handle deep linking in your app. +Add the following in your `MainActivity` + +```kotlin + override fun onNewIntent(intent: Intent) { + super.onNewIntent(intent) + setIntent(intent) + } +``` + +See the [example app](https://github.com/intercom/intercom-react-native/blob/main/sandboxes/NotificationsSandbox/App.tsx) for an example of how to handle deep linking in your app. ### IOS diff --git a/sandboxes/NotificationsSandbox/android/app/src/main/java/com/example/sample/MainActivity.kt b/sandboxes/NotificationsSandbox/android/app/src/main/java/com/example/sample/MainActivity.kt index 9282758..16424dd 100644 --- a/sandboxes/NotificationsSandbox/android/app/src/main/java/com/example/sample/MainActivity.kt +++ b/sandboxes/NotificationsSandbox/android/app/src/main/java/com/example/sample/MainActivity.kt @@ -1,6 +1,7 @@ package com.example.sample -import android.os.Bundle; +import android.os.Bundle +import android.content.Intent import com.facebook.react.ReactActivity import com.facebook.react.ReactActivityDelegate @@ -25,4 +26,13 @@ class MainActivity : ReactActivity() { */ override fun createReactActivityDelegate(): ReactActivityDelegate = DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled) + + /** + * This method is called when a new intent is received while the activity is running. + * It needs to be added if your app needs to handle deep links opened through push notifications. + */ + override fun onNewIntent(intent: Intent) { + super.onNewIntent(intent) + setIntent(intent) + } } diff --git a/sandboxes/NotificationsSandbox/package.json b/sandboxes/NotificationsSandbox/package.json index a995a93..4cedb9d 100644 --- a/sandboxes/NotificationsSandbox/package.json +++ b/sandboxes/NotificationsSandbox/package.json @@ -14,7 +14,7 @@ "rename": "react-native-rename 'notificationsandbox' --skipGitStatusCheck" }, "dependencies": { - "@intercom/intercom-react-native": "^7.0.1", + "@intercom/intercom-react-native": "^7.1.3", "@react-navigation/native": "^6.1.17", "@react-navigation/native-stack": "^6.9.26", "react": "18.2.0",