IWebinarsListener

Interface defining callbacks for handling events related to Webinars within the SDK.

Implement this interface to receive notifications about webinar events such as list changed, go on stage requested, and other webinar-related activities.

Samples

import android.Manifest
import android.annotation.SuppressLint
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import androidx.core.content.PermissionChecker
import com.ale.R
import com.ale.infra.contact.IRainbowContact
import com.ale.infra.manager.IMMessage
import com.ale.infra.manager.channel.Channel
import com.ale.infra.manager.channel.ChannelItem
import com.ale.infra.proxy.conversation.IRainbowConversation
import com.ale.rainbowsdk.Channels
import com.ale.rainbowsdk.Im
import com.ale.rainbowsdk.Infrastructure
import com.ale.rainbowsdk.RainbowSdk
fun main() { 
   //sampleStart 
   class NotificationsSample(private val applicationContext: Context) : Channels.IChannelsListener, Im.IRainbowImListener {

    private val sampleChannelID = "SAMPLE_CHANNEL_ID"
    private val channelGroupID = "CHANNEL_GROUP_ID"

    private val sampleMessageID = "SAMPLE_MESSAGE_ID"
    private val messageGroup = "MESSAGE_GROUP_ID"


    @RequiresApi(Build.VERSION_CODES.O)
    fun start() {
        val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?
        notificationManager?.createNotificationChannel(NotificationChannel(sampleChannelID, "Default notification", NotificationManager.IMPORTANCE_DEFAULT))
        RainbowSdk().channels().registerChannelsListener(this)
        RainbowSdk().im().registerListener(this)
    }

    fun stop() {
        RainbowSdk().channels().unregisterChannelsListener(this)
        RainbowSdk().im().unregisterListener(this)
    }

    // Display notifications when a channel message is received
    @SuppressLint("MissingPermission")
    override fun notifyChannelMessage(channelItem: ChannelItem, channel: Channel) {
        val contactName = channelItem.contact?.getDisplayName("Unknown") ?: "Unknown"
        val text = "$contactName has published a new message in the channel"

        val notification = NotificationCompat.Builder(applicationContext, sampleChannelID)
            .setGroup(channelGroupID)
            .setSmallIcon(R.drawable.subscribed)
            .setColor(ContextCompat.getColor(applicationContext, R.color.blue_rainbow))
            .setAutoCancel(true)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setDefaults(NotificationCompat.DEFAULT_LIGHTS)
            .setContentTitle(channel.name)
            .setContentText(text)
            .build()

        // Check whether the notifications permissions have been accepted
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || PermissionChecker.checkSelfPermission(applicationContext, Manifest.permission.POST_NOTIFICATIONS) == PermissionChecker.PERMISSION_GRANTED) {
            NotificationManagerCompat.from(applicationContext).notify(channel.id.hashCode(), notification)
        }
    }

    @SuppressLint("MissingPermission")
    override fun onImReceived(conversation: IRainbowConversation, message: IMMessage?) {
        if (message == null) return

        val contact = RainbowSdk().contacts().getContactFromJid(message.contactJid) ?: return

        val notification = NotificationCompat.Builder(applicationContext, sampleMessageID)
            .setGroup(messageGroup)
            .setSmallIcon(R.drawable.subscribed)
            .setColor(ContextCompat.getColor(applicationContext, R.color.blue_rainbow))
            .setAutoCancel(true)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setDefaults(NotificationCompat.DEFAULT_LIGHTS)
            .setContentTitle(contact.getDisplayName("Unknown"))
            .setContentText(message.messageContent)
            .build()

        // Check whether the notifications permissions have been accepted
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || PermissionChecker.checkSelfPermission(applicationContext, Manifest.permission.POST_NOTIFICATIONS) == PermissionChecker.PERMISSION_GRANTED) {
            NotificationManagerCompat.from(applicationContext).notify(conversation.id.hashCode(), notification)
        }
    }

    @SuppressLint("MissingPermission")
    override fun notifyNewMessageWithApplicationStopped(conversation: IRainbowConversation, contact: IRainbowContact, message: IMMessage) {
        val notification = NotificationCompat.Builder(applicationContext, sampleMessageID)
            .setGroup(messageGroup)
            .setSmallIcon(R.drawable.subscribed)
            .setColor(ContextCompat.getColor(applicationContext, R.color.blue_rainbow))
            .setAutoCancel(true)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setDefaults(NotificationCompat.DEFAULT_LIGHTS)
            .setContentTitle(contact.getDisplayName("Unknown"))
            .setContentText(message.messageContent)
            .build()

        // Check whether the notifications permissions have been accepted
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || PermissionChecker.checkSelfPermission(applicationContext, Manifest.permission.POST_NOTIFICATIONS) == PermissionChecker.PERMISSION_GRANTED) {
            NotificationManagerCompat.from(applicationContext).notify(conversation.id.hashCode(), notification)
        }
    }
} 
   //sampleEnd
}

Functions

Link copied to clipboard
open fun notifyGoOnStageCanceled(room: IRainbowRoom)

Invoked when a webinar organizer cancels the request for the user to go on stage.

Link copied to clipboard
open fun notifyGoOnStageRequested(room: IRainbowRoom)

Invoked when a webinar organizer requests the user to go on stage to talk.

Link copied to clipboard
open fun notifyWaitingRoomStarted(webinar: Webinar)

Invoked when the waiting room for a webinar is started.

Link copied to clipboard
open fun notifyWebinarInvitation(webinar: Webinar)

Invoked when an invitation to a webinar is received.

Link copied to clipboard

Invoked when the list of webinars is changed. This event is triggered when webinars are added, removed, or modified. It provides a way to handle updates to the list of webinars collectively.