Guideline 1.2 App Store and UIKit

What are some of the techniques that others are using to adhear to Apple’s Guideline 1.2 - Safety - User Generated Content?

I’m using UIKit v3 and thinking about overriding a few functions in the SBUGroupChannelModule.List class. The idea would be to override the createMessageMenuItems function to add a new menu item called “Report” to the action sheet.

It would be ideal to then allow the user to select from the report categories of suspicious, harassing, spam or inappropriate. Then allow them to enter a report description.

Has anyone done something like this with UIKit?

// set the group channel module list component so we can customize and override it
SBUModuleSet.groupChannelModule.listComponent = CustomSBUGroupChannelModule()

class CustomSBUGroupChannelModule: SBUGroupChannelModule.List {
    
    override func createMessageMenuItems(for message: BaseMessage) -> [SBUMenuItem] {
        let isSentByMe = message.sender?.userId == SBUGlobals.currentUser?.userId
        
        var items: [SBUMenuItem] = []
        
        switch message {
        case is UserMessage:
            let copy = self.createCopyMenuItem(for: message)
            items.append(copy)
            // ADDED this:
            let reportTypes = ["suspicious", "harassing", "inappropriate"]
            for type in reportTypes {
                let menuItem = self.createReportMenuItem(for: message, type: type)
                items.append(menuItem)
            }
            
            if isSentByMe {
                let edit = self.createEditMenuItem(for: message)
                let delete = self.createDeleteMenuItem(for: message)
                items.append(edit)
                items.append(delete)
            }
            
        case let fileMessage as FileMessage:
            let save = self.createSaveMenuItem(for: message)
            if SBUUtils.getFileType(by: fileMessage) != .voice {
                items.append(save)
            }
            if isSentByMe {
                let delete = self.createDeleteMenuItem(for: message)
                items.append(delete)
            }
        default:
            if !isSentByMe {
                let delete = self.createDeleteMenuItem(for: message)
                items.append(delete)
            }
        }
        return items
        
    }
    // ADDED this:
    func createReportMenuItem(for message: BaseMessage, type: String) -> SBUMenuItem {
        let isEnabled = message.threadInfo.replyCount == 0
        let menuItem = SBUMenuItem(
            title: "Report as \(type)",
            color: isEnabled ? theme?.menuTextColor : theme?.menuItemDisabledColor
        ) { [weak self, message] in
            guard let self = self else { return }
            self.showReportMessageAlert(on: message, oneTimeTheme: nil, type: type)
        }
        menuItem.isEnabled = message.threadInfo.replyCount == 0
        return menuItem
    }

    // ADDED this:
    func showReportMessageAlert(on message: BaseMessage, oneTimeTheme: SBUComponentTheme? = nil, type: String) {
        
        let reportButton = SBUAlertButtonItem(
            title: "Yes",
            color: self.theme?.alertRemoveColor
        ) { [weak self, message] info in
            guard let self = self else { return }
            
            switch type {
                case "suspicious":
                    self.channel?.report(message: message, reportCategory: ReportCategory.suspicious, reportDescription: "test") { (error) in
                        guard error == nil else {
                            return
                        }
                    }
                case "harassing":
                    self.channel?.report(message: message, reportCategory: ReportCategory.harassing, reportDescription: "test") { (error) in
                        guard error == nil else {
                            return
                        }
                    }
                case "inappropriate":
                    self.channel?.report(message: message, reportCategory: ReportCategory.inappropriate, reportDescription: "test") { (error) in
                        guard error == nil else {
                            return
                        }
                    }
                default:
                    print("The specified method does not exist")
            }
                       
        }
        
        let cancelButton = SBUAlertButtonItem(title: SBUStringSet.Cancel) { _ in }
        
        SBUAlertView.show(
            title: "Do you wish to report this message as \(type)?",
            oneTimetheme: oneTimeTheme,
            confirmButtonItem: reportButton,
            cancelButtonItem: cancelButton
        )
    }
    
}