1. Home
  2. Docs
  3. CTH Directory Apps
  4. Installation
  5. Adding CTH Directory code to your application

Adding CTH Directory code to your application

Step 1: Backup your App.js and package.json file

Step 2: Copy App.js file, react-native.config.js file, src folder and assets folder from Source Code folder to your project folder.

Step 3: Copy dependencies modules bellow into dependencies property of your package.json file

    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-async-storage/async-storage": "^1.17.6",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/datetimepicker": "^6.1.3",
    "@react-native-community/geolocation": "^2.1.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^9.0.0",
    "@react-native-community/slider": "^4.2.3",
    "@react-navigation/bottom-tabs": "^5.8.0",
    "@react-navigation/material-top-tabs": "^5.2.16",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.9.0",
    "axios": "^0.27.2",
    "deprecated-react-native-prop-types": "^2.3.0",
    "html-entities": "^2.3.3",
    "i18n-js": "^3.9.2",
    "install": "^0.13.0",
    "lodash.memoize": "^4.1.2",
    "moment": "^2.29.3",
    "prop-types": "^15.8.1",
    "react": "18.0.0",
    "react-addons-shallow-compare": "^15.6.3",
    "react-mixin": "^5.0.0",
    "react-native": "0.69.1",
    "react-native-calendars": "^1.1275.0",
    "react-native-gesture-handler": "^2.4.2",
    "react-native-image-picker": "^4.8.4",
    "react-native-linear-gradient": "2.6.0",
    "react-native-maps": "^0.31.1",
    "react-native-paper": "^4.12.1",
    "react-native-reanimated": "^2.8.0",
    "react-native-remote-svg": "^2.0.7",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^4.3.1",
    "react-native-screens": "3.14.0",
    "react-native-svg": "^12.3.0",
    "react-native-vector-icons": "^9.1.0",
    "react-native-web": "^0.18.1",
    "react-native-webview": "^11.22.3",
    "react-redux": "^8.0.2",
    "react-timer-mixin": "^0.13.4",
    "redux": "^4.2.0",
    "redux-thunk": "^2.4.1",
    "sprintf-js": "^1.1.2"

Edit your babel.config.js file with the code bellow

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
          'react-native-reanimated/plugin',
      ],
};

Step 4: Run yarn or npm install command on your project folder. yarn is recommended.

yarn
npm install

iOS fixes

Step 1: Copy fonts list bellow into Info.plist file on ios/YOUR_APP_NAME folder

<key>UIAppFonts</key>
<array>
	<string>AvenirNextLTPro-Bold.ttf</string>
	<string>AvenirNextLTPro-Heavy.ttf</string>
	<string>AvenirNextLTPro-Medium.ttf</string>
	<string>AvenirNextLTPro-Regular.ttf</string>
	<string>AntDesign.ttf</string>
	<string>Entypo.ttf</string>
	<string>EvilIcons.ttf</string>
	<string>Feather.ttf</string>
	<string>FontAwesome.ttf</string>
	<string>FontAwesome5_Brands.ttf</string>
	<string>FontAwesome5_Regular.ttf</string>
	<string>FontAwesome5_Solid.ttf</string>
	<string>Fontisto.ttf</string>
	<string>Foundation.ttf</string>
	<string>Ionicons.ttf</string>
	<string>MaterialCommunityIcons.ttf</string>
	<string>MaterialIcons.ttf</string>
	<string>Octicons.ttf</string>
	<string>SimpleLineIcons.ttf</string>
	<string>Zocial.ttf</string>
</array>

You also need properties for current user location and access photo gallery

<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is required for showing listings near you</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) would like access to your photo gallery to change your profile picture</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) would like to use your camera</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) would like to use your microphone (for videos)</string>

<key>LSApplicationQueriesSchemes</key>
<array>
	<string>tel</string>
	<string>telprompt</string>
</array>

Step 2: Link custom fonts by opening .xcworkspace file in ios folder using Xcode

Browse to assets and drag the folder fonts to your project in Xcode. Make sure your app is checked under “Add to targets” and that “Create groups” is checked.

Step 3: Run the following comment from your project folder to update CocoaPods

cd ios
pod install 
cd ..

Step 4: Open .xcworkspace file in ios folder using Xcode to delete vector icons font entries from Build Phases tab -> Copy Bundle Resources. Do not delete AvenirNexLTPro-xxx.ttf fonts, they are custom fonts.

Step 5: Run ios app

npx react-native run-ios

Android fixes

Step1: Edit build.gradle file on android folder to add code bellow ( see screenshot )

kotlinVersion = "1.6.21"

Step2: Edit build.gradle on android/app folder

 // react native vector icons
project.ext.vectoricons = [
    iconFontNames: [ 
    'Entypo.ttf', 
    'EvilIcons.ttf',
    'Feather.ttf',
    'FontAwesome.ttf',
    'FontAwesome5_Brands.ttf',
    'FontAwesome5_Regular.ttf',
    'FontAwesome5_Solid.ttf',
    'Foundation.ttf',
    'Ionicons.ttf',
    'MaterialIcons.ttf',
    'MaterialCommunityIcons.ttf',
    'SimpleLineIcons.ttf',
    'Octicons.ttf',
    'Zocial.ttf',
    ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Copy the contents in the assets/fonts folder to android/app/src/main/assets/fonts (note lowercase fonts folder).

Step3: Edit /android/app/src/main/AndroidManifest.xml file to add Google Map API key and user location permission ( for getting user location for nearby filter )

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="YOUR_GOOGLE_MAP_API_KEY_HERE"/>

You must enable API key for the Android SDK to make your map working on Android.

Step4: Run android app by using the command bellow

npx react-native run-android

Was this article helpful to you? Yes No 5