Waqas
Waqas

Reputation: 999

Can I create Custom Device Picker for iOS CastSDK 4.5.0

In Swift Google Cast SDK 4.5.0 can I create Custom Device picker ?

Previously while using '3.4.0' I was able to do it using GCKDeviceScanner. As for now for 4.5.0 device scanning is done automatically. So I want to know if I still can create a custom device picker cause my application design is different.

To be more specific Screenshot is attached of the screen I want to customize.

enter image description here

i have gone through all the documentation but couldn't find anything

Any help is appreciated.

Upvotes: 1

Views: 661

Answers (1)

Waqas
Waqas

Reputation: 999

So Finally I found a solution. Instead of using GCKCastButton I used custom Cast Button or we just need to give custom selector to GCKCastButton. And for Discovering Devices and showing those in your custom view, We can use GCKDiscoverManager like this

let gckCastOptions = GCKCastOptions(receiverApplicationID: kGoogleCastAppReceiverId)
    GCKCastContext.setSharedInstanceWithOptions(gckCastOptions)
    GCKLogger.sharedInstance().delegate = self

    self.discoveryManager = GCKCastContext.sharedInstance().discoveryManager
    self.discoveryManager!.addListener(self)
    self.discoveryManager!.passiveScan = true
    self.discoveryManager!.startDiscovery()

And then the Listener method

func didStartDiscoveryForDeviceCategory(deviceCategory: String) {
    print("GCKDiscoveryManagerListener: \(deviceCategory)")

    print("FOUND: \(self.discoveryManager!.hasDiscoveredDevices)")
}

I hope this can help someone struggling to find solution to the problem I faced.

Reference: https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_discovery_manager

Upvotes: 1

Related Questions