Message Port
Tizen Web applications can communicate with other Web or native applications. The message data type for the communication is map data, which consists of a string key and value pair.
The Message Port API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. All mandatory APIs are supported on the Tizen Emulators.
You can send and receive messages through 2 types of message ports:
- The LocalMessagePort interface (in mobile and wearable applications) is used to register your message port and prepare to receive messages from other applications.
To receive messages from other applications, you must register a callback function to the local message port.
- The RemoteMessagePort interface (in mobile and wearable applications) is used to send messages to other applications.
The local message port information can be sent to another application for bi-directional communication.
You can retrieve the instances of the LocalMessagePort and RemoteMessagePort interfaces with the requestLocalMessagePort() and requestRemoteMessagePort() methods of the tizen.messageport object.
A message port supports sending and receiving methods:
- A Tizen Web application can send messages to another application using the sendMessage() method of the RemoteMessagePort interface.
To receive response messages from the other application, your application can specify a local message port when it sends the message. You can receive response messages using the callback method which is registered through the addMessagePortListener() method of the LocalMessagePort interface.
- The application that wants to receive messages from your application can mostly be implemented as a Tizen Web or native application. To implement it as a native application, see the mobile native Message Port Communication guide.
Figure: Message port communication
You can communicate only with a trusted application that is signed with the same certificate as your application, using the instances of the LocalMessagePort and RemoteMessagePort interfaces that are retrieved by the requestTrustedLocalMessagePort() and requestTrustedRemoteMessagePort() methods of the tizen.messageport object.
Figure: Trusted message ports