Notifications

Register for Push Notifications


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

Declared In

SNRClient.h

Method Name

Client.registerForPush(registrationToken:success:failure:)

Declaration

func registerForPush(registrationToken: String, success: ((Bool) -> ()), failure: ((Error) -> ())) -> Void) -> Void

Parameters

Parameter Type Mandatory Default Description
registrationToken String yes - Firebase Token

Return Value

There is no return value.

Example

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
	Client.registerForPush(registrationToken: fcmToken, success: { (_) in
		// success
	}, failure: { (error) in
		// failure
	})
}

Check if Push Notification is from Synerise


Verifies that a notification was sent by Synerise.

Declared In

SNRSynerise.h

Method Name

Synerise.isSyneriseNotification(_:)

Declaration

func isSyneriseNotification(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegate
extension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfolet isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
        if isSyneriseNotification == true {
            // notification is from Synerise
        }
    }
}

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

SNRSynerise.h

Method Name

Synerise.isSyneriseSimplePush(_:)

Declaration

func isSyneriseSimplePush(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegateextension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfolet isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
       	if isSyneriseNotification == true {
			// notification is from Synerise			let isSyneriseSimplePush = Synerise.isSyneriseSimplePush(userInfo)
			if isSyneriseSimplePush == true {
				// notification is Synerise Simple Push Campaign
			}
		}
    }
}

Check if Push Notification is a Banner Campaign


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

Declared In

SNRSynerise.h

Method Name

Synerise.isSyneriseBanner(_:)

Declaration

func isSyneriseBanner(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegateextension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfolet isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
       	if isSyneriseNotification == true {
			// notification is from Synerise			let isSyneriseBanner = Synerise.isSyneriseBanner(userInfo)
			if isSyneriseBanner == true {
				// notification is Synerise Banner Campaign
			}
		}
    }
}

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

SNRSynerise.h

Method Name

Synerise.isSyneriseSilentCommand(_:)

Declaration

func isSyneriseSilentCommand(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegateextension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfolet isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
       	if isSyneriseNotification == true {
			// notification is from Synerise			let isSyneriseSilentCommand = Synerise.isSyneriseSilentCommand(userInfo)
			if isSyneriseSilentCommand == true {
				// notification is Synerise Silent Command
			}
		}
    }
}

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

SNRSynerise.h

Method Name

Synerise.isSyneriseSilentSDKCommand(_:)

Declaration

func isSyneriseSilentSDKCommand(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegate
extension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfo
        let isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
       	if isSyneriseNotification == true {
			// notification is from Synerise			let isSyneriseSilentSDKCommand = Synerise.isSyneriseSilentSDKCommand(userInfo)
			if isSyneriseSilentSDKCommand == true {
				// notification is Synerise Silent SDK Command
			}
		}
    }
}

Check if Push Notification is encrypted


Verifies if a notification is encrypted by Synerise.

Declared In

SNRSynerise.h

Method Name

Synerise.isNotificationEncrypted(_:)

Declaration

func isNotificationEncrypted(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
	let isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
	if isSyneriseNotification == false {
		let isNotificationEncrypted = Synerise.isNotificationEncrypted(userInfo)
		if isNotificationEncrypted == true {
			// Notification is encrypted by Synerise
		}
	}
	//...
}

Decrypt Push Notification


Decrypts notification payload.

Declared In

SNRSynerise.h

Method Name

Synerise.decryptNotification(_:)

Declaration

func decryptNotification(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
	let isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
	if isSyneriseNotification == false {
		let isNotificationEncrypted = Synerise.isNotificationEncrypted(userInfo)
		if isNotificationEncrypted == true {
			// Notification is encrypted by Synerise
			if let userDataDecrypted = Synerise.decryptNotification(userInfo) {
				// Notification decryption process was successful
			}
		}
	}
	//...
}

Handle Synerise Push Notification


Handles the notification payload and starts activity.

Declared In

SNRSynerise.h

Method Name

Synerise.handleNotification(_:)

Declaration

func handleNotification(_ userInfo: [AnyHashable: Any]) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegate
extension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfo
        let isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
       	if isSyneriseNotification == true {
			// notification is from Synerise			Synerise.handleNotification(userInfo)
		}
    }
}

Handle Synerise Push Notification with action


Handles the notification payload, including information about an action performed by a customer, and starts activity.

Declared In

SNRSynerise.h

Method Name

Synerise.handleNotification(_:actionIdentifier:)

Declaration

func handleNotification(_ userInfo: [AnyHashable: Any], actionIdentifier: String) -> Void

Parameters

Parameter Type Mandatory Default Description
userInfo [AnyHashable: Any] no - Key-Value map of data
actionIdentifier String no - Identifier of action received from notification response

Return Value

There is no return value.

Examples

//MARK: - UNUserNotificationCenterDelegate
extension NotificationService: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfolet actionIdentifier = response.actionIdentifier
        let isSyneriseNotification = Synerise.isSyneriseNotification(userInfo)
       	if isSyneriseNotification == true {
			// notification is from Synerise			Synerise.handleNotification(userInfo, actionIdentifier: actionIdentifier)
		}
    }
}
😕

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.