XojoCloud.RemoteNotifications

From Xojo Documentation

Module


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

Methods
SendAppleNotification
Delegate Methods
CallbackDelegate

Notes

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

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

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

  1. A XojoCloud.RemoteNotifications.Message which is format most Xojo apps sending remote notifications will use or in JSONItem format which allows for more elaborate messages than Xojo currently supports. The latter 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 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:

// 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

See Also

XojoCloud.RemoteNotifications.DeliveryOptions and XojoCloud.RemoteNotifications.Message classes.