-
Notifications
You must be signed in to change notification settings - Fork 82
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/
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
- 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 totrue
. Iffalse
, 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.
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);
});
-
id
: string, the id of the notification that you wish to cancel -
callback(err, result)
: callback function after the push notification cancelling is completed.
buildfire.notifications.pushNotification.cancel('3333',function(e){
if(e) console.error(e);
});
- options: object
-
groupName
: string (optional), to subscribe current user to specific group
-
-
callback(err, data)
: callback function when the subscribtion is completed.
buildfire.notifications.pushNotification.subscribe({groupName:"scoreboard"},function(err){
if(err)console.error(err);
});
- options: object
-
groupName
: string (optional), to unsubscribe current user from specific group
-
-
callback(err, data)
: callback function when the unsubscribtion is completed.
buildfire.notifications.pushNotification.unsubscribe({groupName:"scoreboard"},function(err){
if(err)console.error(err);
});