Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCKChannel disconnected while iOS sender enter background

I notice GCKChannel will be disconnected after my app enter background (or screen locked), and will be connected again after my app back to foreground.

following is the call stack for channel didDisconnect, it looks like GCKCastSocket registered notification UIApplicationDidEnterBackgroundNotification.

#0  0x001cac58 in -[MyChannel didDisconnect]
#1  0x001feb72 in -[GCKDeviceManager castSocket:didDisconnectWithError:] at GCKDeviceManager.m:692
#2  0x001f8902 in -[GCKCastSocket doTeardownWithError:] at GCKCastSocket.m:187
#3  0x001f8508 in -[GCKCastSocket disconnect] at GCKCastSocket.m:133
#4  0x30b35e70 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()

I am trying to follow the design checklist: https://developers.google.com/cast/docs/design_checklist#sender-control-lockscreen

and this cause my app doesn't get update from my receiver app when user locked their iDevice.

Although it's not required for iOS, I think it is an important usability feature to control my receiver app without unlock the device...

My sender app hooks remote control events, push information to MPNowPlayingInfoCenter, and also monitor the system volume changed event to create the best user experience.

if I cannot keep receiving/sending message from/to receiver app in the background, the controls in the lock screen is useless, and will have out-of-date information, I believe most of users won't keep their device screen open when they are listening to/watching the TV(Chromecast)...

is there any workaround?

like image 736
user3342374 Avatar asked Feb 25 '14 02:02

user3342374


1 Answers

Yep, that's correct. When the app backgrounds the channels will be implicitly disconnected. If you're managing the lock screen controls though, you should be able to disable this behaviour using the ignoreAppStateNotifications on the GCKDeviceManager initWithDevice:clientPackageName:ignoreAppStateNotifications initialiser.

It'll be your responsibility to manage disconnecting when backgrounding if and when you need to - see the comments in the documentation for more.

like image 114
Ian Barber Avatar answered Oct 16 '22 10:10

Ian Barber