Module

# XojoCloud.RemoteNotifications

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Allows the sending of remote notifications to iOS devices via a Xojo web application running on Xojo Cloud.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                         | Parameters                                                                                                                                                                                                                                                                                                                                                                                        | Returns                          | Shared |
|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|--------|
| `SendAppleNotification<xojocloud.remotenotifications.sendapplenotification>` | message As `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`                                                                                                               |                                  |        |
|                                                                              | message As `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`, callback As `XojoCloud.RemoteNotifications.CallbackDelegate<xojocloud.remotenotifications.callbackdelegate>` | `String</api/data_types/string>` |        |
|                                                                              | message As `JSONItem</api/text/json/jsonitem>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`                                                                                                                                                                         |                                  |        |
|                                                                              | message As `JSONItem</api/text/json/jsonitem>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`, callback As `XojoCloud.RemoteNotifications.CallbackDelegate<xojocloud.remotenotifications.callbackdelegate>`                                                           | `String</api/data_types/string>` |        |

## Delegate Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                               | Parameters                                                                                              | Returns |
|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|---------|
| `CallbackDelegate<xojocloud.remotenotifications.callbackdelegate>` | UUID As `String</api/data_types/string>`, error As `RuntimeException</api/exceptions/runtimeexception>` |         |

## Method descriptions

<div id="xojocloud.remotenotifications.sendapplenotification">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XojoCloud.RemoteNotifications.SendAppleNotification

**SendAppleNotification**(message As `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`)

> Sends the message to Apple's Remote Notification Service for delivery to the device specified based upon the delivery options passed and returns the UUID for the notification.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

XojoCloud.RemoteNotifications.SendAppleNotification

**SendAppleNotification**(message As `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`, callback As `XojoCloud.RemoteNotifications.CallbackDelegate<xojocloud.remotenotifications.callbackdelegate>`) As `String</api/data_types/string>`

> Sends the message to Apple's Remote Notification Service for delivery to the device specified based upon the delivery options passed and returns the UUID for the notification.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

XojoCloud.RemoteNotifications.SendAppleNotification

**SendAppleNotification**(message As `JSONItem</api/text/json/jsonitem>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`)

> Sends the message to Apple's Remote Notification Service for delivery to the device specified based upon the delivery options passed and returns the UUID for the notification.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

XojoCloud.RemoteNotifications.SendAppleNotification

**SendAppleNotification**(message As `JSONItem</api/text/json/jsonitem>`, options As `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>`, deviceToken As `String</api/data_types/string>`, callback As `XojoCloud.RemoteNotifications.CallbackDelegate<xojocloud.remotenotifications.callbackdelegate>`) As `String</api/data_types/string>`

> Sends the message to Apple's Remote Notification Service for delivery to the device specified based upon the delivery options passed and returns the UUID for the notification.
>
> If you call this method as a function, you must pass in as the callback parameter (the last parameter of the method) a pointer to a method with the following signature: CallbackDelegate(UUID as String, error as RuntimeException)
>
> If an error occurs, the delegate method will be called and passed the UUID and a `RuntimeException</api/exceptions/runtimeexception>` containing the error information of the notification in which the error occurred.

## Delegate descriptions

<div id="xojocloud.remotenotifications.callbackdelegate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XojoCloud.RemoteNotifications.CallbackDelegate

**CallbackDelegate**(UUID As `String</api/data_types/string>`, error As `RuntimeException</api/exceptions/runtimeexception>`)

> The address of a method with this signature can be passed to `SendAppleNotification<xojocloud.remotenotifications.sendapplenotification>`.

## Notes

The information needed for sending a remote notification comes in three categories:

- The device token (String) – This is a unique hex-encoded identifier, provided by the device itself, which represents a message destination.
- `Delivery Options</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>` (Class) – Specifics about how and where the message(s) are being delivered. See `XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>` for the details.
- `Message</api/xojocloud/xojocloud.remotenotifications.message>` (Class) – The contents of the message being delivered. See `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>` for the details.

The actual message being sent can be in one of two forms:

- A `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>` which is format most Xojo apps sending remote notifications will use
- In `JSONItem</api/text/json/jsonitem>` format which allows for more elaborate messages than Xojo currently supports. This is primarily for apps not written in Xojo that use Xojo Cloud for remote notifications.

If an error occurs, the delegate method will be called and passed the UUID and a `RuntimeException</api/exceptions/runtimeexception>` containing the error information of the notification in which the error occurred.

## Sample code

This example sends a remote notification message to all of the devices whose device tokens exist in the customerTokens array. Note that the values assigned to APNSKeyID and AppleTeamID would come from your Apple developer account:

``` xojo
' First, define the items that we needed from above
Const ApplicationID as String = "com.example.myapp"
Const APNSKeyID as String = "ABS123"
Const AppleTeamID as String = "MY123COMP456ANY"

' First we define the delivery options for this group of notifications
Var deliveryOpts as new XojoCloud.RemoteNotifications.DeliveryOptions(ApplicationID, APNSKeyID, AppleTeamID)

' Create a message that we want to send to our customers
Var message as New XojoCloud.RemoteNotifications.Message
message.alertTitle = "Bobby's Barbecues"
message.alertSubtitle = "Memorial Day Weekend Sale!"
message.alertBody = "Hurry on in! Our Memorial Day sale is going on right now and all grilling equipment is 40% off!"

For i as Integer = 0 to customerTokens.LastIndex
  XojoCloud.RemoteNotifications.SendAppleNotification(message, deliveryOpts, customerTokens(i))
Next i
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |

<div class="seealso">

`XojoCloud.RemoteNotifications.DeliveryOptions</api/xojocloud/xojocloud.remotenotifications.deliveryoptions>` and `XojoCloud.RemoteNotifications.Message</api/xojocloud/xojocloud.remotenotifications.message>` classes.

</div>
