Cordova Plugin API Reference
API methods to manage push notifications for Cordova project
onDeviceReady
[android, ios, wp8, windows] Initializes Pushwoosh plugin and triggers a start push message. Should be called on every app launch.
config.appid
– Pushwoosh application code.
config.projectid
– GCM project number for Android platform.
config.serviceName
– MPNS service name for wp8 platform.
registerDevice
[android, ios, wp8, windows] Registers device for push notifications and retrieves a push Token.
success
– success callback. Push token is passed as “status.pushToken” parameter to this callback
fail
– error callback
unregisterDevice
[android, ios, wp8, windows] Unregisters device from receiving push notifications.
success
– success callback
fail
– error callback
setTags
[android, ios, wp8, windows] Sets tags for the device.
Parameters
config
– object with custom device tags
success
– success callback. Push token is passed as “status.pushToken” parameter to this callback
fail
– error callback
getTags
[android, ios, wp8, windows] Returns tags for the device including default tags.
success
– success callback. Receives tags as parameters
fail
– error callback
getPushToken
[android, ios, wp8, windows] Returns push token if it is available. Note that the token also comes in registerDevice function callback.
success
– success callback.
getPushwooshHWID
[android, ios, wp8, windows] Returns Pushwoosh HWID used for communications with Pushwoosh API.
success
– getPushwooshHWID callback
getRemoteNotificationStatus
[android, ios] Returns detailed status of push notification permissions.
callback
– success callback. Receives object with following properties:
{
”enabled” : notificaions enabled flag.
”pushBadge” : badges permission granted. (iOS only)
”pushAlert” : alert permission granted. (iOS only)
”pushSound” : sound permission granted. (iOS only)
}
error
— error callback
setApplicationIconBadgeNumber
[android, ios] Set the application icon badge number.
badgeNumber
– icon badge number
getApplicationIconBadgeNumber
[android, ios] Returns application icon badge number.
callback
– success callback
addToApplicationIconBadgeNumber
[android, ios] Adds value to application icon badge.
badgeNumber
— incremental icon badge number
getLaunchNotification
[android, ios] Returns push notification payload if the app was started in response to a push notification, or null.
callback
– success callback
clearLaunchNotification
[android, ios] Clears launch notification, getLaunchNotification() will return null after this call.
setUserId
[android, ios] Sets User indentifier– a Facebook ID, username,email, or any other user ID. This allows data and events to be matched across multiple user devices.
userId
– user string identifier
postEvent
[android, ios] Posts events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel.
event
– event to trigger
attributes
– object with additional event attributes
createLocalNotification
[android, ios] Schedules local notification.
config.msg
– notification message
config.seconds
– notification delay in seconds
config.userData
– additional data to pass in notification
success
– success callback
fail
– error callback
clearLocalNotification
[android] Clears all pending local notifications created by createLocalNotification
clearNotificationCenter
[android] Clears all notifications presented in Android Notification Center.
setMultiNotificationMode
[android] Allows multiple notifications to be displayed in the Android Notification Center.
setSingleNotificationMode
[android] Allows only the last notification to be displayed in Android Notification Center.
setSoundType
[android] Sets default sound for incoming pushes.
type
– Sound type (0 – default, 1 – no sound, 2 – always)
setVibrateType
[android] Sets default vibration mode for incoming pushes.
type
– Vibration type (0 – default, 1 – no vibration, 2 – always)
setLightScreenOnNotification
[android] Turns screen on when notification arrives.
on
– enable/disable screen unlock (disabled by default)
setEnableLED
[android] Enables led blinking when notification arrives and display is off.
on
– enable/disable LED blink (disabled by default)
setColorLED
[android] Sets led color. Use with setEnableLED.
color
– LED color in ARGB integer format
getPushHistory
[android] Returns array of received push notifications.
success
– success callback
clearPushHistory
[android] Clears push history.
cancelAllLocalNotifications
[ios] Clears all local notifications from the notification center.
presentInboxUI
[android, ios] Opens Inbox screen.
setCommunicationEnabled
A binary method enabling/disabling all communication with Pushwoosh. The boolean value is false unsubscribes the device from receiving push notifications and stops in-app messages download. The value true reverses the effect.
removeAllDeviceData
Removes all data about the device.
push-receive
[android, ios] Push notification receive event. Is fired when application receives push notification in foreground or background. Closed applications does not receive this event.
Event properties
message
– (string
) Push notification message
userdata
– (object
/array
) Push notification custom data
onStart
– (boolean
) Is launch notification
foreground
– (boolean
) Is notification received in foreground
android
– (object
) Android specific notification payload
ios
– (object
) iOS specific notification payload
wp8
– (object
) Windows Phone specific notification payload
windows
– (object
) Windows specific notification payload
Foreground notifications
By default Pushwoosh plugin does not display notifications in the foreground and automatically triggers push-receive
event. See plugin customization guide for controlling this behavior.
push-notification
[android, ios, wp8, windows] Push notification accept event. It is fired when user taps the push notification.
Event properties
Same as push-receive
additionalAuthorizationOptions
[ios only] Provides additional notification authorization options. Should be called before calling registerDevice.
Last updated