This guide explains how to use "Inter-app communication and interaction with URL Schemes and Intents" and differences between iOS and Android devices.
What is Inter-app communication ?
In order to perform Inter-app communication, we use the Application.call method. You cannot only launch another application but also pass data to it.
First of all, you need to have two different workspace which are using different bundle identifiers. ( such as : io.smartface.app1 , io.smartface.app2 )
For application call, we will need two different applications with different applicationIDs.
We can use "io.smartface.appcall1" for the first application and "io.smartface.appcall2" for the second application.
2.1 First Example
Let's make a simple example which only launches an application from another one. iOS and Android have some differences for the usage of Application.call method.
For the first application that we are going to create, let's use the code block below :
And for the second application, add the following code block :
As you see in pictures above, when you press the “Call 2nd App” button in 1st application, it launches the second application and vice versa.
Tip: You need to create a tracker instance for iOS.
Let's make a simple example for iOS also, which launches another application. For iOS, it is a bit different to call an application.
First, open a new workspace, that will be the first application. Open project.json file under config folder. There is a field called URL Schemes.
Lets fill this with “schemeOfFirstApp” as seen in the picture below:
Now add the code block below :
For the second application, open a new workspace. After that, open project.json file under config folder. There is a field called URL Schemes.
Let's fill this with “schemeOfSecondApp” .
For the second application add the code block below :
Also add these two objects to the related page.
Now, let's see the result. We will have two different applications, with different bundle id’s, and they will call each other.
Press the button “Call 2nd application” in first application, it will launch the second one, and vice versa.
Now, let's see how can we send data between two different applications.
Again, we are going to create two different projects. For the first one, use the below code block :
For the second application, you need to use the code block below :
Add the above code inside app.js. This is used in order to get the sent data by first application;
As you see, from the first application, data is sent and as a result, when the second application launched, it alerts this data.
Now, let's make a similar example for iOS, which will be able to not only launch another application but also send data to it. Be careful about the URL Schemes field, you should always fill it for iOS application call, and call the app using this URL Schemes value. (For the first application fill this field with “schemeOfFirstApp” and for the second application fill this field with “schemeOfSecondApp”). For the first application, use the below code. It creates a dynamic textButton, and when it is pressed, calls the second application and sends data(123456).
For the second application use the code below :
And, add this code block below for the two applications(both for the first application and the second one ) :
Open the first application, press button “Call 2nd application”, as you see below, the second app will be launched and data is sent.
Now open the second application, press the button called “Call 1st application”. Aapp : "io.smartface.appcall2|io.smartface.appcall2.A"s you see, first application will launch and data will be sent.