# 4\_5-带货场景-互动

* [1 功能概述](#_1-功能概述)
* [2 使用演示](#_2-使用演示)

#### 1 功能概述

互动功能包括公告、签到、抽奖、答题卡、和问卷功能。该功能是在`PLVECWatchRoomViewController`中实现，集成[7\_6-核心common-互动](https://git.polyv.net/help-center/document-center/-/blob/master/live/ios/7_6-核心common-互动/README.md)中`PLVInteractView`来实现的功能。

#### 2 使用演示

带货场景互动功能只需要在 页面 中加入`PLVInteractView`，并调用其初始化方法，即可完成集成。

在接收到主播端发起的抽奖等功能时，互动应用界面将会自动显示。

示例代码如下

```objective-c
/// PLVECWatchRoomViewController.m

@property (nonatomic, strong) PLVInteractView *interactView; // 互动

- (void)setupModule{
    PLVRoomData *roomData = [PLVRoomDataManager sharedManager].roomData;
    if (roomData.videoType == PLVChannelVideoType_Live) {
				/// 直播
				/// 注册互动通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationForOpenBulletin:) name:PLVLEChatroomOpenBulletinNotification object:nil];
        
    } else if (roomData.videoType == PLVChannelVideoType_Playback){
    		/// 回放
    }
}

- (void)setupUI{
    if (roomData.videoType == PLVChannelVideoType_Live) {
        /// 直播
        
        /// 互动
        [self.view addSubview:self.interactView];

        /// 互动配置
        self.interactView.frame = self.view.bounds;
        self.interactView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.interactView loadOnlineInteract];
        
    } else if (roomData.videoType == PLVChannelVideoType_Playback){
        /// 回放
    }
}

- (PLVInteractView *)interactView{
    PLVChannelVideoType videoType = [PLVRoomDataManager sharedManager].roomData.videoType;
    if (!_interactView && videoType == PLVChannelVideoType_Live) {
        _interactView = [[PLVInteractView alloc] init];
        _interactView.frame = self.view.bounds;
        _interactView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [_interactView loadOnlineInteract];
    }
    return _interactView;
}

- (void)notificationForOpenBulletin:(NSNotification *)notif {
    [self.interactView openLastBulletin];
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyv.gitbook.io/document/docs/live/ios/45-dai-huo-chang-jing-hu-dong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
