Call system alert methods for popup, vibrate, or playing audio files. For examples of using the Alert API methods, refer to Alerts in Device Capabilities.
To use the vibrate method, you need to enable vibration on the device. Do this by adding that capability to the build.yml file:
capabilities: - vibrate
Closes the current popup window.
Alert.hide_popup
Play an audio file if that media type is supported by the device.
Alert.play_file(path, media_type)
path |
The path to the file, ending in the file name and extension. The file must located in the application; for example, /apps/public/test-file.mp3 .
|
media_type |
(optional) 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. |
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 the button.
Click here for an example of show_popup with a button and callback.
Alert.show_popup "message"
message |
a text string |
show_popup( { :message => string, :title => string, :icon => string, :buttons => [string_or_hash], :callback => url )
:message |
text displayed in the popup window |
:title |
title of the popup window |
:icon |
Icon to be displayed in the popup window. path to an image, or :alert for ! icon, :question for ? icon, :info for information icon. |
:buttons |
array of buttons. Specify each button either by hash with :id and :title keys, or by a string where id and title are set to the string value. |
:callback |
url called on button click, such as url_for(:action => :on_dismiss_popup) . It is called with a @params hash of :button_id, :button_title, and :button_index.
|
Display a window containing a status message. The window closes after the user clicks on its hide button.
Alert.show_status(title, status_text, hide_button_label)
title |
String. The title on the status message popup window. |
status_text |
String. The status message displayed in the popup status window. |
hide_button_label |
String. The label text for the hide button in the popup status window. |
Alert.vibrate(duration)
duration |
Integer. Vibrate the device for this number of milliseconds, up to 25500; if 0 or not specified, vibrate for 2500 milliseconds. |