SamsungSmart TV Ios Sender

Hi,

I’ve been trying to create a sender app for IOS for a few days now, but to know avail. The documentation is unfortunately incomplete. The example for listeners uses technology obsoleted in Swift 3, it does not explain the need to extend from ServiceSearchDelegate, it makes reference to a non-existent variable, “serviceDiscovery”, “onServiceFound” is never called though I have my device and my tv on the same network, and the list goes on and on. Would it be possible to have someone publish a working IOS sender example with the latest updates?

Furthermore, the documentation (https://smartviewsdk.github.io/API-GUIDE/ios-api/docs/) has not been updated since 2017 though there was a release Nov 2019.

Here’s an idea of something I got working, for anyone coming along!

import SmartView

@objc(SamsungSmartview)
class SamsungSmartview: ServiceSearchDelegate {

  private var services: [Service] = []
  private var serviceSearch = Service.search()

  override init() {
    super.init()
    serviceSearch.delegate = self
  }

  @objc func startSearch() -> Void {
    serviceSearch.start()
  }

  @objc func stopSearch() -> Void {
    serviceSearch.stop()
  }

  // MARK: - ServiceSearchDelegate -
  // Update your UI by using the serviceDiscovery.services array
  @objc func onServiceFound(_ service: Service) {
    if (!services.contains(where: { $0.id == service.id })) {
      services.append(service)
    }
  }

  @objc func onServiceLost(_ service: Service) {
    services.removeAll(where: { $0.id == service.id })
  }

  @objc func cast(_ options: NSDictionary) -> Void {
    let id = options.value(forKey: "id") as! String
    let service = getServiceById(id:id)
    let videoPlayer = service?.createVideoPlayer("SmartView")
    let url = options.value(forKey: "url") as! String
    let title = options.value(forKey: "title") as! String
    let imageUrl = options.value(forKey: "image_url") as! String
    videoPlayer!.playContent(
        URL(string: url),
        title: title,
        thumbnailURL: URL(string: imageUrl),
        completionHandler: {
            (error:NSError?) -> Void in
            // resolve 
        })
  }

  @objc func getServiceById(id: String) -> Service? {
    return services.first(where: { $0.id == id })
  }

}