ConnectSDK / Connect-SDK-iOS

iOS source project for Connect SDK
Apache License 2.0
174 stars 136 forks source link

Smart TV Device not find using DiscoveryManager #266

Open HarshadTechmero opened 6 months ago

HarshadTechmero commented 6 months ago
var discoveryManager = DiscoveryManager.shared()
discoveryManager?.registerDefaultServices()
        let videoCapabilities = [
            kMediaPlayerPlayVideo,
            kMediaControlAny,
            kVolumeControlVolumeUpDown
        ]
    let imageCapabilities = [kMediaPlayerDisplayImage]

    let videoFilter = CapabilityFilter(capabilities: videoCapabilities)
    let imageFilter = CapabilityFilter(capabilities: imageCapabilities)
    discoveryManager?.delegate = self
    discoveryManager?.capabilityFilters = [videoFilter, imageFilter]
    discoveryManager?.pairingLevel = DeviceServicePairingLevelOn
    discoveryManager?.registerDeviceService(WebOSTVService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(AirPlayService.self, withDiscovery: ZeroConfDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(CastService.self, withDiscovery: CastDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(DIALService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(RokuService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(DLNAService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.startDiscovery()

    extension ConnectingDeviceViewController: DiscoveryManagerDelegate {
func discoveryManager(_ manager: DiscoveryManager!, didFind device: ConnectableDevice!) {
    // A ConnectableDevice was found
    print(device.friendlyName ?? "")
}

func discoveryManager(_ manager: DiscoveryManager!, didLose device: ConnectableDevice!) {
    // A ConnectableDevice was lost
    print(device.friendlyName ?? "")
}
func discoveryManagerDidFailWithError(_ error: Error!) {
    print("Discovery error: \(error.localizedDescription)")
}

}

delegate method not called and smart TV device not found

Sakurathanh2003 commented 4 months ago

did you solve this problem?

HarshadTechmero commented 4 months ago

@Sakurathanh2003 i have resolved the issue but i am not able to send pairing code to device. have you fix this issue?

proappsteam commented 3 months ago
var discoveryManager = DiscoveryManager.shared()
discoveryManager?.registerDefaultServices()
        let videoCapabilities = [
            kMediaPlayerPlayVideo,
            kMediaControlAny,
            kVolumeControlVolumeUpDown
        ]
    let imageCapabilities = [kMediaPlayerDisplayImage]

    let videoFilter = CapabilityFilter(capabilities: videoCapabilities)
    let imageFilter = CapabilityFilter(capabilities: imageCapabilities)
    discoveryManager?.delegate = self
    discoveryManager?.capabilityFilters = [videoFilter, imageFilter]
    discoveryManager?.pairingLevel = DeviceServicePairingLevelOn
    discoveryManager?.registerDeviceService(WebOSTVService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(AirPlayService.self, withDiscovery: ZeroConfDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(CastService.self, withDiscovery: CastDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(DIALService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(RokuService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.registerDeviceService(DLNAService.self, withDiscovery: SSDPDiscoveryProvider.self)
    discoveryManager?.startDiscovery()

    extension ConnectingDeviceViewController: DiscoveryManagerDelegate {
func discoveryManager(_ manager: DiscoveryManager!, didFind device: ConnectableDevice!) {
    // A ConnectableDevice was found
    print(device.friendlyName ?? "")
}

func discoveryManager(_ manager: DiscoveryManager!, didLose device: ConnectableDevice!) {
    // A ConnectableDevice was lost
    print(device.friendlyName ?? "")
}
func discoveryManagerDidFailWithError(_ error: Error!) {
    print("Discovery error: \(error.localizedDescription)")
}

}

delegate method not called and smart TV device not found

Might I ask which version of google-cast did you use? I can't discover Android TV in the network, only can discover LG, Samsung TVs.

HarshadTechmero commented 3 months ago

ConnectSDK Not Support All Android TV but in my code i have discover my OnePlus TV.

Are you Able to send pairing code to Smart TV(LG, Samsung or etc.)?

proappsteam commented 3 months ago

Yes we can pair code to Smart TV but can't find our TCL TV

crash481 commented 3 months ago

@HarshadTechmero hello. I have same issue that you have initially. Still cannot find TV devices in local wifi network. But another AppStore apps works good

How you resolved issue? Can you help me? I described problem here https://github.com/ConnectSDK/Connect-SDK-iOS/issues/271

HarshadTechmero commented 3 months ago

@crash481 have you enable Multicasting on your Developer Account and Entitlement https://developer.apple.com/contact/request/networking-multicast

Screenshot 2024-06-20 at 9 28 09 AM Screenshot 2024-06-20 at 9 30 37 AM

i hope this should be help for find device

HarshadTechmero commented 3 months ago

@crash481 you can use this lib/code for android device connect and pairing code, i am able to connect and control key event.

https://github.com/odyshewroman/AndroidTVRemoteControl

sivaprasadkv commented 2 months ago

This issue has been resolved by enabling "Multicast Networking" (com.apple.developer.networking.multicast). Request Apple to enable this advanced capability in your developer account for a particular Apple identifier. Provide proper justification on using this capability in your app.

URL to make a request is: https://developer.apple.com/contact/request/networking-multicast

Ones Apple approved, enable this capability to app's bundle identifier in your developer certificates account. After this, add "com.apple.developer.networking.multicast" = YES in your entitlement file in your project.

After all this, your app discovers all the devices immediately. Enjoy Coding! :)