Skip to main content

buildfire.device

This section of buildfire.js helps you access different features on the device that normally would not be accessible to a browser

Methods

calendar.addEvent

buildfire.device.calendar.addEvent(event,callback)

this function allows you to add an event to devices calendar.

buildfire.device.calendar.addEvent({
title: 'Birthday Party'
, location: '1950 Main st, NYC, NY'
, notes: 'Better bring a gift'
, startDate: new Date(2015, 10, 20, 8, 0, 0)
, endDate: new Date(2015, 10, 20, 10, 0, 0)
, options: {
firstReminderMinutes: 120
, secondReminderMinutes: 5
, recurrence: 'yearly'
, recurrenceEndDate: new Date(2025, 6, 1, 0, 0, 0, 0, 0)
}
},
function (err,result) {
if(err) return console.error(err);
console.log('Event added', result);
});

event

NameTypeRequiredDescriptionDefault
titlestringyesThe title of the event
locationstringnoThe location of the event, this can have any string value
notesstringnoAdditional information to be visible inside the event
startDateDateyesThe date and time of when the event begins
endDateDatenoThe date and time of when the event endsDevice OS Default
optionsobjectnoAn object allowing additional customization to the event

options

NameTypeRequiredDescriptionDefault
firstReminderMinutesnumbernoNumber of minutes before an event when the first reminder should be sent60
secondReminderMinutesnumbernoNumber of minutes before an event when the first reminder should be sentnone
recurrencestringnoThe recurrence frequency if the event is recurring. can be daily, weekly, monthly or yearlynone
recurrenceEndDateDatenoThe Date when the recurrence endsnever if recurrence is set

callback(err, data)

Callback function after adding the event to the calendar.

NameTypeDescription
errstringError string, null when operation is successful
resultstringSuccess result message

share

buildfire.device.share(options,callback)

this function allows you to share content outside the app through other apps.

buildfire.device.share({
subject:'my message title',
text:'my message text',
image: 'https://myImageUrl',
link: 'https://anyLink'
}, function (err,result) {
if(err) return console.error(err);
console.log('Message shared', result);
});

options

NameTypeRequiredDescriptionDefault
subjectstringyesThe subject of the message to share
textstringnoThe text of the message
imagestringnoAn image link to share
linkstringnoDirect link users can navigate to

callback(err, data)

Callback function after adding the event to the calendar.

NameTypeDescription
errstringError string, null when operation is successful
resultstringSuccess result message
tip

When the device 'sharing' feature is not available the message will be sent to the user's mail client using mailto protocol which is helpful when testing on the web emulator

Warning

Sharing on Facebook

  • On iOS/Android a message text can not be shared. Only a link or an image can be shared (Facebook App Issue)
  • On Android urls must be real domain names like .com, .net

Sharing on Mail App

  • No support for images

onAppBackgrounded

buildfire.device.onAppBackgrounded(callback, allowMultipleHandlers)

This function allows you to add an event to be fired when the application goes into background.

 buildfire.device.onAppBackgrounded(
function () {
console.log('application is in background');
}
);

callback(err, data)

Callback function after the app goes to background.

NameTypeDescription
errstringError string, null when operation is successful
resultstringSuccess result message

allowMultipleHandlers

An optional boolean parameter that tells the method to override all other handlers. Default is false

onAppResumed

buildfire.device.onAppResumed(callback, allowMultipleHandlers)

This function allows you to add an event to be fired when the application returns into foreground.

 buildfire.device.onAppResumed(
function () {
console.log('application is in foreground');
}
);

callback(err, data)

Callback function after the app returns to foreground.

NameTypeDescription
errstringError string, null when operation is successful
resultstringSuccess result message

allowMultipleHandlers

An optional boolean parameter that tells the method to override all other handlers. Default is false