Contents

Setup

Start with SDK setup if you haven’t done it already.

Common settings

Handle callbacks

  1. Implement NotixCallbackHandler interface

    Kotlin:

    class CallbackHandler : NotixCallbackHandler {  
        override fun handle(context: Context, callback: NotixCallback) { 
            when (callback) { 
                is NotixCallback.Impression -> Log.i(APP_TAG, callback.toString()) 
                is NotixCallback.Subscription -> Log.i(APP_TAG, callback.toString())
                else -> Unit 
            }
        }
    }  
    

    Java:

    class CallbackHandler implements NotixCallbackHandler {
        @Override
        public void handle(@NonNull Context context, @NonNull NotixCallback callback) {
            /* ... */
        }
    }
    
  2. And register it by calling

    Kotlin:

    Notix.setCallbackHandler(CallbackHandler()) 
    

    Java:

    Notix.Companion.setCallbackHandler(new CallbackHandler());
    

Managing logs

You can manage logging done by SDK.

Kotlin:

Notix.setLogLevel(FULL) // can be FULL/IMPORTANT/NONE

Java:

Notix.Companion.setLogLevel(LogLevel.FULL); // can be FULL/IMPORTANT/NONE

Log level is set to IMPORTANT by default.

Push notifications

For setup instructions see Push notifications setup

Audiences

You can manage user audiences

Kotlin:

NotixPush.addAudience("custom-audience")  
NotixPush.deleteAudience("custom-audience")  

Java:

NotixPush.Companion.addAudience("custom-audience");
NotixPush.Companion.deleteAudience("custom-audience");

Modify incoming push messages

You can modify the content of incoming push messages.

  1. Implement NotixNotificationModifier interface

    Kotlin:

    class NotificationModifier : NotixNotificationModifier {  
        override fun modify(context: Context, notificationOverrides: NotificationOverrides) =  
            notificationOverrides
    }
    

    Java:

    class NotificationModifier implements NotixNotificationModifier {
        @Nullable
        @Override
        public NotificationOverrides modify(@NonNull Context context, @NonNull NotificationOverrides notificationOverrides) {
            return notificationOverrides;
        }
    }
    
  2. And register it by calling:

    Kotlin:

    NotixPush.setNotificationModifier(NotificationModifier())
    

    Java:

    NotixPush.Companion.setNotificationModifier(new NotificationModifier());
    

Handle Target Events

  1. Implement NotixTargetEventHandler interface

    Kotlin:

    class TargetEventHandler : NotixTargetEventHandler {  
        override fun handle(context: Context, eventName: String?) {  
            val activityClass = when (eventName) {  
                "first" -> FirstActivity::class.java
                "second" -> SecondActivity::class.java
                else -> OtherActivity::class.java
            }  
            context.startActivity(Intent(context, activityClass))  
        }  
    } 
    

    Java:

    class TargetEventHandler implements NotixTargetEventHandler {
        @Override
        public void handle(@NonNull Context context, @Nullable String eventName) {
            Log.i("TAG", eventName);
        }
    }
    
  2. And register it by calling:

    Kotlin:

    NotixPush.setTargetEventHandler(TargetEventHandler())
    

    Java:

    NotixPush.Companion.setTargetEventHandler(new TargetEventHandler());
    

Interstitial

For setup instructions see Interstitial setup

InterstitialLoader

InterstitialLoaders were introduced to make it easier for a developer to deal with threading, loading, caching, and error handling when loading interstitial ads.

You can get an Interstitial from InterstitialLoader using one of 3 methods: * hasNext/getNext is the simplest method. These functions work only with cached items and are fast. * awaitNext is a suspend function, which accepts timeout. If the loader has at least one entry in the queue, it will immediately return it. Otherwise it will continue trying to fetch an ad for another timeoutms, and will return an Error if that timeout is exceeded (which is very unlikely). * doOnNextAvailable is the callback-way, which is Java-friendly. It works in the same way as awaitNext.

AppOpen

For setup instructions see AppOpen setup

Ignore some application opens

The SDK monitors the lifecycle of all application activities to identify closures and reopens. However, it cannot inherently identify when the application launches external activities. For instance, opening a file picker effectively stops all application activities. Consequently, displaying an AppOpen ad upon returning from the file picker would not be advisable. To address this issue, the following method was introduced:

NotixAppOpen.ignoreNextApplicationOpen()`.

You should call this method whenever you wish to prevent an ad from being shown upon next app reopen.

Show AppOpen ads manually

At the show site get AppOpen instance from the loader and pass it to NotixAppOpen.show:

Kotlin:

App.appOpenLoader.doOnNextAvailable { result -> 
    result?.let { NotixAppOpen.show(it) }
}

Java:

App.appOpenLoader.doOnNextAvailable(result -> {
    if (result != null) {
        NotixAppOpen.Companion.show(result);
    }
    return Unit.INSTANCE;
});

doOnApplicationOpen

For enhanced flexibility in displaying AppOpen ads, including options like delays, error handling, and custom conditions, you can leverage the NotixAppOpen.doOnApplicationOpen() helper method along with its available overloads. It is particularly useful when combined with the manual display of AppOpen ads, as detailed in the preceding section on manually displaying AppOpen ads