Class NotificationCreator


  • public class NotificationCreator
    extends Creator<Notification>
    PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
    • Constructor Detail

      • NotificationCreator

        public NotificationCreator​(String pathServiceSid)
        Construct a new NotificationCreator.
        Parameters:
        pathServiceSid - The SID of the Service to create the resource under
    • Method Detail

      • setBody

        public NotificationCreator setBody​(String body)
        The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification..
        Parameters:
        body - The notification body text
        Returns:
        this
      • setPriority

        public NotificationCreator setPriority​(Notification.Priority priority)
        The priority of the notification. Can be: `low` or `high` and the default is `high`. A value of `low` optimizes the client app's battery consumption; however, notifications may be delivered with unspecified delay. For FCM and GCM, `low` priority is the same as `Normal` priority. For APNS `low` priority is the same as `5`. A value of `high` sends the notification immediately, and can wake up a sleeping device. For FCM and GCM, `high` is the same as `High` priority. For APNS, `high` is a priority `10`. SMS does not support this property..
        Parameters:
        priority - The priority of the notification
        Returns:
        this
      • setTtl

        public NotificationCreator setTtl​(Integer ttl)
        How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property..
        Parameters:
        ttl - How long, in seconds, the notification is valid
        Returns:
        this
      • setTitle

        public NotificationCreator setTitle​(String title)
        The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices..
        Parameters:
        title - The notification title
        Returns:
        this
      • setSound

        public NotificationCreator setSound​(String sound)
        The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property..
        Parameters:
        sound - The name of the sound to be played for the notification
        Returns:
        this
      • setAction

        public NotificationCreator setAction​(String action)
        The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels..
        Parameters:
        action - The actions to display for the notification
        Returns:
        this
      • setData

        public NotificationCreator setData​(Map<String,​Object> data)
        The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels..
        Parameters:
        data - The custom key-value pairs of the notification's payload
        Returns:
        this
      • setApn

        public NotificationCreator setApn​(Map<String,​Object> apn)
        The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed..
        Parameters:
        apn - The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS Bindings
        Returns:
        this
      • setGcm

        public NotificationCreator setGcm​(Map<String,​Object> gcm)
        The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. See the [GCM documentation](https://developers.google.com/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref)..
        Parameters:
        gcm - The GCM-specific payload that overrides corresponding attributes in generic payload for GCM Bindings
        Returns:
        this
      • setSms

        public NotificationCreator setSms​(Map<String,​Object> sms)
        The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/send-messages) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array..
        Parameters:
        sms - The SMS-specific payload that overrides corresponding attributes in generic payload for SMS Bindings
        Returns:
        this
      • setFacebookMessenger

        public NotificationCreator setFacebookMessenger​(Map<String,​Object> facebookMessenger)
        Deprecated..
        Parameters:
        facebookMessenger - Deprecated
        Returns:
        this
      • setFcm

        public NotificationCreator setFcm​(Map<String,​Object> fcm)
        The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel..
        Parameters:
        fcm - The FCM-specific payload that overrides corresponding attributes in generic payload for FCM Bindings
        Returns:
        this
      • setSegment

        public NotificationCreator setSegment​(List<String> segment)
        The Segment resource is deprecated. Use the `tag` parameter, instead..
        Parameters:
        segment - A Segment to notify
        Returns:
        this
      • setSegment

        public NotificationCreator setSegment​(String segment)
        The Segment resource is deprecated. Use the `tag` parameter, instead..
        Parameters:
        segment - A Segment to notify
        Returns:
        this
      • setToBinding

        public NotificationCreator setToBinding​(List<String> toBinding)
        The destination address specified as a JSON string. Multiple `to_binding` parameters can be included but the total size of the request entity should not exceed 1MB. This is typically sufficient for 10,000 phone numbers..
        Parameters:
        toBinding - The destination address specified as a JSON string
        Returns:
        this
      • setToBinding

        public NotificationCreator setToBinding​(String toBinding)
        The destination address specified as a JSON string. Multiple `to_binding` parameters can be included but the total size of the request entity should not exceed 1MB. This is typically sufficient for 10,000 phone numbers..
        Parameters:
        toBinding - The destination address specified as a JSON string
        Returns:
        this
      • setIdentity

        public NotificationCreator setIdentity​(List<String> identity)
        The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/users) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Delivery will be attempted only to Bindings with an Identity in this list. No more than 20 items are allowed in this list..
        Parameters:
        identity - The `identity` value that identifies the new resource's User
        Returns:
        this
      • setIdentity

        public NotificationCreator setIdentity​(String identity)
        The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/users) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Delivery will be attempted only to Bindings with an Identity in this list. No more than 20 items are allowed in this list..
        Parameters:
        identity - The `identity` value that identifies the new resource's User
        Returns:
        this
      • setTag

        public NotificationCreator setTag​(List<String> tag)
        A tag that selects the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 5 tags. The implicit tag `all` is available to notify all Bindings in a Service instance. Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger` are available to notify all Bindings in a specific channel..
        Parameters:
        tag - A tag that selects the Bindings to notify
        Returns:
        this
      • setTag

        public NotificationCreator setTag​(String tag)
        A tag that selects the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 5 tags. The implicit tag `all` is available to notify all Bindings in a Service instance. Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger` are available to notify all Bindings in a specific channel..
        Parameters:
        tag - A tag that selects the Bindings to notify
        Returns:
        this
      • create

        public Notification create​(TwilioRestClient client)
        Make the request to the Twilio API to perform the create.
        Specified by:
        create in class Creator<Notification>
        Parameters:
        client - TwilioRestClient with which to make the request
        Returns:
        Created Notification