tryUseCurrentOrDefaultDistributor

Try to use the saved distributor else, use the default distributor opening the deeplink "unifiedpush://link"

It can be used on application startup to register to the distributor. If you had already registered to a distributor, this ensures the connection is working. If the previous distributor has been uninstalled, it will fall back to the user's default. If you register for the first time, it will use the user's default Distributor or the OS will ask what it should use.

Before calling this function, you may want to check if getAckDistributor exists and resolve the default distributor with resolveDefaultDistributor, to check if the OS will show a screen to the user. In this case, you can introduce this screen with a dialog "You are about to select your push service"

External distributors will be favored over embedded distributors.

This function starts a new translucent activity in order to get the result of the distributor activity.

Usage

Kotlin:

tryUseCurrentOrDefaultDistributor(activityContext) { success ->
if (success) {
//TODO: register, no need to saveDistributor
}
}

Java:

UnifiedPush.tryUseCurrentOrDefaultDistributor(activityContext, success -> {
if (success) {
//TODO: register, no need to saveDistributor
}
return null;
});

Parameters

activity

Activity Context

callback

is a function taking a Boolean as parameter. This boolean is true if the registration using the deeplink succeeded.