SDK

Customizations

In this page we'll dive deeper into several aspects of our iOS library that can be customized to match your needs.

Setting keys in code

Instead of relying on the NotificareServices.plist configuration file, it is possible to set those in code. To configure Notificare, you must run the following code before any other interactions with the library.

Notificare.shared.configure(
    servicesInfo: NotificareServicesInfo(
        applicationKey: "",
        applicationSecret: ""
    ),
    options: nil
)

The configure() method should be called before calling Notificare.shared.launch() to make sure the correct keys are used. After setting the keys programmatically you can safely delete the NotificareServices.plist file.

Additionally, you need to let Notificare know to not configure itself after the application has been launched. To do that, you can set AUTO_CONFIG to NO in your NotificareOptions.plist.

Disabling crash reporting

By default, our library sends crash reports to our servers, which you can access via the Dashboard > Your App > Events > Application Error, in order to facilitate the debugging process for developers. If you would like to opt-out, you can do so by setting CRASH_REPORTING_ENABLED to NO in your NotificareOptions.plist.

<plist version="1.0">
<dict>
	<key>CRASH_REPORTING_ENABLED</key>
	<false/>
</dict>
</plist>

Disable UNUserNotificationCenter delegate

Our library, by default, will assign itself as the delegate for the UNUserNotificationCenter, automatically handling all the implementation for you. If you do want a different behaviour, you can disable it and implement it yourself in your app. This is done by setting the USER_NOTIFICATION_CENTER_DELEGATE_ENABLED property to NO in the NotificareOptions.plist. Once you disable it, you will need to implement the following methods:

extension AppDelegate: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        // More code ...

        // Pass the event to Notificare.
        NotificarePush.shared.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        // More code ...

        // Pass the event to Notificare.
        NotificarePush.shared.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
        // More code ...

        // Pass the event to Notificare.
        NotificarePush.shared.userNotificationCenter(center, openSettingsFor: notification)
    }
}