SDK

Customizations

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

Setting keys in code

Instead of relying on the Application Key and Application Secret in Notificare.plist, it is possible to set these in code while initializing:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    ...more code

    [[NotificarePushLib shared] initializeWithKey:@"xxx" andSecret:@"xxx"];
    [[NotificarePushLib shared] setDelegate:self];
    [[NotificarePushLib shared] launch];


    ...more code
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    ...more code

    NotificarePushLib.shared().initialize(withKey: "xxx", andSecret: "xxx")
    NotificarePushLib.shared().delegate = self
    NotificarePushLib.shared().launch()

    ...more code
}

These methods should be called before instantiating our library, in order to make sure the correct keys are used.

Library Options

The Notificare.plist is used by the library for setup and customization. It allows you to change the colours of the notifications' user interface or enable/disable certain functionality. By default we provide a colour scheme for some of our UI elements that might not match your app's look and feel and using the options below, you will be able to change that look & feel. Open you Notificare.plist and change the following properties if needed.

tvos notificare plist 2 3

Localizable Texts

Our library ships with a default theme that can be customized if needed. Inside the DefaultTheme.bundle you will find several localizable folders that contain all the texts used in the library. Your free to change those texts to match your needs and even add new languages if needed.

ios localizable texts

Non-Managed Implementation

Our library by default will override all the necessary App Delegate methods and manage it for you. You can (in case you using Swift you will need to) disable this behaviour by setting the DISABLE_APP_DELEGATE_PROXY property to YES in the Notificare.plist under the OPTIONS object. Once you disable it, you will need to implement additional App Delegate methods as described below:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [[NotificarePushLib shared] initializeWithKey:nil andSecret:nil];
    [[NotificarePushLib shared] setDelegate:self];
    [[NotificarePushLib shared] launch];
    [[NotificarePushLib shared] didFinishLaunchingWithOptions:launchOptions];
}

- (void)notificarePushLib:(NotificarePushLib *)library onReady:(nonnull NotificareApplication *)application {
    //If you want to register for remote notifications here it's safe to do it
    //You might want to consider calling this in response to a button in your on-boarding screen or some other place else
    [[NotificarePushLib shared] registerForNotifications];

}

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(nonnull NSData *)deviceToken {
    [[NotificarePushLib shared] didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler {
    [[NotificarePushLib shared] didReceiveRemoteNotification:userInfo completionHandler:^(id  _Nullable response, NSError * _Nullable error) {
        if (!error) {
            completionHandler(UIBackgroundFetchResultNewData);
        } else {
            completionHandler(UIBackgroundFetchResultNoData);
        }
    }];
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
    NotificarePushLib.shared().initialize(withKey: nil, andSecret: nil)
    NotificarePushLib.shared().delegate = self
    NotificarePushLib.shared().launch()
    NotificarePushLib.shared().didFinishLaunching(withOptions: launchOptions)
}

func notificarePushLib(_ library: NotificarePushLib, onReady application: NotificareApplication) {
    //If you want to register for remote notifications here it's safe to do it
    //You might want to consider calling this in response to a button in your on-boarding screen or some other place else
    NotificarePushLib.shared().registerForNotifications()
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    NotificarePushLib.shared().didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    NotificarePushLib.shared().didReceiveRemoteNotification(userInfo, completionHandler: {(_ response: Any?, _ error: Error?) -> Void in
        if error == nil {
            completionHandler(.newData)
        } else {
            completionHandler(.noData)
        }
    })
}

After implementing these methods, make sure you also review the implementation guides located here.