Campaigns

Add campaigns to video, chat, scheduled, or virtual agent views. First request the campaign, then use the target campaign as an entry, and finally start the callback.

Get campaigns

Use the API defined in the ZoomCCInterface class to retrieve campaigns using a specific API key APP_CAMPAIGN_API_KEY.

Get the APP_CAMPAIGN_API_KEY value from your Contact Center admin, who can find this at Campaign Management > Web and In-App > </>Embed Web Tag.

[[ZoomCCInterface sharedInstance] getCampaigns:APP_CAMPAIGN_API_KEY complete:^(_Bool success, NSArray <ZoomCCCampaignInfo *>* _Nullable campaigns) {
    if (!success || !campaigns.count) {
        return;
    }
    // choose one campaignInfo
    campaignInfo = campaigns.firstObject;
}];
ZoomCCInterface.sharedInstance().getCampaigns(APP_CAMPAIGN_API_KEY) {
    [weak self] success, campaigns in
    guard let self = self, success, !campaigns.isEmpty else { return }
    // choose one campaignInfo
    let campaignInfo = campaigns.first
}

Use the target campaign as an entry

After fetching all the campaigns, choose one ZoomCCCampaignInfo:campaignInfo and use it as an entry to the chat, video, virtual agent, or scheduled callback channel.

The campaignInfo's translatedCampaignChannels property is an array that contains all channel types. The value is either ZoomCCIInterfaceType_Chat, ZoomCCIInterfaceType_Video, ZoomCCIInterfaceType_ZVA, or ZoomCCIInterfaceType_ScheduledCallback.

// all available campaignChannels
for (campaignChannel in campaignInfo.translatedCampaignChannels.integerValue) {
    switch (campaignChannel) {
        case ZoomCCIInterfaceType_Chat:
        {
            [self showChat:campaignInfo];
        }
            break;
        case ZoomCCIInterfaceType_ZVA:
        {
            [self showZVA:campaignInfo];
        }
            break;
        case ZoomCCIInterfaceType_Video:
        {
            [self showVideo:campaignInfo];
        }
            break;
        case ZoomCCIInterfaceType_ScheduledCallback:
        {
            [self showScheduledCallbacks:campaignInfo];
        }
            break;
        default:
            break;
    }
}
for campaignChannel in campaignInfo.translatedCampaignChannels as? [ZoomCCIInterfaceType] ?? [] {
    switch campaignChannel {
        case .chat:
            self.showChat(campaignInfo)
        case .ZVA:
            self.showZVA(campaignInfo)
        case .video:
            self.showVideo(campaignInfo)
        case .scheduledCallback:
            self.showScheduledCallbacks(campaignInfo)
        default:
            break
    }
}

Start the chat, video, scheduled, or virtual agent callbacks

Show the chat view in the campaign mode

  1. Create a ZoomCCItem class instance.
  2. Set the item's sdkType to ZoomCCIInterfaceType_Chat.
  3. Set the item's apiKey to APP_CAMPAIGN_API_KEY.
  4. Set the item's useCampaignMode property to YES.
  5. Set the item's campaignInfo property to campaignInfo.
  6. Get chatService and end the previously chatService if needed.
  7. Set the chatService's chatDelegate.
  8. Initialize chatService with the item previously created and login with chatService if its status is ZoomCCSDKStatus_Initial.
  9. Fetch and show the chat view using chatService's fetchUI API.
/// demo code to initialize the chat service and show the chat view in the Campaign mode.
- (void)showChat:(ZoomCCCampaignInfo *)campaignInfo {
    /**
     First, create a ZoomCCItem class instance. This determines the channel (chat, video, ZVA) to use. For the chat service, set the sdkType property to ZoomCCIInterfaceType_Chat. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    ZoomCCItem *item = [ZoomCCItem new];
    item.sdkType = ZoomCCIInterfaceType_Chat;
    item.apiKey = APP_CAMPAIGN_API_KEY;
    item.useCampaignMode = YES;
    item.campaignInfo = campaignInfo;
    /**
     Second, fetch the chat service instance, then set its delegate, This delegate receives callbacks from ZoomCCSDK. When the service status is ZoomCCSDKStatus_Initial, initialize the chat service by calling the "initializeWithItem:" and "login" functions. After that, the internal service will connect to the server to fetch information, letting us send and receive messages from the server.
     As only one id<ZoomCCChatService> can exsist at the same time, if the current chatService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the chat in use, or to end it. Below code shows the end logic.
     */
    id<ZoomCCChatService> chatService = [[ZoomCCInterface sharedInstance] chatService];
    ZoomCCItem *previousItem = chatService.item;
    if ((!previousItem.useCampaignMode && previousItem.entryId.length)
        || (previousItem.useCampaignMode && ![previousItem.campaignInfo isEqual:campaignInfo])) {
        [chatService endChat];
        chatService = [[ZoomCCInterface sharedInstance] chatService];
    }
    chatService.chatDelegate = self;
    if (chatService.status == ZoomCCSDKStatus_Initial) {
        [chatService initializeWithItem:item];
        [chatService login];
    }
    /**
     Finally, to show the chat view, call the function below. Inside the call back, get the view's instance, then show it.
     */
    __weak typeof(self) wself = self;
    [chatService fetchUI:^(UIViewController * _Nonnull viewController) {
        [wself directShow:viewController];
    }];
}
/// demo code to initialize the chat service and show the chat view in the Campaign mode.
func showChat(_ campaignInfo: ZoomCCCampaignInfo) {
    /**
     First, create a ZoomCCItem class instance. This determines the channel (chat, video, ZVA) to use. For the chat service, set the sdkType property to ZoomCCIInterfaceType_Chat. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    let item = ZoomCCItem()
    item.sdkType = .chat
    item.apiKey = APP_CAMPAIGN_API_KEY
    item.useCampaignMode = true
    item.campaignInfo = campaignInfo
    /**
     Second, fetch the chat service instance, then set its delegate, This delegate receives callbacks from ZoomCCSDK. When the service status is ZoomCCSDKStatus_Initial, initialize the chat service by calling the "initializeWithItem:" and "login" functions. After that, the internal service will connect to the server to fetch information, letting us send and receive messages from the server.
     As only one id<ZoomCCChatService> can exsist at the same time, if the current chatService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the chat in use, or to end it. Below code shows the end logic.
     */
    var chatService = ZoomCCInterface.sharedInstance().chatService()
    let previousItem = chatService.item
    if ((!previousItem.useCampaignMode && !previousItem.entryId.isEmpty) ||
        (previousItem.useCampaignMode && previousItem.campaignInfo != campaignInfo)) {
        chatService.endChat()
        chatService = ZoomCCInterface.sharedInstance().chatService()
    }
    chatService.chatDelegate = self
    if chatService.status == .initial {
        chatService.initialize(with: item)
        chatService.login()
    }
    /**
     Finally, to show the chat view, call the function below. Inside the call back, get the view's instance, then show it.
     */
    chatService.fetchUI { [weak self] viewController in
        self?.directShow(viewController)
    }
}

Show the virtual agent chat view in the campaign mode

  1. Create a ZoomCCItem class instance.
  2. Set the item's sdkType to ZoomCCIINterfaceType_ZVA.
  3. Set the item's apiKey to APP_CAMPAIGN_API_KEY.
  4. Set the item's useCampaignMode property to YES.
  5. Set the item's campaignInfo property to campaignInfo.
  6. Set the zvaService and end the previous zvaService if needed.
  7. Set zvaService's chatDelegate.
  8. initialize zvaService with the item previously created and login with zvaService if its status is ZoomCCSDKStatus_Initial.
  9. Fetch and show the virtual agent view using zvaService's fetchUI API.
/// demo code to initialize the chat service and show the zva chat view in the Campaign mode.
- (void)showZVA:(ZoomCCCampaignInfo *)campaignInfo  {
    /**
     First, create a ZoomCCItem class instance. This determines the channel (chat, video, ZVA) to use. For ZVA, set the sdkType property to ZoomCCIInterfaceType_ZVA. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    ZoomCCItem *item = [ZoomCCItem new];
    item.apiKey = APP_CAMPAIGN_API_KEY;
    item.useCampaignMode = YES;
    item.campaignInfo = campaignInfo;
    item.sdkType = ZoomCCIInterfaceType_ZVA;
    /**
     Second, fetch the ZVA service instance, then set its delegate. This delegate receives callbacks from ZoomCCSDK. When the service status is ZoomCCSDKStatus_Initial, initialize the ZVA service by calling the "initializeWithItem:" and "login" functions. After that, the internal service will connect to the server to fetch information, letting us send and receive messages from the server.
     As only one id<ZoomCCChatService> can exsist at the same time, if the current zvaService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the chat in use, or to end it. Below code shows the end logic.
     */
    id<ZoomCCChatService> zvaService = [[ZoomCCInterface sharedInstance] zvaService];
    ZoomCCItem *previousItem = zvaService.item;
    if ((!previousItem.useCampaignMode && previousItem.entryId.length)
        || (previousItem.useCampaignMode && ![previousItem.campaignInfo isEqual:campaignInfo])) {
        [zvaService endChat];
        zvaService = [[ZoomCCInterface sharedInstance] zvaService];
    }
    zvaService.chatDelegate = self;
    if (zvaService.status == ZoomCCSDKStatus_Initial) {
        [zvaService initializeWithItem:item];
        [zvaService login];
    }
    /**
     Finally, to show the ZVA view, call the function below. Inside the call back, get the view's instance, then show it.
     */
    __weak typeof(self) wself = self;
    [zvaService fetchUI:^(UIViewController * _Nonnull viewController) {
        [wself directShow:viewController];
    }];
}
/// demo code to initialize the chat service and show the zva chat view in the Campaign mode.
func showZVA(_ campaignInfo: ZoomCCCampaignInfo) {
    /**
     First, create a ZoomCCItem class instance. This determines the channel (chat, video, ZVA) to use. For ZVA, set the sdkType property to ZoomCCIInterfaceType_ZVA. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    let item = ZoomCCItem()
    item.sdkType = .ZVA
    item.apiKey = APP_CAMPAIGN_API_KEY
    item.useCampaignMode = true
    item.campaignInfo = campaignInfo
    /**
     Second, fetch the ZVA service instance, then set its delegate. This delegate receives callbacks from ZoomCCSDK. When the service status is ZoomCCSDKStatus_Initial, initialize the ZVA service by calling the "initializeWithItem:" and "login" functions. After that, the internal service will connect to the server to fetch information, letting us send and receive messages from the server.
     As only one id<ZoomCCChatService> can exsist at the same time, if the current zvaService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the chat in use, or to end it. Below code shows the end logic.
     */
    var zvaService = ZoomCCInterface.sharedInstance().zvaService()
    let previousItem = zvaService.item
    if ((!previousItem.useCampaignMode && !previousItem.entryId.isEmpty) ||
        (previousItem.useCampaignMode && previousItem.campaignInfo != campaignInfo)) {
        zvaService.endChat()
        zvaService = ZoomCCInterface.sharedInstance().zvaService()
    }
    zvaService.chatDelegate = self
    if zvaService.status == .initial {
        zvaService.initialize(with: item)
        zvaService.login()
    }
    /**
     Finally, to show the ZVA view, call the function below. Inside the call back, get the view's instance, then show it.
     */
    zvaService.fetchUI { [weak self] viewController in
        self?.directShow(viewController)
    }
}

Show the video view in the campaign mode

  1. Create a ZoomCCItem class instance.
  2. Set the item's sdkType to ZoomCCIINterfaceType_Video.
  3. Set the item's apiKey to APP_CAMPAIGN_API_KEY.
  4. Set the item's useCampaignMode property to YES.
  5. Set the item's campaignInfo property tocampaignInfo.
  6. Get videoService and end the previous videoService if needed.
  7. Set the videoDelegate, videoPreviewOptions, and autoJoinWhenVideoCreated properties of videoService.
  8. Initialize videoService with the item previously created if its status is ZoomCCSDKStatus_Initial.
  9. Fetch and show the video view using videoService's fetchUI API.
/// demo code to initialize the chat service and show the video view in the Campaign mode.
- (void)showVideo:(ZoomCCCampaignInfo *)campaignInfo {
    /**
     First, cteate a ZoomCCItem class instance. This  determines the channel(chat, video, ZVA) to use. For the video case, set the sdkType property to ZoomCCIInterfaceType_Video. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    ZoomCCItem *item = [ZoomCCItem new];
    item.sdkType = ZoomCCIInterfaceType_Video;
    item.apiKey = APP_CAMPAIGN_API_KEY;
    item.useCampaignMode = YES;
    item.campaignInfo = campaignInfo;
    /**
     Second, fetch the video service instance, then set its delegate. This delegate receives callbacks from ZoomCCSDK. When the service status is ZoomCCSDKStatus_Initial, initialize the video service by calling the "initializeWithItem:" and "login" functions. After that, the internal service will connect to the server to fetch information, letting us send and receive messages from the server.
     As only one id<ZoomCCVideoService> can exsist at the same time, if the current zvaService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the video in use, or to end it. Below code shows the end logic.
     */
    id<ZoomCCVideoService> videoService = [[ZoomCCInterface sharedInstance] videoService];
    ZoomCCItem *previousItem = videoService.item;
    if ((!previousItem.useCampaignMode && previousItem.entryId.length)
        || (previousItem.useCampaignMode && ![previousItem.campaignInfo isEqual:campaignInfo])) {
        [videoService endVideo];
        videoService = [[ZoomCCInterface sharedInstance] videoService];
    }
    videoService.videoDelegate = self;
    videoService.videoPreviewOptions = ZoomCCVideoPreviewOption_default;
    videoService.autoJoinWhenVideoCreated = NO;
    if (videoService.status == ZoomCCSDKStatus_Initial) {
        [videoService initializeWithItem:item];
    }
    /**
     Finally, to show the video view, call the function below. Inside the call back, get the view's instance, then show it. After the video view being showed, the videoService will start to request to start a video session with server. When all is ready, user can join the video session automatically inside the ZoomCCSDK's inner view.
     */
    __weak typeof(self) wself = self;
    [videoService fetchUI:^(UIViewController * _Nonnull viewController) {
        [wself directShow:viewController];
    }];
}
/// demo code to initialize the chat service and show the video view in the Campaign mode.
func showVideo(_ campaignInfo: ZoomCCCampaignInfo) {
    /**
     First, cteate a ZoomCCItem class instance. This  determines the channel(chat, video, ZVA) to use. For the video case, set the sdkType property to ZoomCCIInterfaceType_Video. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    let item = ZoomCCItem()
    item.sdkType = .video
    item.apiKey = APP_CAMPAIGN_API_KEY
    item.useCampaignMode = true
    item.campaignInfo = campaignInfo
    /**
     Second, fetch the video service instance, then set its delegate. This delegate receives callbacks from ZoomCCSDK. When the service status is ZoomCCSDKStatus_Initial, initialize the video service by calling the "initializeWithItem:" and "login" functions. After that, the internal service will connect to the server to fetch information, letting us send and receive messages from the server.
     As only one id<ZoomCCVideoService> can exsist at the same time, if the current zvaService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the video in use, or to end it. Below code shows the end logic.
     */
    var videoService = ZoomCCInterface.sharedInstance().videoService()
    let previousItem = videoService.item
    if ((!previousItem.useCampaignMode && !previousItem.entryId.isEmpty) ||
        (previousItem.useCampaignMode && previousItem.campaignInfo != campaignInfo)) {
        videoService.endVideo()
        videoService = ZoomCCInterface.sharedInstance().videoService()
    }
    videoService.videoDelegate = self
    videoService.videoPreviewOptions = .default
    videoService.autoJoinWhenVideoCreated = false
    if videoService.status == .initial {
        videoService.initialize(with: item)
    }
    /**
     Finally, to show the video view, call the function below. Inside the call back, get the view's instance, then show it. After the video view being showed, the videoService will start to request to start a video session with server. When all is ready, user can join the video session automatically inside the ZoomCCSDK's inner view.
     */
    videoService.fetchUI { [weak self] viewController in
        self?.directShow(viewController)
    }
}

Show the scheduled callback view in the campaign mode

  1. Create a ZoomCCItem class instance.
  2. Set the item's sdkType to ZoomCCIINterfaceType_ScheduledCallback.
  3. Set the item's apiKey to APP_CAMPAIGN_API_KEY.
  4. Set the item's useCampaignMode property to YES.
  5. Set the item's campaignInfo property to campaignInfo.
  6. Get scheduledCallbackService and end the previous scheduledCallbackService if needed.
  7. Set scheduledCallbackDelegate, initialize scheduledCallbackService with the item previously created, and log in with chatService.
  8. Fetch and show the scheduled callback view using scheduledCallbackService's fetchUI API.
/// demo code to initialize the schedule callback service and show the schedule callback view  in the Campaign mode.
- (void)showScheduledCallbacks:(ZoomCCCampaignInfo *)campaignInfo  {
    /**
     Firstly ,we need to cteate an instance of class ZoomCCItem, this item determines the chanel(chat, video, zva, scheduleCallback) that we need to use. For the scheduleCallback case, the sdkType property should be set to ZoomCCIInterfaceType_ScheduledCallback. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    ZoomCCItem *item = [ZoomCCItem new];
    item.sdkType = ZoomCCIInterfaceType_ScheduledCallback;
    item.apiKey = APP_CAMPAIGN_API_KEY;
    item.useCampaignMode = YES;
    item.campaignInfo = campaignInfo;
    /**
     Secondly, we need to fetch the schedule callback service instance, then to set it's delegate, this delegate is to receive callbacks from ZoomCCSDK. Then we should initialize the schedule call back service by calling functions "initializeWithItem:". After that, the inner service will start to connect to server to fetch enough information.
     As only one id<ZoomCCScheduledCallbackService> can exsist at the same time, if the current scheduledCallbackService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the scheduledCallbackService in use, or to end it. Below code shows the end logic.
     */
    id<ZoomCCScheduledCallbackService> scheduledCallbackService = [[ZoomCCInterface sharedInstance] scheduledCallbackService];
    ZoomCCItem *previousItem = scheduledCallbackService.item;
    if ((!previousItem.useCampaignMode && previousItem.entryId.length)
        || (previousItem.useCampaignMode && ![previousItem.campaignInfo isEqual:campaignInfo])) {
        [scheduledCallbackService endScheduledCallback];
        scheduledCallbackService = [[ZoomCCInterface sharedInstance] scheduledCallbackService];
    }
    scheduledCallbackService.scheduledCallbackDelegate = self;
    if (scheduledCallbackService.status == ZoomCCSDKStatus_Initial) {
        [scheduledCallbackService initializeWithItem:item];
    }
    /**
     Finally, when we need to show the schedule callback view, wo call the function below. Inside the call back, we get the view's instance, then we show it. After the schedule callback view being showed, the schedule callback service will start to request to start a schedule call back with server.
     */
    __weak typeof(self) wself = self;
    [scheduledCallbackService fetchUI:^(UIViewController * _Nonnull viewController) {
        [wself directShow:viewController];
    }];
}
/// demo code to initialize the schedule callback service and show the schedule callback view  in the Campaign mode.
func showScheduledCallbacks(_ campaignInfo: ZoomCCCampaignInfo) {
    /**
     Firstly ,we need to cteate an instance of class ZoomCCItem, this item determines the chanel(chat, video, zva, scheduleCallback) that we need to use. For the scheduleCallback case, the sdkType property should be set to ZoomCCIInterfaceType_ScheduledCallback. The ApiKey value can be got in the campaign creation page by clicking the blue button named "</>Embed Web Tag".  The page path in the admin page is Campaign Management-> Web and In-App-></>Embed Web Tag. When using the Campaign mode, the property useCampaignMode should be set to YES, and the property campaignInfo should be set with the target campaign value fetched from the method [ZoomCCInterface getCampaigns:complete: ].
     */
    let item = ZoomCCItem()
    item.sdkType = .scheduledCallback
    item.apiKey = APP_CAMPAIGN_API_KEY
    item.useCampaignMode = true
    item.campaignInfo = campaignInfo
    /**
     Secondly, we need to fetch the schedule callback service instance, then to set it's delegate, this delegate is to receive callbacks from ZoomCCSDK. Then we should initialize the schedule call back service by calling functions "initializeWithItem:". After that, the inner service will start to connect to server to fetch enough information.
     As only one id<ZoomCCScheduledCallbackService> can exsist at the same time, if the current scheduledCallbackService has been used somewhere, we need to end it. For our developer,  you can determine to pop up an window to tell the customers if to end the scheduledCallbackService in use, or to end it. Below code shows the end logic.
     */
    var scheduledCallbackService = ZoomCCInterface.sharedInstance().scheduledCallbackService()
    let previousItem = scheduledCallbackService.item
    if ((!previousItem.useCampaignMode && !previousItem.entryId.isEmpty) ||
        (previousItem.useCampaignMode && previousItem.campaignInfo != campaignInfo)) {
        scheduledCallbackService.endScheduledCallback()
        scheduledCallbackService = ZoomCCInterface.sharedInstance().scheduledCallbackService()
    }
    scheduledCallbackService.scheduledCallbackDelegate = self
    if scheduledCallbackService.status == .initial {
        scheduledCallbackService.initialize(with: item)
    }
    /**
     Finally, when we need to show the schedule callback view, wo call the function below. Inside the call back, we get the view's instance, then we show it. After the schedule callback view being showed, the schedule callback service will start to request to start a schedule call back with server.
     */
    scheduledCallbackService.fetchUI { [weak self] viewController in
        self?.directShow(viewController)
    }
}