# Pushwoosh Outsystems plugin client actions

The Plugin provides a set of client actions to facilitate push notification management. These actions allow you to register and unregister devices, set and get tags, manage inbox messages, and more. 

## Pushwoosh plugin client actions 

### CheckPushwooshPlugin

Validates if the Pushwoosh plugin is currently available.

#### Output parameters

| IsAvailable | Returns true if the plugin is available to use, false otherwise                                                                                                  |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error       | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

#### Usage example 

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-1.webp" alt="CheckPushwooshPlugin action"/>

### RegisterDevice

Registers a device for push notifications and retrieves a Push Token.

#### Input parameters

| ApplicationCode | Text, the Pushwoosh application code obtained from your account settings. |
| --------------- | ------------------------------------------------------------------------- |



#### Output parameters

| RegisterToken | Token received from Google or Apple for the device                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success       | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| Error         | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### UnregisterDevice

Unregisters a device from receiving push notifications.

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### GetDeviceID

Retrieves the device ID, which should be a unique identifier.

#### Output parameters

| DeviceHwid | The unique identifier of the device.                                                                                                          |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Error      | An error containing the error code and error message with details about any error that might have occurred. Only set when there was an error. |

### GetDeviceType

Gets the Device Type (Android, iOS, or Windows).

#### Output parameters

| DeviceTypeId | The identifier of this device type. |
| ------------ | ----------------------------------- |

### GetTags

Fetches tags data from Pushwoosh.

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |
| Tags    | Returns Key, Value Record List containing all tags assigned to this device.                                                                                      |

#### Usage example

1. Invoke the **GetTags** action to fetch the tags data from Pushwoosh.
2. The returned tags are accessible via the **GetTags.Tags** list.

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-2.webp" alt=""/>

3. Use the **LogMessage** action to log each tag's key and value.

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-3.webp" alt=""/>

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-4.webp" alt=""/>

### PostEvent

Sends a message to Pushwoosh when a particular event in your application happens.

#### Input parameters

| EventName       | Text, name of the event                                                                                                                                                    |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| EventAttributes | Key, Value Record List, used to send additional event data to Pushwoosh (i.e. for the "UserLogin" action you might want to send login data, such as - `{"username":"John"}`) |

Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

#### Usage example

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-5.webp" alt=""/>

**1. Assign**

Set up key-value pairs to define the data for the event. For instance, KeyValue1.AttributeName as "test1" and KeyValue1.Value as "test1value". Similarly, define KeyValue2 with the appropriate attribute name and value.

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-6.webp" alt=""/>

2\. Create lists of attributes to be associated with the event. 

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-7.webp" alt=""/>

3. Finally, configure the **PostEvent** action.

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-8.webp" alt=""/>

### SetBadgeNumber

Sets the application icon badge number.

#### Input parameters

| BadgeNumber | Integer, Icon badge number. |
| ----------- | --------------------------- |

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### SetLanguage

Sets custom application language instead of the default system language.

#### Input parameters

| Language | Text, Custom application language in 2-letter ISO format (e.g., "en", "es", "fr") |
| -------- | --------------------------------------------------------------------------------- |

### SetTags

Sends tags and their values to Pushwoosh.

#### Input parameters

| Tags | TagName, TagValue Record List containing all tags you want to send. TagName type should always be Text, while TagValue can be Text, Integer, Boolean, Date, etc. |
| ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

#### Usage example

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-9.webp" alt=""/>

1. Assign tag values. In the example below, there are two tags:

* Tag1 with a name testTag and its value set to the current date.
* Tag2 with a name testTag2 and its value set to True.

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-10.webp" alt=""/>

2\. Then, append tags to a list. In this example: 

* ListAppend3 adds Tag1 to the LocalTag list.
* ListAppend4 adds Tag2 to the LocalTag list.

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-11.webp" alt=""/>

3\. After populating the list with the necessary tags, use the **SetTags** client action to send this list to Pushwoosh. 

<img src="/outsystems-pushwoosh-outsystems-plugin-client-actions-12.webp" alt=""/>

### SetUserId

Assigns a custom User ID to this device.

#### Input parameters

| UserID | Text, custom User ID. |
| ------ | --------------------- |

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

## Pushwoosh Inbox Client Actions

The process of working with Inbox is the following: 

1. Load a list of InboxMessage objects.
2. Use these objects to render the inbox view.
3. Perform the actions listed below, or delete these objects using the actions described below.

| code              | Text                   | Unique ID of an inbox notification.                                                                                                                                                                                                                                                                                               |
| ----------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| title             | Text                   | Notification title.                                                                                                                                                                                                                                                                                                               |
| message           | Text                   | Notification message.                                                                                                                                                                                                                                                                                                             |
| imageUrl          | Text                   | URL of a custom image attached to a notification.                                                                                                                                                                                                                                                                                 |
| sendDate          | <p>Date</p><p>Time</p> | Represents the time when a notification was sent.                                                                                                                                                                                                                                                                                 |
| type              | Integer                | <p>Type of notification.</p><p> Possible values:</p><ul><li>0 - regular notification</li><li>1 - rich media notification</li><li>2 - URL notification</li><li>3 - deep link notification</li></ul>                                                                                                                                |
| bannerUrl         | Text                   | Contains URL of an Android banner.                                                                                                                                                                                                                                                                                                |
| customData        | Key, Value Record List | Contains a list of parameters passed as custom data.                                                                                                                                                                                                                                                                              |
| isRead            | Boolean                | True if inbox notification is read.                                                                                                                                                                                                                                                                                               |
| isActionPerformed | Boolean                | <ul><li><strong>True</strong> if notification action is performed. </li><li>For regular notifications, <strong>true</strong> if a notification is read. </li><li>For Rich Media, <strong>true</strong> if rich media was presented. </li><li>For URL and deep links, <strong>true</strong> if URL/deep link was opened.</li></ul> |

### LoadMessages

Fetches inbox notifications from Pushwoosh.

#### Output parameters

| InboxMessages | InboxMessage List, list of all inbox messages.                                                                                                                   |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success       | Returns **true** if everything goes as expected, **false** if there is an error.                                                                                 |
| Error         | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### ReadMessage

Marks the inbox message as read.

#### Input parameters

| MessageCode | Text, code of an InboxMessage (received as a parameter of an InboxMessage in LoadMessages) |
| ----------- | ------------------------------------------------------------------------------------------ |

#### Output parameters

| Success | True if everything goes as expected, false if there is an error.                                                                                                 |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### PerformAction

Performs action for specified inbox messages (e.g., open URL in a browser).

#### Input parameters

| MessageCode | Text, code of an InboxMessage (received as a parameter of an InboxMessage in LoadMessages) |
| ----------- | ------------------------------------------------------------------------------------------ |

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### DeleteMessage

Removes a message from inbox.

#### Input parameters

| MessageCode | Text, code of an InboxMessage (received as a parameter of an InboxMessage in LoadMessages) |
| ----------- | ------------------------------------------------------------------------------------------ |

#### Output parameters

| Success | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Error   | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### TotalMessagesCount

Returns the total number of inbox messages.

#### Output parameters

| MessagesCount | Integer, total number of inbox messages.                                                                                                                         |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success       | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| Error         | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### UnreadMessagesCount

Returns the number of unread inbox messages.

#### Output parameters

| UnreadMessagesCount | Integer, number of unread inbox messages.                                                                                                                        |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success             | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| Error               | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |

### MessagesWithNoActionPerformedCount

Returns the number of inbox messages with no action performed.

#### Output parameters

| MessagesWithNoActionPerformedCount | Integer, number of inbox messages with no action performed.                                                                                                      |
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success                            | Returns true if everything goes as expected, false if there is an error.                                                                                         |
| Error                              | An error containing the error code and error message with details about any error that might have occurred. Only set when the Success output parameter is false. |