Plugins
App Maker creates a mobile development environment with some dependencies that have proven stable. You may wish to add required modules or third-party services (Analytics, push notification, recommendations, etc.) to this environment. This is where plugins come into play. They allow you to add the modules you need to the environment and write integrations.
When installing native modules to the Environment, some modules are installed automatically. Some require more complex setup processes. For example, a module may require you to add some permissions to AndroidManifest.xml and Info.plist files during installation, or even to add a code block to your application's native files. In order to make complex installations like this, you need to write scripts where you can edit native files.
Plugins have two stages: installation and integration. During the installation stage, required actions are taken for the installation process. The integration phase includes the integration required for the installed module to work with the application's javascript. To develop a plugin with a template that includes these steps, continue reading the next section “Creating a plugin”.
Creating a Plugin
In order to install the environment in which you will develop the plugin, you need to run the following command in the main directory of the project.
appmaker plugin createPlugin names should be unique and adhere to the formatting akinon-react-native-camera.
Plugin Structure
After running the command appmaker plugin create, a plugin will be created, with the name you specified, in the .plugins directory in your project's main directory. This plugin should look like this.

Installation
In this directory, index.js exports the installation scripts and the npm dependencies that need to be installed as objects.
There should be installation scripts specific to these platforms in the android and ios directories.
android&ios / install.js should contain the installation processes needed by the npm package to be installed. For instance, when you wish to install the package Getting Started | VisionCamera, you should write scripts that will add the necessary permissions for android to AndroidManifest.xml.
The scripts written in the file android&ios / post-install.js run after the npm package is installed in the project. For instance, if you need to do something about the package installed in the ios/Pods directory, it should be done in this file.
You can run these scripts with the command appmaker plugin run ios.
Integration
In this directory, index.js should export a class. If this class has a function called init, this function will be run automatically at the start of the application. You can use the init function to subscribe to Framework services (Analytics, Deeplink).
akinon.plugin.js
This exports installation scripts.
config.json
The plugin may have client-specific configs (API_KEY, CLIENT_ID, etc). Such configs are defined in this file.
Using Plugin in Project
A plugin created with the command appmaker plugin create is automatically set up to be used in your project. The plugin you created in Akinon.json > plugins config should look like this.
name (string)
The name of the plugin is specified in this field. The value written in this field and the folder name of the plugin must be identical.
moduleName (string)
When you wish to use the plugin in a project, the name you need to import is specified in this field.
config (object)
This field is used to specify the project-specific configs required by the plugin.
Developing a Plugin
When you create the plugin with the command appmaker plugin create, the plugin is ready for development.
When developing the installation scripts of the plugin, you need to edit the files in the project using the Modifiers services. These modifiers may be inaccurate or incomplete during development. It would be costly to restore project files after configuring them incorrectly or incompletely. To avoid this, it is recommended to run the appmaker's command plugin preview while developing installation scripts.
You need to add the —post-install parameter to run the post-install scripts of the plugin.
This command shows the changes to be made by the installation scripts you have developed to the project files. It does not edit project files.
After making sure that the installation scripts are working correctly, you can now edit project files. In order to do this, you have to run the command plugin run.
This command writes the changes seem in the preview command to project files, and the project is ready to be built.
You may wish to develop a plugin without using the command appmaker plugin create. For instance, you may wish to include a plugin written for a different project. You need to clone the plugin you wish to include to the .plugins directory in the main directory of the project and run the command plugin add.
This command will edit akinon.json for you, enabling you to use the plugin in your project.
You may also wish to develop the plugin you use in a project. When you install a project with the command appmaker project install, the project is set up ready for build. However, you do not wish the plugin you will develop to be installed in the project. In this case, after installing the project, the plugin you wish to develop is cloned to the .plugins directory and this command is run in the project directory.
This command will re-configure the project without the plugin that is cloned under .plugins and defined in the plugins config in akinon.json and will install it ready for build.
After the development is finished, you can run the command plugin run.
Third Parties
Third-party plugins are a bit more complex than installing other react native plugins. You may also need to use features such as Analytics, and DeepLink for third-party plugins. For such features, Analytics and DeepLink services are available in the framework. You can complete the integration using these services. Check out Example Firebase for a sample case.
Modifiers
Modifying Xcode
You need to use XcodeModifier to edit the project with Xcode. See this document for detailed information.
You can try the following steps to make it easier to write scripts for Xcode.
Open a project with Xcode.
Make the related changes with Xcode and run the command appmaker project diff ios. This command will show the Xcode changes. You can write scripts based on these changes.
Run the command appmaker project reset ios to undo Xcode changes. This command will reset the ios changes.
Modifying Info.plist
You need to use PlistModifier to edit the Info.plist files. See this document for detailed information.
Modifying Podfile
You need to use PodModifier to edit the Podfile file. See this document for detailed information.
Modifying AppDelegate
You need to use AppDelegateModifier to edit the AppDelegate.h and AppDelegate.m files. See this document for detailed information.
Modifying AndroidManifest.xml
You need to use XMLModifier to edit AndroidManifest and other xml files. See this document for detailed information.
Modifying Gradle
You need to use GradleModifier to edit the Build.gradle file. See this document for detailed information.
Modifying MainApplication.java
You need to use JavaModifier to edit the MainApplication.java file. See this document for detailed information.
Modifying Other Files
You have to use FileModifier to change different file types. You can also use the features of this modifier in other defined Modifier services. Occasionally, the modifier you use may not fully meet your needs. In such cases, you can use custom Regex patterns with FileModifier methods.
As an example, you can refer to AppDelegateModifier's applyPatch method below.
Regex patterns may no be compatible with the plugins you’ve developed or the changes incoming with the new environment version.
Example React Native Camera
Let's assume we are developing a plugin for the react-native-camera dependency.
Installation
During installation, setup processes for third-party libraries are completed. This includes adding dependencies to package.json and modifying native files.
1. Create Plugin
Run the following command to create a new plugin:
You will be prompted to provide a name for the plugin. Enter the plugin name:
This command will generate a plugin under the directory: .plugins/akinon-react-native-vision-camera.
2. Install npm Package
npm packages should be added to the project's package.json file. To do this, define the names and versions of the required npm packages in the specified directory.
3. Android Installation
The akinon-plugin-adapters package simplifies the process with services like Modifiers and Paths. Refer to the documentation for more details.
Add the required permissions (android.permission.CAMERA and android.permission.RECORD_AUDIO) to the android/app/src/main/AndroidManifest.xml file:
Automate this modification with the following script:
4. iOS Installation
Add the permissions (NSCameraUsageDescription and NSMicrophoneUsageDescription) to ios/akinon/Info.plist:
Automate this modification with the following script:
Preview and Run Installation
Preview installation scripts without making changes to files:
Run the installation scripts:
Integration
After completing the installation phase, you need to write a JavaScript integration to utilize third-party libraries in your application.
Camera Component
The Camera component you want to use in the application should be developed in the integration layer.
First, create the index.js file under .plugins/akinon-react-native-vision-camera/integration/camera to utilize the react-native-vision-camera dependency:
Export and Use the Component:
To use the component you created within the src layer, you need to export it in the .plugins/akinon-react-native-vision-camera/integration/index.js file.
You can use the Camera component you created in the src layer at the desired location, as shown in the example below:
Example Firebase
Let’s say we ‘re developing a plugin for Firebase.
Installation
During the installation phase, the setup processes of the third party are completed. These processes include, among others, adding dependency to package.json and modifying native files.
Create Plugin
Plugin name will be asked after running this command. Name of the plugin should be entered.
Running this command will create a plugin in the project’s .plugins/akinon-react-native-firebase directory.
Install npm Package
@react-native-firebase/app
@react-native-firebase/analytics
@react-native-firebase/messaging
The npm packages must be added to the project's package.json file. In order to do this, the name and versions of npm packages are defined in the specified directory.
Android Installation
You need to download google-services.json file from Firebase console and place it in /android/app/google-services.json directory.
In Akinon.json, you can write the path of the google-service file in the plugin config. (You can also write to a field other than Akinon.json.)
Using the config in Akinon.json, you can write the script to move the google-services.json file to the android/app directory.
While developing plugins, the akinon-plugin-adapters package simplifies the process with services such as Modifiers, Paths. See this document for more detailed information about these services.
In the file android/build.gradle, you need to add classpath 'com.google.gms:google-services:4.3.13' service as dependency under buildscript.
For this:
To the file android/app/build.gradle, you need to add the code apply plugin: 'com.google.gms.google-services' that will enable you to use Google services.
For this:
We need to add code to update the value of the com.google.firebase.messaging.default_notification_color meta data in the android/app/src/main/AndroidManifest.xml file.
For this:
iOS Installation
You need to download GoogleService-Info.plist from Firebase console and put it in /ios/akinon/ directory
In Akinon.json, you can write the path of the google-service file in the plugin config.
You can write the script that will move the GoogleService-Info.plist file to the ios/akinon directory by using the config in Akinon.json; however, this will not be enough. When you add a file to the project or change a config with Xcode, changes are made by xcode in the ios/akinon.xcodeproj/project.pbxproj file. You have to make these changes with scripts.
After adding the GoogleService-Info.plist file, you need to edit the AppDelegate.m file and initialize Firebase. The code block you want to add is as follows:
In order to make these changes in the AppDelegate.m file, you need to write a script as shown below.
You need to edit the Info.plist file and specify the services that will run in the background. The code block you want to add is as follows:
To make these changes in the Info.plist file, you need to write a script as shown below.
After editing the Info.plist, you need to edit the akinon.entitlements file and configure the environment for Push notifications. The code block you want to add is as follows:
To make these changes in the akinon.entitlements file, you need to write a script as shown below.
In order to run the installation scripts:
This command is run in the project directory and Firebase installation is completed.
Integration
After the installation phase is finalized, you need to write javascript integration to use the third party in the application.
Analytics
Let’s say we’re writing this integration for Firebase Analytics.
Analytics | React Native Firebase
Subscribe your analytics integration to Framework’s AnalyticsService.
The init function runs before the application is rendered. This function is useful in cases such as subscribe operations and third party sdk initialize.
Initially, the init function of the integration runs when the Analytics service is ready. This function enables analytics-specific initialization operations. The remove function works when the Analytics service is unmounted from the application.
If you wish to send an event to firebase when you view a product:
When the Product Detail page is opened, the integrated productImpression function will run automatically. You can find all the data about the product in the nextState parameter. Click to access Analytics functions.
Deep Link
Subscribe your deeplink integration to Framework’s DeepLinkService.
Initially, the init function of the integration runs when the DeepLink service is ready. This function enables deeplink-specific initialization operations. The remove function works when the DeepLink service is unmounted from the application.
Let's say we’re sending a push notification to the application using Firebase messaging. With push notification, you may wish to direct users to pages such as product list and product detail. In order to do this, you can access the push notification payload by using Firebase messaging's listeners in the init function. Through the publishNotificationOpen method of DeepLinkService, you can redirect to the relevant page when the notification is opened.
Analytics Events
When you create a method with the following events for the analytics service you have developed, the created method will be triggered when the action type associated with the event is ignited.
User
FETCH_CURRENT_USER_FULFILLED_FOR_LOGIN
userLogin
CLEAR_AUTH_STATE
userLogout
FETCH_CURRENT_USER_FULFILLED_FOR_INDEX
currentUser
Basket
FETCH_BASKET_FULFILLED
basketImpression
FETCH_BASKET_FULFILLED_TO_UPDATE
cartChanges
FETCH_BASKET_DISCOUNT
couponUsed
BASKET_ADD_TO_FAVOURITE_FULFILLED
addToFavOnBasket
ADDED_TO_CART_FULFILLED
addedToCart
Orders
CANCELLATION_REQUEST
cancelOrder
Product Detail
PD_ADD_TO_FAVOURITE_FULFILLED
addToFavOnPd
PD_REMOVE_FROM_FAVOURITE_FULFILLED
removeFromFavOnPd
FETCH_PRODUCT_DETAIL_FULFILLED
productImpression
Product List
PL_ADD_TO_FAVOURITE_FULFILLED
addToFavOnPd
FETCH_PRODUCT_LIST_FULFILLED
productsImpressions
PL_REMOVE_FROM_FAVOURITE_FULFILLED
removeFromFavOnPl
SET_SORTER
setSorter
Register
REGISTER_COMPLETED
userRegister
Search
FETCH_SEARCH_FULFILLED
searched
Checkout Success
WEB_CHECKOUT_OPENED
checkoutImpression
FETCH_CHECKOUT_COMPLETED_SUCCESS
measuringPurchases, measuringFirstPurchase, addShippingInfo, addPaymentInfo
FIRST_PURCHASE_ORDERED
firstPurchaseOrdered
Last updated
Was this helpful?

