The Push API provides access to Push messaging functionality. Use this API to give your application the ability to receive server initiated messages.
To use this API, you must include the following extension in your build.yml
:
For APNS:
capabilities: ["push"]
For FCM:
capabilities: ["push"] extensions: ["fcm-push"] fcmSenderID: 'your_fcm_sender_id' fcmAppID: 'your_fcm_app_id'
Supporting FCM Push on iOS Download GoogleService-Info.plist and put it into the root of your application. Please read guide Add Firebase to your iOS project for more details.
For GCM ( NB: GCM is deprecated, we recommend using FCM push ):
capabilities: ["push"] extensions: ["gcm-push"]
For RhoConnect Push Service:
extensions: ["rhoconnect-push", "rhoconnect-client"]
NOTES
For Win32(XPE), Microsoft Message Queue (MSMQ) and .Net Framework 3.5 also must be installed on the device.
GCM is no longer supported as a standalone jar file since being moved to Google Play services. If you have trouble building an Android app with RhoElements 4.0.0 and Push capability, try these steps:
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:
Map of all available properties
: this method also supports async callbacks - check the Callback tab for callback return parameters.
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:
Default object of Module.
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:
Map of properties I want to know about
: this method also supports async callbacks - check the Callback tab for callback return parameters.
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:
The property to return info about.
: this method also supports async callbacks - check the Callback tab for callback return parameters.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: Rho::Push defaultInstance)
Rho::Push.setDefault(SELF_INSTANCE: Rho::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()
Application name used by RhoConnect Push server to identify application.
Property Access:
myObject.pushAppName
Rho.Push.pushAppName
Rho::Push.pushAppName
URL of RhoConnect Push server.
Property Access:
myObject.pushServer
Rho.Push.pushServer
Rho::Push.pushServer
Push engine type.
Possible Values (STRING):
RhoConnect push engine.
Native push engine (like GCM on Android).
Property Access:
myObject.type
Rho.Push.type
Rho::Push.type
UI notification mode. Use Rho.Notification
instead.
Default: backgroundNotifications
Possible Values (STRING):
Do not notify user about received push messages.
Notify user with alerts inside of application UI only.
Notify user using notification bar.
Notify user using notification bar if in background and with alerts in foreground.
Property Access:
myObject.userNotifyMode
Rho::Push.userNotifyMode
Start Push Notifications service and define alert popup window in push callback method.
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