The specific error or problem was that the connect code to display the alert where the user drags a slider for the desired number of vouchers to transfer, was not showing on iOS 7 device.
The iOS 7 devices DID receive vouchers so that meant the GKSession WAS valid.
So, in debugging it I found that even though the delegate was set, the didConnectPeer callback was firing but the didChangeState: WAS NOT.
So.... an easy-peasy kludge of a patch now allows iOS 7 devices to transfer vouchers to their iOS 6 (and iOS 5) brethren.
Full disclosure: I also added a boolean flag so that the GKPeerStateConnected "state" will only fire once, regardless of "where" it came from.- (void)peerPickerController:(GKPeerPickerController *)picker didConnectPeer:(NSString *)thePeerID toSession:(GKSession *)theSession{self.session = theSession;self.session.delegate = self;self.peerID = thePeerID;[self.session setDataReceiveHandler:self withContext:NULL];[picker dismiss];picker.delegate = nil;float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue];if (sysVersion > 6.9) {if (!didConnect)[self session:self.session peer:self.peerID didChangeState:GKPeerStateConnected];}}
case GKPeerStateConnected:if (!didConnect) {didConnect = TRUE;NSLog(@"Peer %@ Connected", self.peerID);[self performSelector:@selector(promptForQty) withObject:self afterDelay:1.0];self.statusLabel.text = @"Connected";[self.launchShareButton setTitle:@"Stop" forState:UIControlStateNormal];[self.launchShareButton setTitle:@"Stop" forState:UIControlStateHighlighted];[self.connectingActivityIndicatorView stopAnimating];}break;
Thanks for posting this. Unfortunately, I do not use the GKPeerPickerController interface as I've written my own. Hopefully there is another way to trigger the didChangeState delegate callback, but I haven't found it yet.
ReplyDeleteAlso, you might consider using NSNumberSearch for comparing iOS versions instead of a float that only gives you one decimal place while iOS is usually split between 3 separate version number segments.
I use something like this to tell if the app is running on iOS 7 or later...
if( [[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] > NSOrderedAscending )
{
// running iOS 7 or newer
}
Thanks Richard,
ReplyDeleteHope you can resolve your issue.