The Notification API allows you to provide feedback to the user, either auditory, tactile or visual. Use this API to give a visual popup window, sound the device beeper or illuminate the device LEDs (hardware permitting)
This API is part of the coreapi
extension that is included automatically.
extensions: ["coreapi"]
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
If the device is equipped with a beeper then a beep will be emitted. Not supported on iOS devices.
Parameters
The properties associated with the beep.
The frequency of the beep, in Hz
A number between 0 and 3. 0 represents minimum volume and 3 is maximum volume, the decibels each volume level represents is device dependant.
The duration of the beep, in milliseconds
Synchronous Return:
Method Access:
Rho.Notification.beep(HASH propertyMap)
Rho::Notification.beep(HASH propertyMap)
Closes the current popup window
Synchronous Return:
Method Access:
Rho.Notification.hidePopup()
Rho::Notification.hidePopup()
Play an audio file if that media type is supported by the device.
Parameters
The full path to the file, ending in the file name and extension.
Media type can be specified explicitly, or can be recognized from the file extension. The known file extensions are ".mp3" - "audio/mpeg" and ".wav" - "audio/x-wav".
Synchronous Return:
Method Access:
Rho.Notification.playFile(STRING path, STRING media_type)
Rho::Notification.playFile(STRING path, STRING media_type)
Bring the application up front and show a message in a popup window. The message can be passed as a string or a hash. The popup window closes after you click on one of the buttons in the button
array. Icon is not supported on iOS devices.
Parameters
The properties associated with the popup.
Text displayed in the popup window
Title of the popup window
Icon to be displayed in the popup window. path to an image, or :alert for ! icon, :question for ? icon, :info for information icon. Platforms:Android
Array of buttons. Specify each button either by hash with :id and :title keys os string. For example: [{id:'yes',title:'Ok to Delete'},{id:'no',title:'No'}]. Using hash this way: [{id:'yes',title:'Ok to Delete'},{id:'no',title:'No'}] Using string example: ['Yes', 'No']. Note: in case of buttons has been specified using strings an id and a title of each button will have same value.
Async Callback Returning Parameters: HASH
ID assigned to the button when showing the popup
Button text
The index in the 'buttons' array.
Synchronous Return:
Method Access:
Rho.Notification.showPopup(HASH propertyMap, CallBackHandler callback)
Rho::Notification.showPopup(HASH propertyMap, CallBackHandler callback)
Display a window containing a status message. The window closes after the user clicks on its hide button.
Parameters
The title on the status message popup window.
The status message displayed in the popup status window.
The label text for the hide button in the popup status window
Synchronous Return:
Method Access:
Rho.Notification.showStatus(STRING title, STRING status_text, STRING hide_button_label)
Rho::Notification.showStatus(STRING title, STRING status_text, STRING hide_button_label)
Vibrate the device’s pager hardware
Parameters
The duration of the vibration, in milliseconds. Note you may also need to add the vibration capability to your build.yml file. See remarks for maximum duration. iOS devices have fixed system vibration time. It could not be changed. Android and Windows devices have default vibration time 1000 ms
Synchronous Return:
Method Access:
Rho.Notification.vibrate(Integer duration)
Rho::Notification.vibrate(Integer duration)
# --------------- # controller.rb # --------------- def sound_beeper # Obtain list of available leds on the device. beeperProps = Hash.new beeperProps['frequency'] = 3000; beeperProps['volume'] = 2; beeperProps['duration'] = 1500; Rho::Notification.beep(beeperProps) end
function show_alert() { //creates a popup with a message and two buttons Rho.Notification.showPopup({ title:'My Popup', message:'Do you really want to delete this record', buttons:[ {id:'yes',title:'Ok to Delete'}, {id:'no',title:'No'}] }, function(e){ if(e.button_id == "yes") { // go ahead and delete the record } } ); }
On Android, the maximum duration for vibrate is 15 seconds (15000ms).
Some Windows Mobile or CE devices may report hardware which is not present on the device such as a pager or LEDs. This is a limitation of the underlying driver layer reporting spurious results to the application, though all real hardware will be controllable.