The Push API provides access to Push messaging functionality
Use this API to give your application the ability to receive server initiated messages.
In order to use this API you must include the following extension in your build.yml
:
For APNS or GCM:
capabilities: ["push"]
For RhoConnect Push Service:
extensions: ["rhoconnect-push", "rhoconnect-client"]
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript
Be sure to review the Ruby API Usage guide for important information about using this API in Ruby
This method will return all of object/value pairs for the propertyNames of the API class.
Parameters
Async Callback Returning Parameters: HASH
Synchronous Return:
Method Access:
myObject.getAllProperties(CallBackHandler callback)
Rho.Push.getAllProperties(CallBackHandler callback)
Rho::Push.getAllProperties(CallBackHandler callback)
This method will return an object that represents the default instance of the API Class. For example Camera.getDefault will return a Camera object that represents the default camera.
Synchronous Return:
Method Access:
Rho.Push.getDefault()
Rho::Push.getDefault()
Returns push token used to identify particular device.
Parameters
Async Callback Returning Parameters: STRING
Synchronous Return:
Method Access:
myObject.getDeviceId(CallBackHandler callback)
Rho.Push.getDeviceId(CallBackHandler callback)
Rho::Push.getDeviceId(CallBackHandler callback)
This method will return a set of object/value pairs for the list of the propertyName that is passed in. The propertyNames must be a valid property of the API class.
Parameters
List of properties I want to know about
Async Callback Returning Parameters: HASH
Synchronous Return:
Method Access:
myObject.getProperties(ARRAY arrayofNames, CallBackHandler callback)
Rho.Push.getProperties(ARRAY arrayofNames, CallBackHandler callback)
Rho::Push.getProperties(ARRAY arrayofNames, CallBackHandler callback)
This method will return the value of the propertyName that is passed in. The propertyName must be a valid property of the API class.
Parameters
The property to return info about.
Async Callback Returning Parameters: STRING
Synchronous Return:
Method Access:
myObject.getProperty(STRING propertyName, CallBackHandler callback)
Rho.Push.getProperty(STRING propertyName, CallBackHandler callback)
Rho::Push.getProperty(STRING propertyName, CallBackHandler callback)
This method allows you to set the attributes of the default object instance by passing in an object of the same class.
Parameters
An instance object that is of the same class.
Synchronous Return:
Method Access:
Rho.Push.setDefault(SELF_INSTANCE: Push defaultInstance)
Rho::Push.setDefault(SELF_INSTANCE: Push defaultInstance)
This method will set the values of a list of properties for the API class. The propertyName must be a valid property for the class and must also not be read only.
Parameters
Map of properties I want to set
Synchronous Return:
Method Access:
myObject.setProperties(HASH propertyMap)
Rho.Push.setProperties(HASH propertyMap)
Rho::Push.setProperties(HASH propertyMap)
This method will set the value of a property for the API class. The propertyName must be a valid property for the class and must also not be read only.
Parameters
The one property name that I want to set
The one property value that I want to set
Synchronous Return:
Method Access:
myObject.setProperty(STRING propertyName, STRING propertyValue)
Rho.Push.setProperty(STRING propertyName, STRING propertyValue)
Rho::Push.setProperty(STRING propertyName, STRING propertyValue)
Start listening for push messages, errors or other push related events.
Parameters
Async Callback Returning Parameters: HASH
List of sources to sync separated by comma or 'all'.
Alert message to show to user.
Vibrate duration in milliseconds.
Path to sound file to play when push message is received.
Synchronous Return:
Method Access:
myObject.startNotifications(CallBackHandler callback)
Rho.Push.startNotifications(CallBackHandler callback)
Rho::Push.startNotifications(CallBackHandler callback)
Stop listening push events.
Synchronous Return:
Method Access:
myObject.stopNotifications()
Rho.Push.stopNotifications()
Rho::Push.stopNotifications()
Property Access:
myObject.pushAppName
Rho.Push.pushAppName
Rho::Push.pushAppName
Property Access:
myObject.pushServer
Rho.Push.pushServer
Rho::Push.pushServer
Possible Values (STRING):
Property Access:
myObject.type
Rho.Push.type
Rho::Push.type
Default: backgroundNotifications
Possible Values (STRING):
Property Access:
myObject.userNotifyMode
Rho::Push.userNotifyMode
function setupPush() { // Start listening for push messages. Parameter is an url to push_callback method Rho.Push.startNotifications(pushCallback); } function pushCallback(params) { // Show 'alert' popup window with push message text var propertyMap = {message: params["alert"], buttons: [{id: 'OK', title: 'OK'}]}; Rho.Notification.showPopup(propertyMap); }
def setup_push # Start listening for push messages. Parameter is an url to push_callback method Rho::Push.startNotifications(url_for(:action=>:push_callback)) end def push_callback # Show 'alert' popup window with push message text Rho::Notification.showPopup({'message' => @params['alert'], 'buttons' =>['OK']}) end