Skip to content

Commit

Permalink
Merge pull request #131 from 100mslive/1.15.0Release
Browse files Browse the repository at this point in the history
1.15.0 Release
  • Loading branch information
gzerad authored Jul 22, 2024
2 parents aa623a5 + 3742e0e commit fa56db9
Show file tree
Hide file tree
Showing 11 changed files with 302 additions and 82 deletions.
120 changes: 66 additions & 54 deletions Example/HMSSDKExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions Example/HMSSDKExample/Login/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit
import SwiftyGif
import HMSSDK

final class LoginViewController: UIViewController {

Expand Down Expand Up @@ -105,6 +106,11 @@ final class LoginViewController: UIViewController {
self?.showInputAlert()
}

NotificationCenter.default.addObserver(forName: Constants.meetingLeft,
object: nil,
queue: .main) { [weak self] _ in
self?.collectFeedback()
}
}

private func checkIfInMeeting() -> Bool {
Expand Down Expand Up @@ -231,4 +237,89 @@ final class LoginViewController: UIViewController {

present(viewController, animated: true)
}

// MARK: - Session Feedback

/// Function to prompt the user to provide feedback on the session.
private func collectFeedback() {

// Create an alert controller to display feedback options.
let alert = UIAlertController(title: SessionFeedback.feedbackTitle,
message: SessionFeedback.feedbackSubTitle,
preferredStyle: .actionSheet)

// Add actions for various feedback options.
alert.addAction(UIAlertAction(title: SessionFeedback.awful, style: .default, handler: { [weak self] action in
self?.submitFeedback(.awful)
}))
alert.addAction(UIAlertAction(title: SessionFeedback.bad, style: .default, handler: { [weak self] action in
self?.submitFeedback(.bad)
}))
alert.addAction(UIAlertAction(title: SessionFeedback.fair, style: .default, handler: { [weak self] action in
self?.submitFeedback(.fair)
}))
alert.addAction(UIAlertAction(title: SessionFeedback.good, style: .default, handler: { [weak self] action in
self?.submitFeedback(.good)
}))
alert.addAction(UIAlertAction(title: SessionFeedback.great, style: .default, handler: { [weak self] action in
self?.submitFeedback(.great)
}))

// Add cancel action.
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { action in
// Log the cancel action.
print(#function, action.title as Any)
}))

// Present the alert controller to the user.
self.present(alert, animated: true)
}

/// Function to submit feedback provided by the user.
///
/// - Parameter rating: The rating provided by the user.
private func submitFeedback(_ rating: HMSFeedbackRatingUI) {

// Create an alert controller to gather additional comments from the user.
let alert = UIAlertController(title: rating.toString(),
message: rating.getQuestion(),
preferredStyle: .alert)

// Add text fields for reasons and additional comments.
alert.addTextField { textField in
textField.placeholder = "Reasons?" // Example: "Bad Audio"
}
alert.addTextField { textField in
textField.placeholder = "Additional Comments?" // Example: "Could not hear others"
}

// Add submit action.
alert.addAction(UIAlertAction(title: "Submit", style: .default, handler: { action in

// Create a feedback object with the provided information.
let feedback = HMSSessionFeedback(question: SessionFeedback.feedbackTitle,
rating: rating.toInt(),
minRating: 1,
maxRating: 5,
reasons: ["\(alert.textFields![0].text ?? "")"],
comment: alert.textFields![1].text)

// Submit the feedback to the SDK.
HMSSDK.submitFeedback(feedback) { success, error in

// Create an alert to inform the user about the submission status.
let alert = UIAlertController(title: "Feedback Submitted",
message: "\(success)",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel))

// Present the alert to the user.
self.present(alert, animated: true)
}
}))

// Present the alert controller to the user.
self.present(alert, animated: true)
}

}
69 changes: 69 additions & 0 deletions Example/HMSSDKExample/Login/SessionFeedback/SessionFeedback.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// SessionFeedback.swift
// HMSSDKExample
//
// Created by Yogesh Singh on 10/05/24.
// Copyright © 2024 100ms. All rights reserved.
//

import Foundation

class SessionFeedback {
static let feedbackTitle = "How was your experience?"
static let feedbackSubTitle = "Your answers help us improve the quality"
static let awful = "😔 Awful"
static let bad = "☹️ Bad"
static let fair = "🙂 Fair"
static let good = "😄 Good"
static let great = "🤩 Great"
}


internal enum HMSFeedbackRatingUI {
case awful
case bad
case fair
case good
case great

func toString() -> String {
switch self {
case .awful:
return "😔 Awful"
case .bad:
return "☹️ Bad"
case .fair:
return "🙂 Fair"
case .good:
return "😄 Good"
case .great:
return "🤩 Great"
}
}

func toInt() -> Int {
switch self {
case .awful:
return 1
case .bad:
return 2
case .fair:
return 3
case .good:
return 4
case .great:
return 5
}
}

func getQuestion() -> String {
switch self {
case .awful, .bad:
return "What went wrong?"
case .fair:
return "Any reason for your rating?"
case .good, .great:
return "What went right?"
}
}
}
30 changes: 20 additions & 10 deletions Example/HMSSDKExample/Meeting/HMSSDKInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,36 @@ final class HMSSDKInteractor: HMSUpdateListener {
private func setupPlugins() {
if #available(iOS 15.0, *) {

let vbPlugin = HMSVirtualBackgroundPlugin(backgroundImage: UIImage(named: "VBPortrait"))
vbPlugin.imageDataSource = { info in
if info.orientation == .down || info.orientation == .up {
return UIImage(named: "VBLandscape")!
}
return UIImage(named: "VBPortrait")!
var vbPlugin: HMSVirtualBackgroundPlugin?

if UserDefaults.standard.string(forKey: "virtualBackgroundType") == nil {
UserDefaults.standard.set("none", forKey: "virtualBackgroundType")
}

if UserDefaults.standard.string(forKey: "virtualBackgroundType") == "blur" {
vbPlugin = HMSVirtualBackgroundPlugin(operatingMode: .init(blurIntensity: 40))
}
else {
vbPlugin = HMSVirtualBackgroundPlugin(operatingMode: .init(imageDataSource: { info in
if info.orientation == .down || info.orientation == .up {
return UIImage(named: "VBLandscape")!
}
return UIImage(named: "VBPortrait")!
}))
}

virtualBackgroundPlugin = vbPlugin

if UserDefaults.standard.string(forKey: "virtualBackgroundType") != "none" {
virtualBackgroundPlugin?.activate()
}

videoFilterPlugin = HMSVideoFilterPlugin()
videoFilterPlugin?.activate()
if let videoFilterPlugin {
videoPlugins.append(videoFilterPlugin)
}

if UserDefaults.standard.bool(forKey: "virtualBackgroundPluginEnabled") == true {
virtualBackgroundPlugin?.activate()
}

if let virtualBackgroundPlugin = virtualBackgroundPlugin {
videoPlugins.append(virtualBackgroundPlugin)
}
Expand Down
46 changes: 40 additions & 6 deletions Example/HMSSDKExample/Meeting/MeetingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,15 @@ final class MeetingViewController: UIViewController, UIDocumentPickerDelegate {

private func cleanup() {
UIApplication.shared.isIdleTimerDisabled = false
viewModel?.cleanup()
viewModel?.cleanup() { success, error in
if let error = error {
print(#function, error as Any)
return
}
print(#function, success)

NotificationCenter.default.post(name: Constants.meetingLeft, object: nil)
}
}

// MARK: - Settings Menu Button
Expand Down Expand Up @@ -370,7 +378,7 @@ final class MeetingViewController: UIViewController, UIDocumentPickerDelegate {

let currentMode = viewModel?.mode ?? .regular

let isVBActivated = UserDefaults.standard.bool(forKey: "virtualBackgroundPluginEnabled")
let vbType = UserDefaults.standard.string(forKey: "virtualBackgroundType")

let isNCActivated = self.interactor.noiseCancellationPlugin?.isEnabled()

Expand Down Expand Up @@ -469,14 +477,40 @@ final class MeetingViewController: UIViewController, UIDocumentPickerDelegate {

UIAction(title: "Enable virtual background",
image: UIImage(systemName: "person.crop.rectangle.fill"),
state: isVBActivated ? .on : .off) { [weak self] _ in
if isVBActivated {
state: vbType == "background" ? .on : .off) { [weak self] _ in
if vbType == "background" {
self?.interactor.virtualBackgroundPlugin?.deactivate()
UserDefaults.standard.set("none", forKey: "virtualBackgroundType")
}
else {
if #available(iOS 15.0, *) {
(self?.interactor.virtualBackgroundPlugin as? HMSVirtualBackgroundPlugin)?.operatingMode = .init(imageDataSource: { info in
if info.orientation == .down || info.orientation == .up {
return UIImage(named: "VBLandscape")!
}
return UIImage(named: "VBPortrait")!
})
}
_ = self?.interactor.virtualBackgroundPlugin?.activate()
UserDefaults.standard.set("background", forKey: "virtualBackgroundType")
}
self?.updateSettingsButton()
},
UIAction(title: "Enable blur background",
image: UIImage(systemName: "person.crop.rectangle.fill"),
state: vbType == "blur" ? .on : .off) { [weak self] _ in
if vbType == "blur" {
self?.interactor.virtualBackgroundPlugin?.deactivate()
UserDefaults.standard.set(false, forKey: "virtualBackgroundPluginEnabled")
UserDefaults.standard.set("none", forKey: "virtualBackgroundType")
}
else {
if #available(iOS 15.0, *) {
if let plugin = (self?.interactor.virtualBackgroundPlugin as? HMSVirtualBackgroundPlugin) {
plugin.operatingMode = .init(blurIntensity: 40)
}
}
_ = self?.interactor.virtualBackgroundPlugin?.activate()
UserDefaults.standard.set(true, forKey: "virtualBackgroundPluginEnabled")
UserDefaults.standard.set("blur", forKey: "virtualBackgroundType")
}
self?.updateSettingsButton()
},
Expand Down
6 changes: 4 additions & 2 deletions Example/HMSSDKExample/Meeting/MeetingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,12 @@ final class MeetingViewModel: NSObject,

// MARK: - Action Handlers

internal func cleanup() {
internal func cleanup(completion: ((Bool, Error?) -> Void)? = nil) {
dataSource.delegate = nil
dataSource.sortComparator = nil
interactor?.hmsSDK?.leave()
interactor?.hmsSDK?.leave { success, error in
completion?(success, error)
}
interactor = nil
}

Expand Down
2 changes: 2 additions & 0 deletions Example/HMSSDKExample/SupportingFiles/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct Constants {
static let roleUpdated = Notification.Name("ROLE_UPDATED")

static let sessionMetadataReceived = NSNotification.Name("sessionMetadataReceived")

static let meetingLeft = NSNotification.Name("MeetingViewControllerCleanup")

// MARK: - View Constants

Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ platform :ios, '13.0'

target 'HMSSDKExample' do
use_frameworks!
pod 'HMSSDK', '1.14.1'
pod 'HMSSDK', '1.15.0'
pod 'HMSHLSPlayerSDK', '0.0.2'
pod 'HMSNoiseCancellationModels', '1.0.0'
pod 'SwiftyBeaver', '1.9.5'
Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PODS:
- HMSHLSPlayerSDK (0.0.2):
- HMSAnalyticsSDK (= 0.0.2)
- HMSNoiseCancellationModels (1.0.0)
- HMSSDK (1.14.0):
- HMSSDK (1.14.1):
- HMSAnalyticsSDK (= 0.0.2)
- HMSWebRTC (= 1.0.6170)
- HMSWebRTC (1.0.6170)
Expand All @@ -18,7 +18,7 @@ DEPENDENCIES:
- HMSBroadcastExtensionSDK (= 1.0.0)
- HMSHLSPlayerSDK (= 0.0.2)
- HMSNoiseCancellationModels (= 1.0.0)
- HMSSDK (= 1.14.0)
- HMSSDK (= 1.14.1)
- SwiftyBeaver (= 1.9.5)
- SwiftyGif
- Zip (= 2.1.2)
Expand All @@ -42,12 +42,12 @@ SPEC CHECKSUMS:
HMSBroadcastExtensionSDK: 0757d80497fddec3952858eb14892fb274f9f3c3
HMSHLSPlayerSDK: 6a54ad4d12f3dc2270d1ecd24019d71282a4f6a3
HMSNoiseCancellationModels: a3bda1405a16015632f4bcabd46ce48f35103b02
HMSSDK: e2731dcc80f5a0d261dcc751424c21f4342f4aaa
HMSSDK: 389e692c315efd6abe1932e2dab4859ebb5cd60d
HMSWebRTC: b5ffaf5d6133ae2a4c841beaf1e5e4fe06d0fb07
SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
Zip: b3fef584b147b6e582b2256a9815c897d60ddc67

PODFILE CHECKSUM: a5512f9410e5ad2b0cc5b561e52039c5cc199d24
PODFILE CHECKSUM: 014e726e7c539bf2fd7b24d5543d7a4887ea7810

COCOAPODS: 1.15.2
6 changes: 3 additions & 3 deletions HMSSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'HMSSDK'
s.version = '1.14.1'
s.version = '1.15.0'
s.summary = 'HMS Videoconferencing iOS SDK'

s.description = <<-DESC
Expand All @@ -10,8 +10,8 @@ TODO: Add long description of the pod here.
s.homepage = 'https://github.com/100mslive/100ms-ios-sdk/'
s.license = { :type => 'MIT'}
s.author = { 'Dmitry Fedoseyev' => '[email protected]', 'Yogesh Singh' => '[email protected]', 'Pawan Dixit' => '[email protected]'}
s.source = { :http => 'https://github.com/100mslive/100ms-ios-sdk/releases/download/1.14.1/HMSSDK.xcframework.zip',
:sha256 => '9949413d443492b01cca4060b6425cdf31814712127b25d2bd24ebf535e0e09e'
s.source = { :http => 'https://github.com/100mslive/100ms-ios-sdk/releases/download/1.15.0/HMSSDK.xcframework.zip',
:sha256 => '73f15409b76dc2a7b677027ede12fb5711f6222931f690b2701c6d86e0b3092b'
}
s.ios.deployment_target = '12.0'
s.vendored_frameworks = 'HMSSDK.xcframework'
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ let package = Package(
targets: [
.binaryTarget(
name: "HMSSDK",
url: "https://github.com/100mslive/100ms-ios-sdk/releases/download/1.14.1/HMSSDK.xcframework.zip",
checksum: "9949413d443492b01cca4060b6425cdf31814712127b25d2bd24ebf535e0e09e"
url: "https://github.com/100mslive/100ms-ios-sdk/releases/download/1.15.0/HMSSDK.xcframework.zip",
checksum: "73f15409b76dc2a7b677027ede12fb5711f6222931f690b2701c6d86e0b3092b"
),
.binaryTarget(
name: "WebRTC",
Expand Down

0 comments on commit fa56db9

Please sign in to comment.