Skip to content

BuildFire Push Notifications API

chris edited this page May 19, 2021 · 10 revisions

⚠️⚠️⚠️

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

⚠️⚠️⚠️

buildfire.notifications.pushNotification

This is a built-in API that allows your control or widget to schedule push notifications to be sent out to devices. If you wish to schedule a Notification to be sent to the device you are currently on use Local Notifications.

This service requires you to include buildfire/services/notifications/pushNotifications.js with your plugin

Control: <script src="../../../../scripts/buildfire/services/notifications/pushNotifications.js"></script>

Widget: <script src="../../../scripts/buildfire/services/notifications/pushNotifications.js"></script>

Running Example: https://github.com/BuildFire/simpleBuildFireJSExamples/blob/master/examplePushNotifications/widget/index.html

Methods

schedule(options, callback): use to schedule a push notification

  • options: object
    • title: string, A short string describing the purpose of the notification
    • text: string, The text of the alert message
    • inAppMessage: string (optional), The html text of the message in the app
    • at: Date (optional), representing the time to send the push notification.
    • users: array of usersIds (optional), send the push notification to specific users
    • userTags: array of tags (optional), send the push notification to specific user tags
    • groupName: string (optional),send the push notification to specific group
    • queryString: string (optional), will be added to the plugin when the push notification triggers the plugin to open
    • sendToSelf: boolean (optional), defaults to true. If false, the device generating the notification will not recieve it
  • callback(err, data): callback function after the push notification scheduling is completed. Data contains an id property, which is the id of the newly scheduled push notification.

Example

buildfire.notifications.pushNotification.schedule({
        title:"You got kicked off !!!"
        ,text:"Your old score is no longer on the top 10. Honestly, I dont know how you sleep at night."
        ,at:new Date()
        },function(e){
             if(e) console.error(e); 
});

cancel(id, callback): use to cancel a scheduled push notification

  • id: string, the id of the notification that you wish to cancel
  • callback(err, result): callback function after the push notification cancelling is completed.

Example

buildfire.notifications.pushNotification.cancel('3333',function(e){
             if(e) console.error(e);
});

subscribe(options, callback): use to subscribe current user to group.

  • options: object
    • groupName: string (optional), to subscribe current user to specific group
  • callback(err, data): callback function when the subscribtion is completed.
Example
buildfire.notifications.pushNotification.subscribe({groupName:"scoreboard"},function(err){
          if(err)console.error(err);
});

unsubscribe(options, callback): use to unsubscribe current user from group.

  • options: object
    • groupName: string (optional), to unsubscribe current user from specific group
  • callback(err, data): callback function when the unsubscribtion is completed.
Example
buildfire.notifications.pushNotification.unsubscribe({groupName:"scoreboard"},function(err){
          if(err)console.error(err);
});
Clone this wiki locally