Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class Push
- Object
- Push
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"Constructor details
Push
public Push(String token, String body, String... deviceKeys)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)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
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)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
sendPushMessageAsync
public static void sendPushMessageAsync(String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword)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)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
setDeliveryDeferred
public static void setDeliveryDeferred(boolean deferred)Chooses whether an incoming push may interrupt a blocking call.
By default (true) a push that arrives while the application is inside a blocking call on
the EDT – a modal Dialog shown from start(), invokeAndBlock(),
NetworkManager.addToQueueAndWait() – is held, and PushCallback.push(String) is called
as soon as the outermost blocking call returns. Pushes are delivered in arrival order and
none is dropped. A push is never held longer than about 15 seconds – below the time iOS allows a
background push – after which it is delivered inside the blocking call after all. This keeps a push from running before the form it needs exists, which is
what happens when an application is launched by tapping a notification while start() is
still showing a dialog or waiting on the network.
Pass false to deliver every push as soon as it reaches the EDT, even in the middle of a
blocking call, as releases before this setting did. Call it from init(Object) so it is in
force before the first push.
Parameters
deferredboolean- true to hold pushes while a blocking call is in progress
isDeliveryDeferred
public static boolean isDeliveryDeferred()Returns
#setDeliveryDeferred(boolean)getDeviceKey
public static String getDeviceKey()Returns
getPushKey
public static String getPushKey()Returns
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)#send() which includes parameters for new platforms such as UWP.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
sendPushMessage
public static boolean sendPushMessage(String token, String body, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword, int pushType, String... deviceKey)#send() which includes parameters for new platforms such as UWP.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
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)#send() which includes parameters for new platforms such as UWP.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
sendPushMessageAsync
public static void sendPushMessageAsync(String token, String body, String deviceKey, boolean production, String googleAuthKey, String iosCertificateURL, String iosCertificatePassword)#sendAsync() which includes parameters for new platforms such as UWP.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)#sendAsync() which includes parameters for new platforms such as UWP.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)Parameters
googleAuthKeyString- authorization key from the google play store
Returns
apnsAuth
public Push apnsAuth(String iosCertificateURL, String iosCertificatePassword, boolean production)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
wnsAuth
public Push wnsAuth(String wnsSID, String wnsClientSecret)Parameters
wnsSIDString- The SID from the Windows store.
wnsClientSecretString- The client secret from the windows store
Returns
pushType
public Push pushType(int pushType)Returns
send
public boolean send()Returns
sendAsync
public void sendAsync()