Polyv Help Center

Help Center

4_5-带货场景-互动

Updated: 2023-04-17 15:27:57

1 Feature Overview

The interactive features include announcements, check-ins, lucky draws, answer cards, and surveys. These features are implemented in PLVECWatchRoomViewController and are realized by integrating PLVInteractView from 7_6-Core Common-Interaction.

2 Usage Demo

For the live commerce scenario, the interactive features can be integrated simply by adding PLVInteractView to the page and calling its initialization method.

When the host initiates features such as a lucky draw, the interactive application interface will be displayed automatically.

The example code is as follows:

/// 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];
}
联系客服,在线咨询