Skip to main content

buildfire.notes

The NotesAPI allows users to create and manage notes for app content. Saved notes appear under the "notes" section of the side munu.

Methods

openDialog()

buildfire.notes.openDialog(options, callback)

Used for opening up notes dialog. Once opened, user can add new note or edit / remove previous notes.

buildfire.notes.openDialog(
{
itemId: "MY_VIDEO_ID",
title: "Crazy cat jumping over the fence!",
imageUrl: "https://example.com/image.jpg",
timeIndex: 22,
},
(err, data) => {
if (err) return console.error(err);

const { hasNotes, noteCount, itemId } = data;

if (hasNotes) {
console.log(`Video with id ${itemId} has ${noteCount} notes!`);
} else {
console.log(`No notes yet!`);
}
}
);

options

NameTypeRequiredDescriptionDefault
itemIdstring or numberyesUnique id
titlestringyesTitle of the item the note will belong to, will be displayed on the notes page
imageUrlstringyesIcon for the item the note will belong to, will be displayed on the notes page
timeIndexnumbernoIf adding notes to a video this allows the video to skip to the time when the user added the note. Expressed in seconds.

callback(err, data)

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectNotes dialog response
data
NameTypeDescription
itemIdstring or numberUnique identifier
notes[object]All notes for this item. Returns as an empty array if there isn't any note
hasNotesbooleanIndicates whether there is at least 1 note associated with itemId
noteCountnumberTotal number of notes associated with itemId
notes
NameTypeDescription
idnumberUnique identifier
textstringThe note's text
timeIndexnumberIf adding notes to a video this allows the video to skip to the time when the user added the note. Expressed in seconds. Returns as false if wasn't provided.

getByItemId()

buildfire.notes.getByItemId(options, callback)

Useful if you want to get total number of notes or simply check if any note exists on given itemId without pulling up the notes dialog.

buildfire.notes.getByItemId(
{
itemId: "MY_VIDEO_ID",
},
(err, data) => {
if (err) return console.error(err);

const { hasNotes, noteCount, itemId } = data;

if (hasNotes) {
console.log(`Video with id ${itemId} has ${noteCount} notes!`);
} else {
console.log(`Video with id ${itemId} does not have a single note yet!`);
}
}
);

options

NameTypeRequiredDescriptionDefault
itemIdstring or numberyesUnique identifierN/A

callback(err, data)

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectNotes dialog response, see data
data
NameTypeDescription
itemIdstring or numberUnique identifier
notes[object]All notes for this item. Returns as an empty array if there isn't any note
hasNotesbooleanIndicates whether there is at least 1 note associated with itemId
noteCountnumberTotal number of notes associated with itemId
notes
NameTypeDescription
idnumberUnique identifier
textstringThe note's text
timeIndexnumberIf adding notes to a video this allows the video to skip to the time when the user added the note. Expressed in seconds. Returns as false if wasn't provided.

onSeekTo()

buildfire.notes.onSeekTo(callback)

If you have a video associated with an item, pass its current time to openDialog as timeIndex. If the item is later on opened through the notes dialog, BuildFire will trigger an event used to seek to the specified time.

buildfire.notes.onSeekTo((data) => {
console.log("Seek to time:", data.time);
});

callback(data)

Function called when there is timeIndex

NameTypeDescription
dataobjectObject containing time

Handling note opens

The app will navigate to the plugin to which the note belongs, and will pass note data through deep links.

This can be useful in cases where the plugin has internal navigation, which must be triggered when the note is opened. The following example shows how a plugin may use the payload to navigate to a specific YouTube video.

buildfire.deeplink.getData((data) => {
if (data && data.link) {
// use link to navigate to item
}
});

Editing and Deleting notes

The user manages their notes for an item through the notes dialog that is accessed through menu or opened programatically using openDialog. Once there, they can add, edit or remove notes.