Push Notifications


Register for Push Notifications


Use this method to pass the Firebase Token to Synerise for notifications.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.registerForNotifications(registrationToken, mobileAgreement, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
registrationToken string yes - Firebase Token
mobileAgreement boolean yes - Agreement (consent) for mobile push campaigns
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

// If you integrate Firebase Messaging in the native part of app
Synerise.Notifications.setListener({
	onRegistrationToken: function(registrationToken) {
		Synerise.Notifications.registerForNotifications(registrationToken, true, function(){
			//success
		}, function() {
			//failure
		});
	},
	onNotification: function(payload) {
		//...
	}
	//...
	//other listener's methods
});
// Or if you want to use Firebase Messaging in react native
Synerise.Notifications.registerForNotifications("YOUR_FIREBASE_TOKEN", true, function(){
	//success
}, function() {
	//failure
});

Check if Push Notification is from Synerise


Verifies that a notification was sent by Synerise.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.isSyneriseNotification(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Boolean value is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		if (Synerise.Notifications.isSyneriseNotification(payload)) {
			Synerise.Notifications.handleNotification(payload);
		}
	}
	//...
	//other listener's methods
});

Check if Push Notification is a Simple Push Campaign


Verifies that a notification was sent by Synerise and that it’s a Simple Push.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.isSyneriseSimplePush(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Boolean value is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		if (Synerise.Notifications.isSyneriseSimplePush(payload)) {
			Synerise.Notifications.handleNotification(payload);
		}
	}
	//...
	//other listener's methods
});

Check if Push Notification is a Banner Campaign


Verifies that a notification was sent by Synerise and that it’s a Banner.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.isSyneriseBanner(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Boolean value is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		if (Synerise.Notifications.isSyneriseBanner(payload)) {
			Synerise.Notifications.handleNotification(payload);
		}
	}
	//...
	//other listener's methods
});

Check if Push Notification is a Silent Command


Verifies that a notification was sent by Synerise and that it’s a Silent Command.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.isSilentCommand(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Boolean value is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		if (Synerise.Notifications.isSilentCommand(payload)) {
			Synerise.Notifications.handleNotification(payload);
		}
	}
	//...
	//other listener's methods
});

Check if Push Notification is a Silent SDK Command


Verifies that a notification was sent by Synerise and that it’s a Silent SDK Command.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.isSilentSDKCommand(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Boolean value is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		if (Synerise.Notifications.isSilentSDKCommand(payload)) {
			Synerise.Notifications.handleNotification(payload);
		}
	}
	//...
	//other listener's methods
});

Check if Push Notification is encrypted


Verifies if a notification is encrypted.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.isNotificationEncrypted(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Boolean is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		if (Synerise.Notifications.isNotificationEncrypted(payload)) {
			Synerise.Notifications.decryptNotification(payload);
		}
	}
	//...
	//other listener's methods
});

Decrypt Notification


Decrypts the notification payload.
If the payload is not encrypted, the method returns raw payload.
The method returns null if the crypter fails while decrypting the payload.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.decryptNotification(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

Key-value data object is returned.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		let data = Synerise.Notifications.decryptNotification(payload)
		// custom notification implementation
	}
	//...
	//other listener's methods
});

Handle Synerise Push Notification


Handles the notification payload and starts activity.

Declared In

lib/main/modules/NotificationsModule.js

Method

Synerise.Notifications.handleNotification(payload)

Parameters

Parameter Type Mandatory Default Description
payload object no - Notification’s key-value data object

Return Value

There is no return value.

Example

Synerise.Notifications.setListener({
	onNotification: function(payload) {
		Synerise.Notifications.handleNotification(payload);
	}
	//...
	//other listener's methods
});
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.