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
Name | Type | Required | Description | Default |
---|---|---|---|---|
title | string | yes | The title of the event | |
location | string | no | The location of the event, this can have any string value | |
notes | string | no | Additional information to be visible inside the event | |
startDate | Date | yes | The date and time of when the event begins | |
endDate | Date | no | The date and time of when the event ends | Device OS Default |
options | object | no | An object allowing additional customization to the event |
options
Name | Type | Required | Description | Default |
---|---|---|---|---|
firstReminderMinutes | number | no | Number of minutes before an event when the first reminder should be sent | 60 |
secondReminderMinutes | number | no | Number of minutes before an event when the first reminder should be sent | none |
recurrence | string | no | The recurrence frequency if the event is recurring. can be daily , weekly , monthly or yearly | none |
recurrenceEndDate | Date | no | The Date when the recurrence ends | never if recurrence is set |
callback(err, data)
Callback function after adding the event to the calendar.
Name | Type | Description |
---|---|---|
err | string | Error string, null when operation is successful |
result | string | Success 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
Name | Type | Required | Description | Default |
---|---|---|---|---|
subject | string | yes | The subject of the message to share | |
text | string | no | The text of the message | |
image | string | no | An image link to share | |
link | string | no | Direct link users can navigate to |
callback(err, data)
Callback function after adding the event to the calendar.
Name | Type | Description |
---|---|---|
err | string | Error string, null when operation is successful |
result | string | Success result message |
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
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.
Name | Type | Description |
---|---|---|
err | string | Error string, null when operation is successful |
result | string | Success 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.
Name | Type | Description |
---|---|---|
err | string | Error string, null when operation is successful |
result | string | Success result message |
allowMultipleHandlers
An optional boolean parameter that tells the method to override all other handlers. Default is false