Themes Coder Grocery & Delivery SolutionsDocs
Getting started

React Native app installation

This chapter covers React Installation and React App Installation.

React App Installation#

This section will help you walk through the minimum required setup to run project.

Required Setup#

First, this is important, please make sure you have already install and run the simulator successful base on this guide with REACT-NATIVE-CLI.

It will help you install and build your first Example React Native app.

Installing Node Modules#

Open terminal and go to project folder and run following command

npm install

yarn

iOS Setup (Mac OS only)#

Follow above link React Native CLI Quickstart -> macOS -> iOS we are using node v12.14.1

Running Simulator#

Run following command if you have installed node modules from previous command.

CocoaPods#

cd ios && pod install

After installation of all dependencies back to previous folder

cd ..

run this command

npx react-native run-ios

Android Setup (Mac OS, Windows, Linux)#

Change Android SDK Path#

Go to 1. File -> project Structure into Project Structure 2. Left -> SDK Location SDK location select Android SDK location

Running Emulator#

To check the Android device is ready or not run following command from your terminal

adb devices

Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Preferences" dialog, under Appearance & Behavior → System Settings → Android SDK. If you have device listed you can run following command.

npx react-native run-android

if you are on window and getting error metro bundle ‘react-native start' then go node_modulesmetro-configsrcdefaultsblacklist.js and replace var sharedBlacklist = [ /node_modules[/]react[/]dist[/].*/, /website/node_modules/.*/, /heapCapture/bundle.js/, /.*/__tests__/.*/ ]; to: var sharedBlacklist = [ /node_modules[/]react[/]dist[/].*/, /website/node_modules/.*/, /heapCapture/bundle.js/, /.*/__tests__/.*/ ];

Ecommerce Configuration#

This section will guide how to make the app work.

Required Setup#

App Config#

Go to the project folder open the file: src/common/Theme.style.js and follow the below steps to set up the app.

  • https://your-site.com (it will be the url of your domain)
  • Client ID
  • Client secret
  • Change the colors for your theme
  • Change the Text size of the application small, medium, Large, Custom radius,
  • Font family
  • webClientIdForGoogleSign (add this webclient id from firebase for google login)

we need to go into our Firebase console and enable Google authentication for our app.

‌Once you’re inside the app’s dashboard, you’re going to go into

Authentication → Sign-In Method → Google

and click the Enable toggle.

Now save your web client Id and paste it into the config file in the webClientIdForGoogleSign variable. for further details visit this URL https://enappd.com/blog/google-login-in-react-native-android-apps-with-firebase/90/

Google Map Integration (Android)#

Add Google Map Api key#

Go to the Firebase Project and create a new one with new android package name

Next screen shot

Google Map Integration (IOS)#

Add Google Map Api key#

Go to the Firebase Project and create a new one with new android package name

Next screen shot

Next screen shot

Next screen shot

Change SplashScreen and app Icon#

Android#

go into android/app/src/res/mipmap(dpi,mdpi,xhdpi,xxhdpi,xxxhdpi) and replace the splashscreen image for splash screen and ic_launcher and ic_launcher_round(round shape icon) for icon (name and extension of all images should be same )

IOS#

go into /RNBecrux/Images.xcassets/ and change the splashscreen and icon

How to Set the App Icon#

Click in the Project navigator and then choose AppIcon

Intro1 Slider Images#

replace that images for intro1 slider (name and extension of all images should be same )

Rate us#

Android#

For Rate Us button change the google package name in /screens/RateUs.js

IOS#

go to Wordpress site ReactEcommerce/General Settings and enter URL to iOS share app

RTL#

Android#

go into android/app/src/main/java/com/../MainActivity.java folder and change forceRTL() to true

IOS#

go into ios/RNBecrux/AppDelegate.m folder and change forceRTL() to YES

Facebook Integration#

Facebook Developer Console#

The first thing we need to do is to create a new application in Facebook’s developer dashboard, and this app is the one that Facebook will use to ask our users for their permission when we try to log them into our React Native application. For that, you’ll need to go to the Facebook developer console and create a new app.

Add your Platforms to Facebook#

Android#

Add Facebook App ID#

  • Add your Facebook App ID to your app and update your Android manifest.
  • Open your strings.xml file, for example:/app/src/main/res/values/strings.xml .
  • Add a new string with the name facebook_app_id containing the value of your Facebook App ID:
<string name="facebook_app_id">....</string>
  • Add your development and release key hashes To ensure the authenticity of the interactions between your app and Facebook, If your app has already been published, you should add your release key hash too. You'll have a unique development key hash for each Android development environment. To generate a development key hash, on Mac, run the following command:

- keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

- keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%.androiddebug.keystore | openssl sha1 -binary | openssl base64

This command will generate a 28-character key hash unique to your development environment. Copy and paste it into the field below. You will need to provide a development key hash for the development environment of each person who works on your app. If your app has already been published, you should also add a hash of your release key. Android apps must be digitally signed with a release key before you can upload them to the store. To generate a hash of your release key, run the following command on Mac or Windows substituting your release key alias and the path to your keystore:

- keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

This will generate a 28-character string that you should copy and paste into the field below. Also, see the Android documentation for signing your apps.

IOS:#

https://developers.facebook.com/quickstarts

Configure your info.plist and project settings#

Find the .plist file in the Supporting Files folder in your Xcode Project.

  1. Right-click your .plist file and choose "Open As Source Code".
  2. Copy & Paste the XML snippet into the body of your file
<dict>...</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>……</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>……</string>
<key>FacebookDisplayName</key>
<string>rn</string>

Google SignIn Integration#

Add your iOS and Android App inside Project settings (see image).

⦁ Enter required information and download the config file.

⦁ In firebase, you will need to enable Google option in SignIn Method section

While enabling Google, do copy the Web Client ID from there, we need this later on.

and pest WebClient id in

the file: src/common/Theme.style.js

Android#

When you are done registering your android app with firebase then Download the Config file and place it in the android/app

IOS#

Now, we need to get started on the Firebase configuration. In Firebase, we need to set up a Google cloud app. But when we set up the authentication method on Firebase this also creates a Google cloud app. First, we need to create a Firebase iOS app in order to obtain GoogleServiceinfo.list as shown in the screenshot below:

Next, we copy the GoogleService-info.list file to the Xcode project as shown in the screenshot below:

Now, we need to add the reversed client ID present in the GoogleService-info.list file to the URL Types, as shown in the screenshot below:

The next step is to go to Info → URL Types then fill the URL Schemes as shown in the screenshot below:

also, add Client_ID in URL Types same as shown in the screenshoot

https://github.com/react-native-google-signin/google-signin

Push Notification#

create A OneSignal Account

Your OneSignal App ID, available in Keys & IDs Put your ONESIGNAL APP ID here with your OneSignal google project number in your android/app/build.gradle folder.

ndroid { defaultConfig { manifestPlaceholders = [ onesignal_app_id: 'PUT YOUR ONESIGNAL APP ID HERE', // Project number pulled from dashboard, local value is ignored. onesignal_google_project_number: 'REMOTE' ]}}

Generate Credentials#

iOS - Generate an iOS Push Certificate ANDROID - Generate a Google Server API Key

Deep linking#

Configuring Android#

First, we need to open our Manifest file and add the app name we will want to be referencing, in our case Becruxapp. In android/app/src/main, open AndroidManifest.xml and change the android:host=” ” according to your link and you can also change android:scheme=” ”.

Configuring Ios#

Step 1. Add URL type to info.plist#

  1. Open plistand at the top of the file, create a new property called URL types

  2. Expand item 0(zero) and choose URL Schemes.

  3. Give item 0 or 1the name you would like your app to be linkable as. In our case, I chose tcshop.androidecommerce as the name.

Reference:#

https://medium.com/react-native-training/deep-linking-your-react-native-app-d87c39a1ad5e

Config Android#

How to config App name#

pen file android/app/src/main/res/values/strings.xml and change to your App name

Don’t forget clean cache after change app info.

cd ./android && ./gradlew clean

Publishing to Google Play Store#

https://facebook.github.io/react-native/docs/signed-apk-android

Publishing to Apple Store#

https://facebook.github.io/react-native/docs/running-on-device