resolveDefaultDistributor
Resolve default distributor using the deeplink "unifiedpush://link"
When the user has a default or a single distributor, it returns ResolvedDistributor.Found, and tryUseDefaultDistributor is transparent to the user.
When the user has many distributors but hasn't selected a default yet, it returns ResolvedDistributor.ToSelect, and tryUseDefaultDistributor will open an OS screen to select one.
Informing the user about the incoming OS screen helps them to understand why they are selecting an application. The OS dialog can't have a custom title or message, and we need the OS dialog to define a default distributor.
when (val res = UnifiedPush.resolveDefaultDistributor(this)) {
is ResolvedDistributor.Found -> {
// The user don't have to interact. Will be the case most of the time,
// if the user has a default or a single distributor installed
UnifiedPush.saveDistributor(this, res.packageName)
UnifiedPush.register(this)
}
ResolvedDistributor.ToSelect -> {
// Use your own dialog before running tryUseDefaultDistributor
showDialogBeforeSelection(this)
}
ResolvedDistributor.NoneAvailable -> {
// fallback to another solution
}
}Content copied to clipboard