:param object args: Vibrates constantly for the specified period of time
(in milliseconds).
Vibrate mobile device with given duration.
..code-block:: javascript
mobile.methods.vibrate({'duration': 100});
Show snackbar with action
.........................
..js:function:: showSnackBar
:param object args: (*required*) **Message** to show in snackbar and action **button label** in Snackbar (optional)
:returns: ``True`` if the user clicks on the Action button, ``False`` if SnackBar auto dismissed after some time.
Snackbars provide lightweight feedback about an operation. They show a brief
message at the bottom of the screen on mobile or in the lower left corner on larger devices.
Snackbars appear above all the other elements on the screen and only one can be
displayed at a time.
..code-block:: javascript
mobile.methods.showSnackBar({'message': 'Message is deleted', 'btn_text': 'Undo'}).then(function(result){
if(result){
// Do undo operation
}else{
// Snack Bar dismissed
}
});
..image:: images/snackbar.png
Showing notification
.....................
..js:function:: showNotification
:param object args: **title** (first row) of the notification, **message** (second row) of the notification, in a standard notification.
A notification is a message you can display to the user outside of your
application's normal UI. When you tell the system to issue a notification, it
first appears as an icon in the notification area. To see the details of the
notification, the user opens the notification drawer. Both the notification
area and the notification drawer are system-controlled areas that the user can
view at any time.
..code-block:: javascript
mobile.showNotification({'title': 'Simple Notification', 'message': 'This is a test for a simple notification'})
..image:: images/mobile_notification.png
Create contact in device
.........................
..js:function:: addContact
:param object args: Dictionary with contact details. Possible keys (name, mobile, phone, fax, email, website, street, street2, country_id, state_id, city, zip, parent_id, function and image)
Create a new device contact with the given contact details.
..code-block:: javascript
var contact = {
'name': 'Michel Fletcher',
'mobile': '9999999999',
'phone': '7954856587',
'fax': '765898745',
'email': 'michel.fletcher@agrolait.example.com',
'website': 'http://www.agrolait.com',
'street': '69 rue de Namur',
'street2': false,
'country_id': [21, 'Belgium'],
'state_id': false,
'city': 'Wavre',
'zip': '1300',
'parent_id': [8, 'Agrolait'],
'function': 'Analyst',
'image': '<<BASE 64 Image Data>>'
}
mobile.methods.addContact(contact);
..image:: images/mobile_contact_create.png
Scanning barcodes
..................
..js:function:: scanBarcode
:returns: Scanned ``code`` from any barcode
The barcode API detects barcodes in real-time, on the device, in any orientation.
The barcode API can read the following barcode formats: