Installation
This chapter covers Ionic Source Code Setup, Plugin Installation, Facebook Login, Facebook Integration, One Signal Notification, OneSignal Integration and AdMob Integration.
Ionic Source Code Setup#
Ionic Source Code Setup
For install ionic environment use this link
https://ionicframework.com/docs/intro/cli
Now we have set up the ionic environment. We need to connect our app with woocommerce website. Open the folder name (App Source Code) inside the downloaded packages.
Inside the folder, you will find all the ionic application code.
Now open project folder/src/providers/config.service.ts file and change the following.
- https://your-site.com (it will be the URL of your domain)
- consumer key
- consumer secret
It will load woocommerce products data into your application

Test Application
Now you can test the application in your ionic development environment.
Plugin Installation#
We have added JSON API and ionic eCommerce plugins. These plugins can be installed in two ways.
You will find the JSON API and ionic eCommerce plugins in a zipped folder in the pack.
1stMethod
- Upload the folder “JSON-API” to your WordPress Plugin folder (/wp-content/plugins)
- Now activate the plugin through the “plugins” menu in WordPress or by using the link provided by the plugin installer.
- Activate the controller through the JSON API menu found in the WordPress Admin Center (Settings->JSON API)
2ndMethod
Go straight to the admin panel>Plugin>Add New.

The above-given page will show up. From here, click on the “upload plugin” option, make sure that the plugin that you have is in .zip format. Click on the “Browse” option, upload the plugin folder and once the folder is chosen, click on the “Install Now” option”.
Once the plugin is installed, you can activate or deactivate the plugin through settings according to your usage.
After WordPress plugins installation and setup, please follow the below-mentioned instructions to set up your mobile application.
After Intallation of plugin need to activate the controllers from Settings >> Json APi

Ionic Woocommerce app works with woocommerce rest api, please follow the link below to enable woocommerce rest api on your server.
https://docs.woocommerce.com/document/woocommerce-rest-api/
After enable rest api, please make sure your site woocommerce rest api working correctly. You can follow that simple tutorial link to check whether rest api works correctly on your sever or not.
https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API
Now you have all set at your wordpress site end. Please proceed with ionic source code setup.
Enable REST API & Generate API keys
To enable the REST API with in WooCommerce, go to WooCommerce> Settings> Advanced and tick the Enable Legacy API link .
The WooCommerce REST API works on a key system to control access. These keys are linked to WordPress users on your website.
To create or manage keys for specific WordPress user:
Go to: WooCommerce> Settings> Advanced> REST API
- Select Add Key
- Select the user you would like to generate a key for, in the user file and add a description. 3)Choose the desired level of access for this API key , which can be Read access, Write access or Read/Write access. 4)Select the Generate APIkey button and WooCommwrce will generate API keys for that certain user.
Once the keys have been generated, you will see two new keys, a QRCode and a Revoke API Key button. These two keys are your Consumer Key and Consumer Secret.
- Place your site link, consumer key and consumer secret in the mobile application config file that uses the WooCommerce API.
Facebook Login#

This allows you to log in through your Facebook credentials. Here is the official link with the detailed demonstration of Facebook integration https://ionicframework.com/docs/native/facebook/.
Facebook Integration#
Note:
Add plugin using below code using your app id and app name
Important:
ionic cordova plugin add cordova-plugin-facebook4 –variable APP_ID=“yourAppId” –variable APP_NAME=“yourAppName”
You have to enable it From CMS. For more details please visit https://ionicframework.com/docs/native/facebook/
One Signal Notification#

To avail of this feature, you need to create OneSignal account and obtain both needed keys that are App ID and App key. Place them here and make this feature functional. You can offer various discount coupons to your distinguished customers that would appear in their app like this

Here is the official link that would guide you throughout the process of OneSignal account creation https://ionicframework.com/docs/native/onesignal
OneSignal Integration#
Android#
Generate a Google Server API Key#
Your Google Server API Key and Google Project Number are used to send push notifications to ANDROID devices.
To begin, we'll obtain a Google Server API Key and Google Project Number. These keys allow OneSignal to use Google's web push services for your notifications.
Create A Firebase Project#
- Visit the Firebase Console and sign in with your Google account.

Press "CREATE NEW PROJECT" or select an existing one below

Enter a project name and press "CREATE PROJECT".

Firebase Cloud Messaging Token and Sender Id#
Getting your Firebase Cloud Messaging token and Sender ID
- Click the Gear icon in the top left and select "Project settings".
- Select the "CLOUD MESSAGING" tab.
- Save the two values listed:
- You'll need your Server key, also known as the Google Server API key.
- You'll need your Sender ID, also known as the Google Project Number, later as well

OneSignal App Android Setting#
Configure your OneSignal app's Android platform settings
- Go to Settings and press the Configure button to the right of Google Android.

Paste your Google Server API Key and Google Project Number in here and press Save.

After saving this server API Key and Sender ID from the firebase project, you can get the one signal app Id from the settings

and your sender id from the firebase project

place this app id and sender id in config.ts (src/providers/configProviders/config.ts) file then save it.

IOS#
Generate an IOS Push Certificate#
Required for all IOS apps.
Required For Setup#
- A OneSignal Account, if you do not already have one.
- Your OneSignal App Auth Key, available in Keys & IDs.
- A Mac with Xcode 8+. If you are using Xcode 7, PhoneGap Build, or Cordova, follow this guide instead.
Provisioning#
Option A: Create Certificate Request Manually#
We recently released a tool to automate this process!
Make sure your role for the team is Admin inside your Apple Developer account > Membership section. Otherwise you will not be able to use this tool.
Simply follow the directions on OneSignal's Provisionator Tool then continue to Step 4.
OR#
Option B: Create Certificate Request Manually#
- Open Keychain Access on your Mac OS X system. It may be located in "Applications" > "Utilities" > "KeychainAccess"
- Select "KeychainAccess" > "CertificateAssistant" > "RequestaCertificateFroma CertificateAuthority...".

Select the "Save to disk" option and enter your information in the required fields. This creates a certification request file that will be used

Enable Push Notification#
To enable Push Notifications and apply the Certification Request to generate Certificate.
- Select your app from the Apple's Developer site and press "Edit".

Scroll down to the bottom and enable Push Notifications. Press Done, but do not configure either Production or Development certificate.
Instead, go to Add iOS Certificate and select "Apple Push Notification service SSL (Sandbox & Production)" and click Continue.
This certificate will be applicable to both Sandbox and Production environments, so you do not need a separate key for each.

- Choose an App ID from the App ID pop-up menu.
- Press "Continue".
- Press "Choose File...” select the "certSigningRequest" file you saved in step 1, press "open", and then press "Generate"..

Press "Download" to save your certificate.

Creating A Private Key#
- Open the .cer file you downloaded in the last step by double clicking on it in Finder.

After a few seconds the "KeychainAccess" program should pop up. Select Login > My Certificates, then right click on your key in the list and select "Export".

- Give the file a unique name using the .p12 extension, and press save. You will have an option to protect the file with a password. If you add a password, you need to enter this same password on OneSignal.
Upload Your Push#
Upload Your Push Certificate to OneSignal.
If you haven't already, you should set up your OneSignal account.
- Select your app from the All Apps page in OneSignal, then go to "App Settings" and press "Configure" to the right of the Apple iOS Settings.

Select the .p12 you exported along with a password that you added, and press Save.

AdMob Integration#
Find your app IDs & ad unit IDs#
An app ID is a unique ID number assigned to your apps when they're added to AdMob. The app ID is used to identify your apps.
An ad unit ID is a unique ID number assigned to each of your ad units when they're created in AdMob. The ad unit ID is added to your app's code and used to identify ad requests from the ad unit.
Note:
During the final step of ad unit creation, you'll need to copy and paste the app ID and any ad unit ID(s) into your app's code. For more information on implementation, review the Google Developers Get Started guide (Android, iOS) for the appropriate ad format(s): banner, interstitial, rewarded video, native.
Find an app ID#
- Sign in to your AdMob account at https://apps.admob.com.
- Click Apps in the sidebar.
- Click View all apps.
- Click the Copy icon in the App ID column to copy the ID of an app.
Find an ad unit ID#
- Sign in to your AdMob account at https://apps.admob.com.
- Click Apps in the sidebar.
- Click the name of the app associated with the ad unit. Note: If you don't see it in the list of recent apps, click All apps. Then, click the name of the app.
- Click Ad units in the sidebar.
- Click the Copy icon in the Ad unit ID column to copy the ID of an ad unit.
Now update the src/providers/configProvider/config.ts file . Add your ios and android ids below and then also change the value of admob =1 for android ads and admobIos = 1 to enable the ios ads.#
