# Custom

If for some reason, you need to implement your own dispatcher, you must create a `BatchEventDispatcher` and register it to the SDK using `Batch.EventDispatcher.addDispatcher(BatchEventDispatcher)`.

{% hint style="info" %}
You don't need to add a dispatcher if you're using one of the previous "ready-to-go" library ! It will be automatically registered.
{% endhint %}

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
class MyKotlinApplication : Application(), BatchEventDispatcher {

    override fun onCreate() {
        super.onCreate()

        Batch.start("MY_API_KEY")
        registerActivityLifecycleCallbacks(BatchActivityLifecycleHelper())

        // [...]

        Batch.EventDispatcher.addDispatcher(this)
    }

    override fun dispatchEvent(type: Batch.EventDispatcher.Type,
                               payload: Batch.EventDispatcher.Payload) {
        Log.d("Dispatcher", "I'm dispatching : " + type.name)
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
public class MyApplication extends Application implements BatchEventDispatcher {
    @Override
    public void onCreate() {
        super.onCreate();

        Batch.start("MY_API_KEY");
        registerActivityLifecycleCallbacks(new BatchActivityLifecycleHelper());
        
        // [...]

        Batch.EventDispatcher.addDispatcher(this); // add the dispatcher at app start
    }

    @Override
    public void dispatchEvent(@NonNull Batch.EventDispatcher.Type type,
                              @NonNull Batch.EventDispatcher.Payload payload) {
    	Log.d("Dispatcher", "I'm dispatching : " + type.name());
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If the Batch SDK happens to be opt-out (from the user or because the SDK is opt-out by default), dispatchers won't receive any events.
{% endhint %}
