저는 Multipeer Conectivity Framework를 사용하는 앱에서 작업하고 있습니다. 지금까지 모든 것이 훌륭해졌습니다. 프로그래밍 방식의 탐색 및 초대를 구현했습니다.멀티 페어 연결 - 상태가 변경되지 않습니다.
내 문제는 사용자가 브라우저가 상태 변경을받지 못했다는 초대를 수락하여 세션을 만들지 않는 경우입니다.
이것은 블록으로 통합 된 작업 시트를 사용하여 만든 초대 방법을받은 광고주입니다.
- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
withContext:(NSData *)context
invitationHandler:(void(^)(BOOL accept, MCSession *session))invitationHandler
{
[UIActionSheet showInView:self.view
withTitle:[[NSString alloc]initWithFormat:@"%@ would like to share %@ information with you.",peerID.displayName, (NSString *)context]
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Deny"
otherButtonTitles:@[@"Accept"]
tapBlock:^(UIActionSheet *actionSheet, NSInteger buttonIndex) {
NSLog(@"%i",buttonIndex==1?true:false);
MCSession *newSession=[[MCSession alloc]initWithPeer:[[MCPeerID alloc] initWithDisplayName:@"CRAP23456"]];
[newSession setDelegate: self];
NSLog(@"button index %i ",buttonIndex==1?true:false);
invitationHandler(buttonIndex==1?YES:NO,newSession);
}];
}
위의 메서드가 호출되고 초대 핸들러가 올바른 값을 반환합니다.
브라우저 측에서 구현 한 방법은 매우 간단합니다.이 방법은 사용자가 메서드를 수락하거나 거부 할 때 호출해야하는 메서드입니다. 그러나 사용자가 초대를 거절 할 때만 호출됩니다.
- (void)session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state
{
NSLog(@"%d",state);
NSLog(@"%ld",(long)MCSessionStateConnected);
}
감사합니다.
제임스.
이런 종류의 문제를 제안 해 주셔서 감사합니다. 브라우저와 광고주에도 문제가 있음이 밝혀졌습니다. ARC에 대한 내구성있는 참조가 만들어지면 시스템이 작동하기 시작했습니다. –