Table of Contents
require( hop.hopdroid ) to use it as a library.
Creates a custom
phone object. This object is required to access
device features and to install event listeners.
phone object posses the following attributes:
sdk: the sdk name.
model: the phone model.
product: the product number.
phone.addEventListener( event, listener )
Installs an event listener for the phone. All events have an associated value whose components are stored in an array. The known events are:
battery: An event denoting the state of the battery. The value associated with the event is an array containing:
- the battery level, 2. the status, 3. the plug/unplug state, 4. the battery healt, 5. the battery voltage.
call: An event denoting the call state.
smsdelivered: Is emitted upon sms delivery. The value associated with the event is an array whose first element is the string
"ok"is the delivery has been sucessful.
smsreceived: Is emitted upon sms reception. The associated value is an array of two strings: the sender phone number and the message body.
phone.sendSms( number, text )
Sends an sms to phone
const hopdroid = require( hop.hopdroid ); const phone = new hopdroid.phone(); const phoneNumber = ...; phone.sendSms( phoneNumber, "Sent from Hop.js" );
phone.placeCall( number )
Place a call to
phone.stopCall( number )
Stop the current call.
phone.vibrate( frequency = 2, repetition = 1 )
Vibrate the phone. The argument
frequency can either be:
- an integer standing for the frequency of the vibration.
- an array of integers whose elements are vibration frequency separated by delays.
repetition is a positive integer, it tells how many times to repeat
the vibration. Example:
const hopdroid = require( hop.hopdroid ); const phone = new hopdroid.phone(); const dot = 200; const dash = 500; cont shortGap = 200; const mediumGap = 500; const longGap = 1000; const sos = [ 0, // S dot, shortGap, dot, shortGap, dot, // O dash, shortGap, dash, shortGap, dash, // S dot, shortGap, dot, shortGap, dot, longGap ]; phone.vibrate( sos );