An optional Javascript object that can contain other configuration parameters and any platform specific configuration parameters to be set if needed.
onymosNotification.register
To register the device to receive app notifications. This function is called to register the application to receive app notifications. This is function is typically invoked when application starts up and is ready after user authentication.
OnymosNotification.register(
registerObject,
(message) => {
console.log(message);
},
(error) => {
console.log(error);
}
);
Object
A JavaScript object with the userId of the logged-in user. If you are using the Onymos Access component with this app, you can pass @AUTHID@
as the userId which will automatically use the logged-in user’s User Id.
Usage Example:
{
userId: ‘@AUTHID@’,
}
0r
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
}
onymosNotification.unregister
To stop receiving notifications on the device for your application.
OnymosNotification.unregister(
userId,
(message) => {
console.log(message);
},
(error) => {
console.log(error);
}
);
String
The user id of the logged-in user. If you are using the Onymos Access component with this app, you can pass ‘@AUTHID@’ as the userId which will automatically use the logged-in user’s User Id.
Usage Example:
{
userId: ‘@AUTHID@’,
}
0r
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
}
onymosNotification.receive
To set a callback function to receive notification messages. This function is called to register an application callback function which is called every time a notification message is available for the application.
OnymosNotification.receive(
(notificationData) => {
console.log("App notification received");
handleAppNotification(notificationData);
}
);
Object
Contains the notification details
{
// foreground – true or false; indicates if the application was running and in foreground when the notification was received
foreground: true/false,
// coldstart – true or false; indicates if the application was not running when the notification was received
coldstart: true/false,
// the application payload that was sent with the notification
‘payload’: {
}
}
onymosNotification.notify
To notify other user(s). This function is called to send a message to one or more application users.
OnymosNotification.notify(
sender,
recipients,
message,
(status) => {
console.log(status);
},
(error) => {
console.log(error);
},
payload,
options
);
Object
A JavaScript object with the userId of the logged-in user. If you are using the Onymos Access component with this app, you can pass ‘@AUTHID@’ as the userId which will automatically use the logged-in user’s User Id.
Usage Example:
{
userId: ‘@AUTHID@’,
}
or
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
}
Object []
A list of JavaScript objects that represent the user ids of the users to receive the message.
Usage Example:
[{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
}]
String
The notification message to be sent.
Object
A JavaScript object that can contain any application specific data to be transmitted with the message. This object is transmitted along with the message and is available in the event handler for notifications. This is typically used for information that the application would need to take further actions after displaying the message, for example: the route to the page to navigate to when the user opens the message.
Object
{
expiry: ”,
iosSound: ‘default’,
androidSound: ‘default’
}
String
Time after which the notification will expire.
String
Name of iOS sound to be played when the notification is displayed. This name is specific to the iOS platform.
String
Name of Android sound to be played when the notification is displayed. This name is specific to the Android platform.
onymosNotification.getApplicationBadgeNumber
To get the badge number set for the application icon. This function is called anytime the application needs to know the number that is displayed as the application badge.
OnymosNotification.getApplicationBadgeNumber(
(badgeNumber) => {
console.log("Number of messages shown in badge: " + badgeNumber);
},
(error) => {
console.log(error);
}
);
onymosNotification.setApplicationBadgeNumber
To set the number displayed as a badge on the application icon. This function would typically be used after receiving a notification to update the user interface, for example: set the number remaining number of messages to be read in an incoming message list.
OnymosNotification.setApplicationBadgeNumber(this.numOfUnreadArticles);
onymosNotification.clearAllNotifications
To remove all application notifications from the device notification list and clear the application badge count.
OnymosNotification.clearAllNotifications();
Think differently about app development
Download our free white paper today to learn how Onymos Features can maximize the value of your developer resources — and shave weeks or months off your development timeline.