Module
XojoCloud.RemoteNotifications
Description
Allows the sending of remote notifications to iOS devices via a Xojo web application running on Xojo Cloud.
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
message As XojoCloud.RemoteNotifications.Message, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As String |
|||
message As XojoCloud.RemoteNotifications.Message, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As String, callback As XojoCloud.RemoteNotifications.CallbackDelegate = Nil |
|||
message As JSONItem, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As String |
|||
message As XojoCloud.RemoteNotifications As JSONItem, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As String, callback As XojoCloud.RemoteNotifications.CallbackDelegate = Nil |
Delegate Methods
Name |
Parameters |
Returns |
---|---|---|
UUID As String, error As RuntimeException |
Method descriptions
XojoCloud.RemoteNotifications.SendAppleNotification
SendAppleNotification(message As XojoCloud.RemoteNotifications.Message, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As 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.
XojoCloud.RemoteNotifications.SendAppleNotification
SendAppleNotification(message As XojoCloud.RemoteNotifications.Message, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As String, callback As XojoCloud.RemoteNotifications.CallbackDelegate = Nil) As 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.
XojoCloud.RemoteNotifications.SendAppleNotification
SendAppleNotification(message As JSONItem, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As 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.
XojoCloud.RemoteNotifications.SendAppleNotification
SendAppleNotification(message As XojoCloud.RemoteNotifications As JSONItem, options As XojoCloud.RemoteNotifications.DeliveryOptions, deviceToken As String, callback As XojoCloud.RemoteNotifications.CallbackDelegate = Nil) As 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 containing the error information of the notification in which the error occurred.
Delegate descriptions
XojoCloud.RemoteNotifications.CallbackDelegate
CallbackDelegate(UUID As String, error As RuntimeException)
The address of a method with this signature can be passed to 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 (Class) – Specifics about how and where the message(s) are being delivered. See XojoCloud.RemoteNotifications.DeliveryOptions for the details.
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:
A XojoCloud.RemoteNotifications.Message which is format most Xojo apps sending remote notifications will use
In 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 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
Compatibility
All project types on all supported operating systems.
See also
XojoCloud.RemoteNotifications.DeliveryOptions and XojoCloud.RemoteNotifications.Message classes.