Onymos Raises $12M Series A: Learn why

onymos-logo

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.

function onUserLoggedIn() {
// user logged in initializations/setup
// …
OnymosNotification.register(
registerObject,
function registerSuccess(message) {
console.log(message);
},
function registerFailure(error) {
console.log(error);
}
);
} /* end function */
registerObject

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.

function onUserLogout() {
OnymosNotification.unregister(
userId,
function registerSuccess(message) {
console.log(message);
},
function registerFailure(error) {
console.log(error);
}
);
} /* end function */
userID

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.

function onUserLogin() {
OnymosNotification.receive(function (notificationData) {
console.log("App notification received");
handleAppNotification(notificationData);
});
} /* end function */
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.notifyUser

To notify other user(s). This function is called to send a message to one or more application users.

function notifyUser() {
OnymosNotification.notify(
sender,
recipients,
message,
function onymosNotifySuccess (status) {
console.log(status);
},
function onymosNotifyFailure (error) {
console.log(error);
},
payload,
options
);
/* end function */
sender

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’,
}
recipients

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’,

}

]

message

String

The notification message to be sent.

payload

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.

options

Object

An optional Javascript object that can contain other configuration parameters and any platform specific configuration parameters to be set if needed.

{

expiry: ”,

iosSound: ‘default’,

androidSound: ‘default’

}

expiry

String

Time after which the notification will expire.

iosSound

String

Name of iOS sound to be played when the notification is displayed. This name is specific to the iOS platform.

androidSound

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.getApplicationIconNumber(
function successCallback(badgeNumber) {
console.log("Number of messages shown in badge: " + badgeNumber);

},
function failureCallback(error) {
console.log(error);
}
);
/* end function */

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.

    onHandleNotification() {
OnymosNotification.setApplicationBadgeNumber(this.numOfUnreadArticles);
}
/* end function */

onymosNotification.clearAllNotifications

To remove all application notifications from the device notification list and clear the application badge count.

    onHandleNotification() {
OnymosNotification.clearAllNotifications();
}
/* end function */

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 days or weeks off your development timeline.

Get your free white paper