-
Notifications
You must be signed in to change notification settings - Fork 84
How to use Notes
This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/notes/
The NotesAPI allows users to create and manage notes for app content. Saved notes appear under the "notes" section of the side munu.
The BuildFire SDK provides the ability to add, delete, and fetch notes.
-
buildfire.notes.openDialogOpens the notes dialog where user can add notes. -
buildfire.notes.onSeekToA function that is called when navigating from notes to media content -
buildfire.notes.getByItemIdChecks if there is at least one note associated with itemId without opening notes dialog. Also returns total number of notes.
Used for opening up notes dialog. Once opened, user can add new note or edit / remove previous notes.
-
itemId {String|Number}: unique identifier -
title {String}: title of the item the note will belong to, will be displayed on the notes page -
imageUrl {String}: icon for the item the note will belong to, will be displayed on the notes page -
timeIndex {Number}: optional, if adding notes to a video this allows the video to skip to the time when the user added the note. Expressed in seconds.
Callback returns 2 items, error and data.
Error will indicate if there was any error while notes dialog is opened, otherwise it will return null
-
itemId {String|Number}: unique identifier passed in options -
hasNotes {Boolean}: indicates whether there is at least 1 note associated with itemId -
noteCount {Number}: total number of notes associated with itemId
Example adding note to a video
const options = {
itemId: 'MY_VIDEO_ID',
title: 'Crazy cat jumping over the fence!',
imageUrl: 'https://example.com/image.jpg',
timeIndex: 22
};
const callback = (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!`)
}
}
buildfire.notes.openDialog(options, callback)The app will navigate to the plugin to which the note belongs, and will pass note data through deeplinking.
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
}
});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.
An example of using
onSeekTowith the YouTube API
buildfire.notes.onSeekTo(function (data) {
window.player.seekTo(data.time);
});One more example using different video player
buildfire.notes.onSeekTo(function (data) {
NowPlaying.changeTime(data.time);
});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.
-
itemId {String|Number}: unique identifier
-
itemId {String|Number}: unique identifier passed in options -
hasNotes {Boolean}: indicates whether there is at least 1 note associated with itemId -
noteCount {Number}: number of notes associated with itemId
const options = {
itemId: 'MY_VIDEO_ID',
};
const callback = (err, data) => {
if(err) return console.error(err);
console.log(data)
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!`)
}
}
buildfire.notes.getByItemId(options, callback)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.