Skip to content

Commit

Permalink
feat: add Firebase In-App Messaging support
Browse files Browse the repository at this point in the history
  • Loading branch information
pushpender-singh-ap committed Dec 27, 2024
1 parent 4fd73d3 commit 69c23cb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation platform('com.google.firebase:firebase-bom:33.1.0') // Add firebase bom
implementation(platform("com.google.firebase:firebase-bom:33.7.0")) // Import the BoM for the Firebase platform
implementation 'com.google.firebase:firebase-analytics' // Add firebase analytics
implementation("com.google.firebase:firebase-crashlytics") // Add firebase crashlytics
implementation("com.google.firebase:firebase-inappmessaging-display") // Add firebase inapp messaging

implementation ('com.facebook.soloader:soloader:0.12.1+')

Expand Down
3 changes: 2 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"messaging_auto_init_enabled": true,
"messaging_android_notification_channel_id": "high-priority",
"perf_auto_collection_enabled": false,
"google_analytics_automatic_screen_reporting_enabled": true
"google_analytics_automatic_screen_reporting_enabled": true,
"in_app_messaging_auto_collection_enabled": true
}
}
20 changes: 20 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ PODS:
- Firebase/Crashlytics (11.4.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 11.4.0)
- Firebase/InAppMessaging (11.4.0):
- Firebase/CoreOnly
- FirebaseInAppMessaging (~> 11.4.0-beta)
- Firebase/Messaging (11.4.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 11.4.0)
Expand Down Expand Up @@ -104,6 +107,13 @@ PODS:
- GoogleUtilities/Environment (~> 8.0)
- nanopb (~> 3.30910.0)
- PromisesObjC (~> 2.4)
- FirebaseInAppMessaging (11.4.0-beta):
- FirebaseABTesting (~> 11.0)
- FirebaseCore (~> 11.0)
- FirebaseInstallations (~> 11.0)
- GoogleUtilities/Environment (~> 8.0)
- GoogleUtilities/UserDefaults (~> 8.0)
- nanopb (~> 3.30910.0)
- FirebaseInstallations (11.4.0):
- FirebaseCore (~> 11.0)
- GoogleUtilities/Environment (~> 8.0)
Expand Down Expand Up @@ -1926,6 +1936,10 @@ PODS:
- FirebaseCoreExtension (<= 11.4.0)
- React-Core
- RNFBApp
- RNFBInAppMessaging (21.6.1):
- Firebase/InAppMessaging (= 11.4.0)
- React-Core
- RNFBApp
- RNFBMessaging (21.4.0):
- Firebase/Messaging (<= 11.4.0)
- FirebaseCoreExtension (<= 11.4.0)
Expand Down Expand Up @@ -2256,6 +2270,7 @@ DEPENDENCIES:
- "RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`)"
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
- "RNFBCrashlytics (from `../node_modules/@react-native-firebase/crashlytics`)"
- "RNFBInAppMessaging (from `../node_modules/@react-native-firebase/in-app-messaging`)"
- "RNFBMessaging (from `../node_modules/@react-native-firebase/messaging`)"
- "RNFBPerf (from `../node_modules/@react-native-firebase/perf`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
Expand All @@ -2275,6 +2290,7 @@ SPEC REPOS:
- FirebaseCoreExtension
- FirebaseCoreInternal
- FirebaseCrashlytics
- FirebaseInAppMessaging
- FirebaseInstallations
- FirebaseMessaging
- FirebasePerformance
Expand Down Expand Up @@ -2445,6 +2461,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-firebase/app"
RNFBCrashlytics:
:path: "../node_modules/@react-native-firebase/crashlytics"
RNFBInAppMessaging:
:path: "../node_modules/@react-native-firebase/in-app-messaging"
RNFBMessaging:
:path: "../node_modules/@react-native-firebase/messaging"
RNFBPerf:
Expand Down Expand Up @@ -2478,6 +2496,7 @@ SPEC CHECKSUMS:
FirebaseCoreExtension: 4445e4cd877e0790c4af33bedca61eaef27b7513
FirebaseCoreInternal: f47dd28ae7782e6a4738aad3106071a8fe0af604
FirebaseCrashlytics: 41bbdd2b514a8523cede0c217aee6ef7ecf38401
FirebaseInAppMessaging: 711d4357e9e6cfab5123f67ce1ea1f63bbb6442d
FirebaseInstallations: 6ef4a1c7eb2a61ee1f74727d7f6ce2e72acf1414
FirebaseMessaging: f8a160d99c2c2e5babbbcc90c4a3e15db036aee2
FirebasePerformance: 89f9e52ea9d86d1819cde923a7ca397743df8593
Expand Down Expand Up @@ -2563,6 +2582,7 @@ SPEC CHECKSUMS:
RNFBAnalytics: e4b4e0d20810d12309e5522432fbf4c0f2b2c2e1
RNFBApp: 21cbda2e7d2657cd3c92f490c050f5f0905d2ff0
RNFBCrashlytics: 1f0f79d23fc26cebc5325edf685f69bb5b9493e2
RNFBInAppMessaging: 1500674838d6f688f8dac648b16b9cad3898505d
RNFBMessaging: 5bc9395c4d411f0411e6ea939dd61fd5247a3db8
RNFBPerf: 816ff369b041978ab7a10dcbdafff0e88dc6b39c
RNGestureHandler: 1e33ee267aaf61bbab6089d32df3b38c3024e3dd
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@react-native-firebase/analytics": "^21.4.0",
"@react-native-firebase/app": "^21.4.0",
"@react-native-firebase/crashlytics": "^21.4.0",
"@react-native-firebase/in-app-messaging": "^21.6.1",
"@react-native-firebase/messaging": "^21.4.0",
"@react-native-firebase/perf": "^21.4.0",
"@react-native-picker/picker": "^2.9.0",
Expand Down
14 changes: 14 additions & 0 deletions src/Navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import messaging from '@react-native-firebase/messaging';
import {firebase} from '@react-native-firebase/perf';
import crashlytics from '@react-native-firebase/crashlytics';
import {firebase as fire} from '@react-native-firebase/analytics';
import inAppMessaging from '@react-native-firebase/in-app-messaging';

import {
check,
request,
Expand Down Expand Up @@ -83,6 +85,17 @@ export function RootNavigation() {
console.log('Adapter Statuses ->', adapterStatuses);
}

/**
* Enables the reception of in-app messages by disabling message display suppression.
*
* @async
* @function allowToReceiveInAppMessages
* @returns {Promise<void>} Resolves when in-app messages can be received.
*/
async function allowToReceiveInAppMessages() {
await inAppMessaging().setMessagesDisplaySuppressed(false);
}

/**
* Enables analytics collection for the application.
*
Expand Down Expand Up @@ -123,6 +136,7 @@ export function RootNavigation() {
}

useEffect(() => {
allowToReceiveInAppMessages();
requestUserPermission();
requestAppTrackingPermission();
if (!__DEV__) {
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,16 @@ __metadata:
languageName: node
linkType: hard

"@react-native-firebase/in-app-messaging@npm:^21.6.1":
version: 21.6.1
resolution: "@react-native-firebase/in-app-messaging@npm:21.6.1"
peerDependencies:
"@react-native-firebase/analytics": 21.6.1
"@react-native-firebase/app": 21.6.1
checksum: e086fb9319ab79c8300a2a3461c5af2db7e881f49a71790feb0a16d1a77420a5dc43f29ed74078e56b040c1058782b80b927511736190bd52e25f3d4513fdc90
languageName: node
linkType: hard

"@react-native-firebase/messaging@npm:^21.4.0":
version: 21.4.0
resolution: "@react-native-firebase/messaging@npm:21.4.0"
Expand Down Expand Up @@ -4002,6 +4012,7 @@ __metadata:
"@react-native-firebase/analytics": ^21.4.0
"@react-native-firebase/app": ^21.4.0
"@react-native-firebase/crashlytics": ^21.4.0
"@react-native-firebase/in-app-messaging": ^21.6.1
"@react-native-firebase/messaging": ^21.4.0
"@react-native-firebase/perf": ^21.4.0
"@react-native-picker/picker": ^2.9.0
Expand Down

0 comments on commit 69c23cb

Please sign in to comment.