Channels for the Android SDK
Access and manage channel IDs, listen for channel creation, and configure the channel capture tool.
Each device or app install generates a unique identifier known as the Channel ID. Once a Channel ID is created, it persists in the application until the app is reinstalled or its internal data is cleared.
For information about finding Channel IDs, using the Channel Capture tool, and other methods to access Channel IDs, see Finding Channel IDs.
Accessing the Airship Channel ID
Apps can access the Channel ID directly through the SDK.
Accessing the channel ID
val channelId = Airship.channel.idString channelId = Airship.getChannel().getId();The SDK creates the Channel ID asynchronously, so it may not be available immediately on the first run. The SDK automatically batches and applies changes to Channel data when the Channel is created, so you do not need to wait for the Channel to be available before modifying data.
Applications that need to access the Channel ID can use a listener to receive notification when it becomes available.
Listening for the Channel ID
Using channelIdFlow (StateFlow):
// channelIdFlow is a StateFlow<String?> that emits the channel ID when it's created
scope.launch {
Airship.channel.channelIdFlow.collect { channelId ->
channelId?.let {
Log.d("Sample", "Channel created: $it")
}
}
}Using addChannelListener:
Airship.channel.addChannelListener { channelId ->
Log.d("Sample", "Channel created: $channelId")
}Using addChannelListener:
Airship.getChannel().addChannelListener(new AirshipChannelListener() {
@Override
public void onChannelCreated(@NonNull String channelId) {
// created
}
});Channel Capture tool
The Channel Capture tool is a feature built into the SDK that helps users find their Channel ID. For detailed information about how it works and how to use it, see Finding Channel IDs.
The Channel Capture tool can be disabled through the Airship Config options passed to takeOff during SDK initialization. For information about setting up the Airship SDK and configuring AirshipConfigOptions, see Android SDK Setup.
Disabling Channel Capture tool
val options = airshipConfigOptions {
// ...
setChannelCaptureEnabled(false)
}AirshipConfigOptions options = AirshipConfigOptions.newBuilder()
// ...
.setChannelCaptureEnabled(false)
.build();Delaying channel creation
Airship creates the channel if at least one feature is enabled in the Privacy Manager. To delay channel creation, use the Privacy Manager to disable all features during initialization.
For more information about Privacy Manager, see Privacy Manager.
Categories