Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart TV Device not find using DiscoveryManager #266

Open
HarshadTechmero opened this issue Apr 2, 2024 · 9 comments
Open

Smart TV Device not find using DiscoveryManager #266

HarshadTechmero opened this issue Apr 2, 2024 · 9 comments

Comments

@HarshadTechmero
Copy link

HarshadTechmero commented Apr 2, 2024

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
Copy link

did you solve this problem?

@HarshadTechmero
Copy link
Author

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

@hainguyenspdn
Copy link

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
Copy link
Author

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.)?

@hainguyenspdn
Copy link

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

@crash481
Copy link

crash481 commented Jun 19, 2024

@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 #271

@HarshadTechmero
Copy link
Author

@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
Copy link
Author

@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
Copy link

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! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants