This article will guide you to build your Android app with Premium Mobile Code. The article contains the following parts:

Now, let's start!

The Premium Mobile Code is ONLY available on phpFox ULTIMATE license. In case you are holding other license types, please upgrade to phpFox ULTIMATE license first.

In this article, we assume that you already got the following knowledge:

  • How to use Android Studio to set up and build an Android app
  • How to create necessary Google certifications to build an Android app
  • How to configure a Firebase project for push notification on an Android app.

Prerequisite

MUST enroll a Google Play Developer account at https://console.developers.google.com

Set up Tools and Environment

Install Android Studio

Install Nodejs & Dependencies

If you are using Mobile code version 1.4 or newer, you no longer need to install Nodejs & Dependencies. This step can be bypassed.

# support eslint 
npm install -g @babel/core@^7 @babel/cli@^7 eslint eslint-plugin-jest babel-eslint eslint-config-airbnb eslint-config-google eslint-plugin-flow-vars \
 eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-node eslint-plugin-promise eslint-plugin-react \
 eslint-plugin-standard eslint-plugin-mocha eslint-plugin-jasmine babel-plugin-react-intl babel-plugin-transform-remove-console \
 yarn react-native-cli create-react-native-app

Setup Mobile Code

Install Project Dependencies

If you are using Mobile code version 1.4 or newer, you no longer need to install Project Dependencies. This step can be bypassed.

Run the following command to install necessary dependencies on the project

#install dependencies
 
cd MobileProject/
yarn install

Configure your Android app

Configure Push Notification with Firebase

Visit Google Firebase platform (https://console.firebase.google.com/), create a project (You can use one Firebase project for both iOS and Android apps)

Update configuration.json under folder MobileProject/android/app/

Default file configuration.json will be as below:

{
  "appName": "YourAppName",
  "bundleId": "com.yourcompany.phpfoxmobile",
  "serverUrl": "https://yourphpfoxwebsite.com",
  "clientId": "CLIENT_ID",
  "clientSecret": "CLIENT_SECRET",
  "versionName": "x.x",
  "versionBuildNumber": x,
  "facebookAppId": "xxx",
  "googlePlacesClientId": "GOOGLE_PLACES_CLIENT_ID",
  "stringKeyCodePush": "",
  "react-native-google-mobile-ads": {
    "android_app_id": "GOOGLE_ADMOB_APP_ID",
    "delay_app_measurement_init": false,
    "optimize_initialization": true,
    "optimize_ad_loading": true
  },
  "pingServerUrl": "",
  "firebaseEnabledAnalytic": true,
  "theme": {
    "splashScreenBackgroundColor": "#COLOR",
    "primaryColor": "#COLOR",
    "grayBaseColor": "#111",
    "welcomeText": {
      "fontSize": 24,
      "color": "#FFF",
      "fontWeight": 400
    },
    "welcomeImage": {
      "height": 48,
      "resizeMode": "contain"
    }
  },
  "enableAssociatedDomains": true,
  "associatedDomains": [
    "yourphpfoxwebsite.com",
    "www.yourphpfoxwebsite.com"
  ],
  "enableLiveStream": false, 
  "enableRocketChat": true,
  "enableInAppPurchase": false,
  "enableAdmob": false,
  "enableAudio": false,
  "enableLog": false,
  "privateInfo": {
    "storeFile": "yourcompany.keystore",
    "storePassword": "xxxxxxxxxx",
    "keyAlias": "yourcompany",
    "keyPassword": "xxxxxxxxxx"
  }
}


Here is our detailed explanation for items in this file

appName

This is the app name displayed under the app logo on Android devices after installation. Ex: phpFox

bundleId

Bundle ID of your Android that you registered in Google Play Store Developer. Ex: com.yourcompany.phpfoxmobile or com.phpfox.phpfoxmobile

serverUrl

The URL of your phpFox website. Ex: https://mobileapi.phpfox.com

clientId and ClientSecret

Get these values in AdminCP > Apps > Installed > Restful API app ( /admincp/app/?id=phpFox_RESTful_API )

facebookAppId

Get value in AdminCP > Apps > Installed > Facebook Login app ( /admincp/setting/edit/?module-id=PHPfox_Facebook )

googlePlacesClientId

Follow instructions at https://developers.google.com/places/android-sdk/start to get this key for Android app.

android_app_id

Follow instructions at https://developers.google.com/admob/android/quick-start to get this key for Android app.

firebaseEnabledAnalytic

true OR false. If true, enable Firebase analytic. For further information take a look at Google Analytics for Firebase

versionName and versionBuildNumber

These two values control the versioning of your Android app in Google Play.

primaryColor and splashScreenBackgroundColor

The primary color (in Hex color code, Ex: #2681D5) of your app. This color is applied to links, like button, navigation title, etc.

grayBaseColor

This color code is used for generating appropriate text color.

privateInfo

These items will be used when distributing Android app to Google Play. They can be generated within Android Studio.

Run Nodejs

If you are using Mobile code version 1.4 or newer, you no longer need to run Nodejs. This step can be bypassed.

node ./server.js

Run your Android app in Android Studio

When opening, you may receive some notice messages about missing libraries of Android Studio with instructions to install them. You can follow instructions to install missing libraries.