-
Notifications
You must be signed in to change notification settings - Fork 11
Tracking usage
Firebase is mainly used for tracking usage and app performance. In addition to the default Firebase events, some custom events have been defined in the app to capture all activity. React Native Firebase version 15.x is implemented. Firebase Cloud Messaging, Crashlytics and Dynamic Links modules are also used for sending push notifications, analysing crashes and capturing referrer details.
Track screen views
Google Analytics tracks screen transitions and attaches information about the current screen to events, it will enable the track metrics such as user engagement or user behavior per screen.
For ex. Child_detail_screen, child_growth, Search, Chatbot, setting, Category_details, List_of_Activities etc.
User properties
User properties are attributes to describe segments of user data, such as language preference. These are used for targeting of push notifications and in the analysis of usage.
Out of 25 available, 6 user properties are used: selected country (country), selected language (language), age of the child (ageid), gender of the child (child_gender), relationship to the child (relationship_with_child), if child is premature (is_premature) and Facebook ID (facebook_id, which is used only for a specific study at the moment)
Events
All custom events, event parameters and user properties are defined in this document.
-
Run the below command on the project directory.
npm uninstall <@react-native-firebase/app>
Remove Firebase related folder from the node package if it is not deleted
Check the below text in the Package.json, if not removed automatically then remove it manually
`"@react-native-firebase/analytics": "^15.1.1",`
`"@react-native-firebase/app": "^15.1.1",`
`"@react-native-firebase/crashlytics": "^15.1.1",`
`"@react-native-firebase/dynamic-links": "^15.4.0",`
`"@react-native-firebase/messaging": "^15.1.1",`
-
Remove the below file from the project
EventSyncService.ts
google-services.json
GoogleService-Info.plist
-
Find the below line and remove it from the entire code
import analytics from '@react-native-firebase/analytics';
import { * } from '@assets/data/firebaseEvents'; // ‘*’ can be any value.
Remove all reference codes from the above imports which were removed
-
Remove the below line from App.tsx
import crashlytics from '@react-native-firebase/crashlytics';
-
You can find below the code start and remove the entire line of code. You also need to remove all used references codes in the below 2 Syntax.
analytics().setUserProperties
logEvent
-
Find in entire project and Remove all conditions in which the below firebase screen conditions are there.
fromScreen === "FirebaseActivities"
fromScreen == "FirebaseVaccinationTab"
fromScreen == "FirebaseHealthCheckupsTab"
fromScreen == "FirebaseArticles"
-
From AppNavigation.tsx file remove import of messaging and all usage of messaging in that file.
import messaging from '@react-native-firebase/messaging';
`useEffect(() => {`
`// console.log('useEffectonMessage');`
`messaging().onNotificationOpenedApp(remoteMessage => {`
`if (remoteMessage) {`
`// background click noti`
`if (userIsOnboarded == true) {`
`redirectPayload(remoteMessage);`
`}`
`}`
`});`
`// Check whether an initial notification is available`
`messaging()`
`.getInitialNotification()`
`.then(remoteMessage => {`
`if (remoteMessage) {`
`// after kill and restart application`
`if (userIsOnboarded == true) {`
`redirectPayload(remoteMessage);`
`}`
`}`
`});`
`messaging().setBackgroundMessageHandler(async remoteMessage => {`
`try {`
`// console.log('Remote notification', JSON.stringify(remoteMessage))`
`} catch (err) {`
`console.log(err)`
`}`
`});`
`setTimeout(() => {`
`SplashScreen.hide();`
`}, 2000);`
`const unsubscribe = messaging().onMessage(async remoteMessage => {`
`//type article/activities`
`//foreground call`
`if (remoteMessage && remoteMessage.notification && remoteMessage.notification.body && remoteMessage.notification.title) {`
`Alert.alert(remoteMessage.notification.title, remoteMessage.notification.body, [`
`{ text: t('forceUpdateOkBtn') }`
`]);`
`}`
`});`
`return unsubscribe;`
`}, [userIsOnboarded]);`
`if (previousRouteName !== currentRouteName) {`
`analytics().logScreenView({`
`screen_name: currentRouteName,`
`screen_class: currentRouteName,`
`});`
`const eventData = { 'name': currentRouteName + "_opened" }`
`logEvent(eventData, netInfo.isConnected)`
`}`
-
Remove the below line from build.gradle file
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
classpath 'com.google.gms:google-services:4.3.12'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
-
Remove the below code from androidmanifest.xml file.
`<service` `android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"` `android:exported="false" >` `<intent-filter>` `<action android:name="com.google.firebase.MESSAGING_EVENT" />` `</intent-filter>` `</service>` `<meta-data android:name="com.google.firebase.messaging.default_notification_icon"` `android:resource="@mipmap/ic_notification" />` `<meta-data` `android:name="com.google.firebase.messaging.default_notification_color"` `android:resource="@color/noti_color"` `tools:replace="android:resource" />`
-
Remove the below line from iOS AppDelegate.m
#import <Firebase.h>
-
Remove the below line from the iOS PodFile:
$RNFirebaseAsStaticFramework = true
-
From podfile we have to also remove or comment below line.
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
Facebook SDK is installed in the app in order to advertise the app on Facebook. iOS version is v12.3.2 and Android version is v12.3.0 with need of upgradation. A Facebook app is created and owned by UNICEF Business Manager. For ad accounts to be linked to this app, Business Manager account can give permissions, please contact Jacob Hunt from Communications team in HQ.
-
Uninstall below node package from the project
npm uninstall <@react-native-fbsdk-next>
Remove below line from Package.json if not removed automatically
`"react-native-fbsdk-next": "^7.3.3",`
- Remove below keys from ios.plist file
FacebookAdvertiserIDCollectionEnabled
FacebookAppID
- Remove below line from build.gradle
force 'com.facebook.android:facebook-android-sdk:12.3.0'
-
Remove below code form /AppNavigation.tsx file
`const handleDynamicLink = (link: any): any => {` `if (link && link.url) {` `// Alert.alert("foreground dynamic link",link.url);` `const facebookId = getSearchParamFromURL(link.url, 'facebook_id');` `facebookId && facebookId != '' ? analytics().setUserProperties({` `facebook_id: facebookId` `}) : null;` `console.log(facebookId, "..facebookId.");` `}` `};` `useEffect(() => {` `const unsubscribe = DynamicLinks().onLink(handleDynamicLink);` `// When the component is unmounted, remove the listener` `DynamicLinks()` `.getInitialLink()` `.then((link: any) => {` `console.log(link, "..11link")` `if (link && link.url) {` `// Alert.alert("background dynamic link",link.url);` `const facebookId = getSearchParamFromURL(link.url, 'facebook_id');` `facebookId && facebookId != '' ? analytics().setUserProperties({` `facebook_id: facebookId` `}) : null;` `console.log(facebookId, "..facebookId11.")` `}` `});` `return (): any => unsubscribe();` `}, []);`