Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:3500:0800 [2023/04/05 06:08] – [Creating a contact on the phone] sean | docs:3500:0800 [2025/06/12 02:36] (current) – Rename to AwareIM aware_support3 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Writing client-side plugins ====== | ====== Writing client-side plugins ====== | ||
| - | In //**Aware IM**// you can not only add plugins for the server (such as custom processes, channels or functions), but you can also add plugins that execute on the client within a web browser. Most of the time you would write these plugins in order to add your custom user interface functionality, | + | In //**AwareIM**// you can not only add plugins for the server (such as custom processes, channels or functions), but you can also add plugins that execute on the client within a web browser. Most of the time you would write these plugins in order to add your custom user interface functionality, |
| All client-side plugins must be written in Javascript and in most cases you need the knowledge of the [[http:// | All client-side plugins must be written in Javascript and in most cases you need the knowledge of the [[http:// | ||
| - | There are several types of the client-side plugins you can add in //**Aware IM**//: | + | There are several types of the client-side plugins you can add in //**AwareIM**//: |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| We will look at each of these client-side plugins separately | We will look at each of these client-side plugins separately | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ==== Send email to the selected contact ==== | ||
| - | |||
| - | We need to use the pickContact method of the navigator.contacts object to display a list of contacts, let the user pick one and then we need to start a process in the application to send an email to the email address of the contact picked by the user. | ||
| - | |||
| - | The email address returned by the plugin needs to be saved in some temporary object and then this object can be used in the process. So we will create a temporary business object (persistence type – memory) called ContactParam with the single EmailAddress attribute. We will then create a process called SendEmailToContact with the ContactParam object as its input. The process will then use the SEND action to send any email to this email address (the email can use tag expressions to retrieve some information from the system – for example, from SystemSettings or from the logged in user). | ||
| - | |||
| - | To start a process we will use the AwareApp.startProcessWithInit function. It has the following signature: | ||
| - | |||
| - | startProcessWithInit: | ||
| - | |||
| - | Here procName is the name of the process to start, renderOption is where to display the results of the process (we can use null), objName is the name of the parameter object, initValues is the object storing values of the parameter object and context contains additional parameter objects (null in our case) | ||
| - | |||
| - | So our Javascript can look like this: | ||
| - | |||
| - | navigator.contacts.pickContact (function (contact) | ||
| - | |||
| - | { | ||
| - | |||
| - | var email = contact.emals[0].value; | ||
| - | |||
| - | | ||
| - | |||
| - | | ||
| - | |||
| - | | ||
| - | |||
| - | | ||
| - | |||
| - | { “EmailAddress” : email } | ||
| - | |||
| - | }, | ||
| - | |||
| - | function (error { console.log (error); } | ||
| - | |||
| - | ); | ||
| - | |||
| - | Then we just need to add a command of the “Execute Script” type to the mobile menu of the application. | ||
| - | |||
| {{simplenavi> | {{simplenavi> | ||