Class PushNotification.Builder
java.lang.Object
com.codename1.backend.push.PushNotification.Builder
- Enclosing class:
PushNotification
Builds a
PushNotification. A builder can be reused: build() takes a
snapshot.-
Method Summary
Modifier and TypeMethodDescriptionbuild()collapseKey(String value) Adds a value the app reads from the message's data, or removes it.Adds options for one provider, which the other providers ignore.silent(boolean value) Sets a widget or Live Activity command, which the app applies before its listener sees the message.ttlSeconds(int value) How long the providers keep trying to deliver the message.
-
Method Details
-
id
- Parameters:
value- an id for the message, or null to clear it- Returns:
- this builder
-
title
- Parameters:
value- the visible title, or null to clear it- Returns:
- this builder
-
body
- Parameters:
value- the visible body, or null to clear it- Returns:
- this builder
-
imageUrl
- Parameters:
value- an HTTPS URL of an image to show, or null to clear it- Returns:
- this builder
-
deepLink
- Parameters:
value- the deep link the app opens when the user taps the notification, or null to clear it- Returns:
- this builder
-
collapseKey
- Parameters:
value- a key under which a newer message replaces an older undelivered one, or null to clear it- Returns:
- this builder
-
ttlSeconds
How long the providers keep trying to deliver the message.- Parameters:
value- the lifetime in seconds, greater than zero- Returns:
- this builder
- Throws:
IllegalArgumentException- if the value isn't positive
-
silent
- Parameters:
value- true for a data-only message that shows nothing- Returns:
- this builder
-
data
Adds a value the app reads from the message's data, or removes it.- Parameters:
key- the namevalue- a JSON value (string, number, boolean, map or list), or null to remove the key- Returns:
- this builder
- Throws:
IllegalArgumentException- if the key is empty or has surrounding whitespace
-
platform
Adds options for one provider, which the other providers ignore.- Parameters:
providerId-fcm,apns,huawei,wnsorweb, or one of the aliasesPushTarget.of(String, String)acceptsoptions- the provider's options, or null to remove them- Returns:
- this builder
- Throws:
IllegalArgumentException- if the provider is unknown
-
surface
Sets a widget or Live Activity command, which the app applies before its listener sees the message.PushNotification.liveUpdate(String, Map),PushNotification.liveEnd(String, Map, boolean)andPushNotification.widget(String, String)build one.- Parameters:
command- the command, or null to remove it- Returns:
- this builder
- Throws:
IllegalArgumentException- if the command'soperationisn'twidget,live-updateorlive-end
-
build
- Returns:
- an immutable snapshot of the message built so far
-