This tutorial is a simple and quick guide for developers that want to add behavior to their smart devices applications.
In order to add behavior, GeneXus defined the concept of Actions. By adding Actions to your Smart Device application you’ll be able to call procedures, web pages, etc. The Actions can interact with the device through External Objects for Smart Devices. Specifically, we are going to send a message to a client using Interop external object.
Let’s continue with our KB that we developed in My first iOS application.
Before starting we should see which actions for Smart Devices are provided.
On KB Explorer, under References, you’ll see a section module called SD. There you’ll see the external objects GeneXus offers to interact with the device.
In this document, we are going to focus on the Interop external object.
This object has a method called Send Message for sending general messages through those apps which allow it. It has two parameters that can be set.
The content of the message.
The receiver of the general message (e.g. by its phone number, email, facebook account, twitter username etc.).
The method will display every application installed in the end user's device for sending the message, without pay attention to the semantic of To parameter (phone, email, etc.). The end-user should select which app should resolve its request; otherwise, the To parameter will be ignored. For instance, if To parameter is set as under Phone domain, and the end user tries to send the message by email, only Message parameter will be used.
Add the Action to our application.
Go to the Work With for Smart Devices object associated with Customer Transaction object (called WorkWithDevicesCustomer). On the Section General, add an Action as follows.
Add behavior to the action. Go to Event tab, and call Interop.SendMessage method as follows.
Then, this action will try to send a message with no content to a specific customer (in this case, by its phone number). If the end-user selects the SMS messaging app, will open it directly to send the message to the target user. But, if the end-user selects Email app, only will open the application for sending an email --- since message's content is empty and phone number is discarded. If your aim is only to send SMS, use SendSMS method.
For example, in runtime, we'll have the following behavior.