public class Push
- Object
- Push
Utility class for sending a push message to a different device
through the Codename One push servers.
Fields
public static final String GOOGLE_PUSH_KEY = "googlePlay" | Key for the hashtable argument when pushing to the google play store |
Constructors
public Push(String token, String body, String... deviceKeys) | Creates a new push notification. |
Methods
Inherited methods
Field details
GOOGLE_PUSH_KEY
public static final String GOOGLE_PUSH_KEY = "googlePlay"Key for the hashtable argument when pushing to the google play store
Constructor details
Push
public Push(String token, String body, String... deviceKeys)Creates a new push notification.
Parameters
tokenString- the authorization token from the account settings in the CodenameOne website, this is used to associate push quotas with your app
bodyString- the body of the message
deviceKeysString...- Device keys when sending to specific devices.
Method details
sendPushMessage
public static boolean sendPushMessage(String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword)Deprecated. this method sends a push using the old push servers which will be retired, you need to switch
to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
Parameters
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
Returns
true if the message reached the Codename One server successfully, this makes no guarantee
of delivery.
sendPushMessage
public static boolean sendPushMessage(String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword, String bbUrl, String bbApp, String bbPass, String bbPort)Deprecated. this method sends a push using the old push servers which will be retired, you need to switch
to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
Parameters
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
bbUrlString- the URL to which the push should be submitted when sending a blackberry push for evaluation use https://pushapi.eval.blackberry.com for production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbAppString- the application id to authenticate on push for RIM devices
bbPassString- the application password credentials authenticate on push for RIM devices
bbPortString- the port of the blackberry push
Returns
true if the message reached the Codename One server successfully, this makes no guarantee
of delivery.
sendPushMessageAsync
public static void sendPushMessageAsync(String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword)Deprecated. this method sends a push using the old push servers which will be retired, you need to switch
to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
Parameters
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
sendPushMessageAsync
public static void sendPushMessageAsync(String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword, String bbUrl, String bbApp, String bbPass, String bbPort)Deprecated. this method sends a push using the old push servers which will be retired, you need to switch
to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
Parameters
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
bbUrlString- the URL to which the push should be submitted when sending a blackberry push for evaluation use https://pushapi.eval.blackberry.com for production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbAppString- the application id to authenticate on push for RIM devices
bbPassString- the application password credentials authenticate on push for RIM devices
bbPortString- the port of the blackberry push
getDeviceKey
public static String getDeviceKey()Deprecated. this method sends a push using the old push servers which will be retired, you need to switch
to getPushKey()
Returns the push device key if the device was previously successfully registered for push
otherwise returns null
Returns
the device key that can be used to push to this specific device.
getPushKey
public static String getPushKey()Returns the push device key if the device was previously successfully registered for push
otherwise returns null
Returns
the device key that can be used to push to this specific device.
subscribeToTopic
public static void subscribeToTopic(String topic)Subscribes this device to a push topic. Topics are a fan-out mechanism: a single server-side push to a topic is delivered to every device subscribed to it, without the server needing to track individual device keys.
On Android this maps to Firebase Cloud Messaging topics. On iOS, where the stock push transport is raw APNs which has no native topic concept, this is a no-op and topic fan-out must be performed server side; a warning is logged.
Parameters
topicString- the topic name
unsubscribeFromTopic
public static void unsubscribeFromTopic(String topic)Unsubscribes this device from a previously subscribed push topic.
On Android this maps to Firebase Cloud Messaging topics. On iOS this is a no-op; a warning is logged.
Parameters
topicString- the topic name
sendPushMessage
public static boolean sendPushMessage(String token, String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword)Deprecated. Please use new builder syntax with
#send() which includes parameters for new platforms such as UWP.Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
This method uses the new push servers
Parameters
tokenString- the authorization token from the account settings in the CodenameOne website, this is used to associate push quotas with your app
bodyString- the body of the message
deviceKeyString- the device key that will receive the push message (can’t be null!)
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
Returns
true if the message reached the Codename One server successfully, this makes no guarantee
of delivery.
sendPushMessage
public static boolean sendPushMessage(String token, String body, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword, int pushType, String... deviceKey)Deprecated. Please use new builder syntax with
#send() which includes parameters for new platforms such as UWP.Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
This method uses the new push servers
Parameters
tokenString- the authorization token from the account settings in the CodenameOne website, this is used to associate push quotas with your app
bodyString- the body of the message
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
pushTypeint- the type for the push in the server, this is useful for sending hidden pushes (type 2) should default to 0 or 1
deviceKeyString...- set of devices that should receive the push
Returns
true if the message reached the Codename One server successfully, this makes no guarantee
of delivery.
sendPushMessage
public static boolean sendPushMessage(String token, String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword, String bbUrl, String bbApp, String bbPass, String bbPort)Deprecated. Please use new builder syntax with
#send() which includes parameters for new platforms such as UWP.Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
This method uses the new push servers
Parameters
tokenString- the authorization token from the account settings in the CodenameOne website, this is used to associate push quotas with your app
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
bbUrlString- the URL to which the push should be submitted when sending a blackberry push for evaluation use https://pushapi.eval.blackberry.com for production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbAppString- the application id to authenticate on push for RIM devices
bbPassString- the application password credentials authenticate on push for RIM devices
bbPortString- the port of the blackberry push
Returns
true if the message reached the Codename One server successfully, this makes no guarantee
of delivery.
sendPushMessageAsync
public static void sendPushMessageAsync(String token, String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword)Deprecated. Please use new builder syntax with
#sendAsync() which includes parameters for new platforms such as UWP.Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
This method uses the new push servers
Parameters
tokenString- the authorization token from the account settings in the CodenameOne website, this is used to associate push quotas with your app
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
sendPushMessageAsync
public static void sendPushMessageAsync(String token, String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword, String bbUrl, String bbApp, String bbPass, String bbPort)Deprecated. Please use new builder syntax with
#sendAsync() which includes parameters for new platforms such as UWP.Sends a push message and returns true if server delivery succeeded, notice that the
push message isn’t guaranteed to reach all devices.
This method uses the new push servers
Parameters
tokenString- the authorization token from the account settings in the CodenameOne website, this is used to associate push quotas with your app
bodyString- the body of the message
deviceKeyString- an optional parameter (can be null) when sending to a specific device
productionboolean- whether pushing to production or test/sandbox environment
googleAuthKeyString- authorization key from the google play store
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
bbUrlString- the URL to which the push should be submitted when sending a blackberry push for evaluation use https://pushapi.eval.blackberry.com for production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbAppString- the application id to authenticate on push for RIM devices
bbPassString- the application password credentials authenticate on push for RIM devices
bbPortString- the port of the blackberry push
gcmAuth
public Push gcmAuth(String googleAuthKey)Sets authentication for GMS (Android and Chrome)
Parameters
googleAuthKeyString- authorization key from the google play store
Returns
self for chaining
apnsAuth
public Push apnsAuth(String iosCertificateURL, String iosCertificatePassword, boolean production)Sets authentication for APNS (iOS)
Parameters
iosCertificateURLString- a URL where you host the iOS certificate for this applications push capabilities.
iosCertificatePasswordString- the password for the push certificate
productionboolean- True if this is a production certificate. False if this is a development certificate.
Returns
Self for chaining
wnsAuth
public Push wnsAuth(String wnsSID, String wnsClientSecret)Sets authenticaton for WNS (Windows 10/UWP)
Parameters
wnsSIDString- The SID from the Windows store.
wnsClientSecretString- The client secret from the windows store
Returns
self for chaining.
pushType
public Push pushType(int pushType)Sets the type of push to use. See developer guide for details of different push types. Default is 1
Returns
Self for chaining.
send
public boolean send()Sends push message.
Returns
True if the request was successful.
sendAsync
public void sendAsync()Sends push message asynchronously.