Skip to content

How to use Notifications

o5faruk edited this page May 2, 2021 · 25 revisions

⚠️⚠️⚠️

This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/notifications/

⚠️⚠️⚠️

buildfire.notifications

Methods

beep(options, callback):

This function only available on widget section

  • times: The number of times to repeat the beep. (Number)
  • callback(err, data)

vibrate(options, callback):

This function only available on widget section

  • milliseconds: Milliseconds to vibrate the device. (Number). iOS only supports 1000 Milliseconds
  • callback(err, data)

prompt(options, callback):

This function only available on widget section

  • options: object
    • title: string
    • message: string (optional)
    • buttonLabels: Array of strings specifying button labels (Array) (Optional, defaults to ["OK","Cancel"])
    • defaultText: Default textbox input value (String) (Optional, Default: empty string)
  • callback(err, data)

The following section of Notifications API is deprecated. Please use Dialog API.


alert(options, callback) - Deprecated

The alert method displays an alert popup with a specified message and an OK button. An alert popup is often used if you want to make sure information comes through to the user.

  • options: object
    • title: string (optional), by default 'Alert'
    • message: string
    • size: string (optional), by default 'sm', sizes available: sm small popup, md medium popup ,lg large popup
    • okButton: object (optional)
      • text: string (optional), button text, by default the value is Ok
      • key: string (optional), button key, by default the value is ok, to be use in the callback to know what button the user clicked
      • type: string (optional), to be use to show the button style, by default the value is 'primary'. types available: default, primary, success, info, warning, danger
  • callback(err, data): callback function after the end user clicked on button. Data contains the selected button object ex: {selectedButton:{text:"Ok", key:'ok'}}

Example

buildfire.notifications.alert({
        title:"Access Deined"
        ,message:"You don't have the permission to access this section!"
        ,okButton: {text:'Ok'}
        },function(e,data){
             if(e) console.error(e); 
             if(data) console.log(data);
});

confirm(options, callback) - Deprecated

The confirm method displays a confirm popup with a specified message, along with an OK and a Cancel button. A confirm popup is often used if you want the user to verify or accept something.

  • options: object
    • title: string (optional), by default 'Are you sure?'
    • message: string
    • size: string (optional), by default 'sm', sizes available: sm small popup, md medium popup ,lg large popup
    • confirmButton: object (optional)
      • text: string (optional), button text, by default the value is Confirm
      • key: string (optional), button key, by default the value is confirm, to be use in the callback to know what button the user clicked
      • type: string (optional), to be use to show the button style, by default the value is 'primary'. types available: default, primary, success, info, warning, danger
    • cancelButton: object (optional)
      • text: string (optional), button text, by default the value is Cancel
      • key: string (optional), button key, by default the value is cancel, to be use in the callback to know what button the user clicked
      • type: string (optional), to be use to show the button style, by default the value is 'default'. types available: default, primary, success, info, warning, danger
  • callback(err, data): callback function after the end user clicked on button. Data contains the selected button object ex: {selectedButton:{text:"Confirm", key:'confirm'}}

Example

buildfire.notifications.confirm({
        title:"Are you sure?"
        ,message:"Are you sure to delete this record?"
        ,confirmButton: {text: 'Yes', key:'yes', type: 'danger'}
        ,cancelButton: {text: 'No', key:'no', type: 'default'}
        },function(e,data){
             if(e) console.error(e);
             if(data) console.log(data);
});

showDialog(options, callback) - Deprecated

This function only available on Control section of your plugin, The showDialog method displays a popup with a specified title and message. A showDialog popup is used if you want to build a popup with generic buttons.

  • options: object
    • title: string
    • message: string (optional)
    • size: string (optional), by default 'sm', sizes available: sm small popup, md medium popup ,lg large popup
    • buttons: array of objects (optional)
      • text: string
      • key: string, to be use in the callback to know what button the user clicked
      • type: string (optional), to be use to show the button style, by default the value is 'default'. types available: default, primary, success, info, warning, danger
  • callback(err, data): callback function after the end user clicked on button. Data contains the selected button object ex: {selectedButton:{text:"button text", key:'button key'}}

Example

buildfire.notifications.showDialog({
        title:"options available"
        ,message:"Please select the t-shirt size"
        ,buttons: [{text: 'Small', key:'small', type: 'default'}, {text: 'Medium', key:'medium', type: 'default'}, {text: 'Large', key:'large', type: 'default'}]
        },function(e,data){
             if(e) console.error(e);
             if(data) console.log(data);
});

Advanced

Clone this wiki locally