new Push()
This is a global variable called push exposed by cordova
- Source:
Methods
-
register(onNotification, successCallback, errorCallback, options) → {void}
-
Registers the device with the APNS (iOS) or GCM (Android) and the Unified Push server.
Parameters:
Name Type Argument Description onNotificationfunction callback to be executed if a message arrives successCallbackfunction callback to be executed when register is succesful errorCallbackfunction <optional>
callback to be executed if the request results in error optionsObject <optional>
A configuration for the Unified Push server, so that it can register this device. This is optional a when a file called push-config.json is put in the `www` folder this will be used. The object can have the following properties: Properties
Name Type Argument Description senderIdString <optional>
android specific - the id representing the Google project ID variantIDString the id representing the mobile application variant variantSecretString the secret for the mobile application variant pushServerURLString the location of the UnifiedPush server e.g. http(s)//host:port/context aliasString <optional>
Application specific alias to identify users with the system. Common use case would be an email address or a username. iosObject <optional>
Holder of the ios specific values variantID and variantSecret Properties
Name Type Argument Description variantIDString <optional>
the id representing the mobile application variant for iOS variantSecretString <optional>
the secret for the mobile application variant for iOS androidObject <optional>
Holder of the android specific values variantID and variantSecret Properties
Name Type Argument Description variantIDString <optional>
the id representing the mobile application variant for android variantSecretString <optional>
the secret for the mobile application variant for android - Source:
Returns:
- Type
- void
Examples
var pushConfig = { pushServerURL: "<pushServerURL e.g http(s)//host:port/context >", senderID: "<senderID e.g Google Project ID>", variantID: "<variantID e.g. 1234456-234320>", variantSecret: "<variantSecret e.g. 1234456-234320>" alias: "<alias e.g. a username or an email address optional>", } push.register(onNotification, successHandler, errorHandler, pushConfig);//combined android and ios configuration var pushConfig = { pushServerURL: "<pushServerURL e.g http(s)//host:port/context >", alias: "<alias e.g. a username or an email address optional>", android: { senderID: "<senderID e.g Google Project ID>", variantID: "<variantID e.g. 1234456-234320>", variantSecret: "<variantSecret e.g. 1234456-234320>" }, ios: { variantID: "<variantID e.g. 1234456-234320>", variantSecret: "<variantSecret e.g. 1234456-234320>" } }; push.register(onNotification, successHandler, errorHandler, pushConfig);//push-config.json file in www folder { "pushServerURL": "<pushServerURL e.g http(s)//host:port/context >", "android": { "senderID": "<senderID e.g Google Project ID only for android>", "variantID": "<variantID e.g. 1234456-234320>", "variantSecret": "<variantSecret e.g. 1234456-234320>" }, "ios": { "variantID": "<variantID e.g. 1234456-234320>", "variantSecret": "<variantSecret e.g. 1234456-234320>" } } push.register(onNotification, successHandler); -
setApplicationIconBadgeNumber(success, badge) → {void}
-
Call this to set the application icon badge -- ios specific
Parameters:
Name Type Argument Description successfunction callback to be executed if the request results in success badgeString | Number <optional>
the badge number to set on the application icon - Source:
Returns:
- Type
- void
Example
push.setApplicationIconBadgeNumber(successHandler, errorHandler); -
setContentAvailable(dataType) → {void}
-
Call this function to tell the OS if there was data or not so it can schedule the next fetch operation
Parameters:
Name Type Description dataTypeint one of the BackgroundFetchResults or 0 new data 1 no data or 2 failed - Source:
Returns:
- Type
- void
-
unregister(success, error) → {void}
-
Unregisters the device with the APNS (iOS) or GCM (Android) and the Unified Push server.
Parameters:
Name Type Argument Description successfunction callback to be executed if the request results in success errorfunction <optional>
callback to be executed if the request results in error - Source:
Returns:
- Type
- void
Example
push.unregister(successHandler, errorHandler);