• <legend id='9WDxd'><style id='9WDxd'><dir id='9WDxd'><q id='9WDxd'></q></dir></style></legend>
    <tfoot id='9WDxd'></tfoot>

        <bdo id='9WDxd'></bdo><ul id='9WDxd'></ul>

    1. <i id='9WDxd'><tr id='9WDxd'><dt id='9WDxd'><q id='9WDxd'><span id='9WDxd'><b id='9WDxd'><form id='9WDxd'><ins id='9WDxd'></ins><ul id='9WDxd'></ul><sub id='9WDxd'></sub></form><legend id='9WDxd'></legend><bdo id='9WDxd'><pre id='9WDxd'><center id='9WDxd'></center></pre></bdo></b><th id='9WDxd'></th></span></q></dt></tr></i><div id='9WDxd'><tfoot id='9WDxd'></tfoot><dl id='9WDxd'><fieldset id='9WDxd'></fieldset></dl></div>

      1. <small id='9WDxd'></small><noframes id='9WDxd'>

      2. iOS Multipeer 连接框架invitationHandler 似乎不接受?

        时间:2023-09-12

          <small id='Fdk9A'></small><noframes id='Fdk9A'>

          <legend id='Fdk9A'><style id='Fdk9A'><dir id='Fdk9A'><q id='Fdk9A'></q></dir></style></legend>

            • <bdo id='Fdk9A'></bdo><ul id='Fdk9A'></ul>

              1. <tfoot id='Fdk9A'></tfoot>
              2. <i id='Fdk9A'><tr id='Fdk9A'><dt id='Fdk9A'><q id='Fdk9A'><span id='Fdk9A'><b id='Fdk9A'><form id='Fdk9A'><ins id='Fdk9A'></ins><ul id='Fdk9A'></ul><sub id='Fdk9A'></sub></form><legend id='Fdk9A'></legend><bdo id='Fdk9A'><pre id='Fdk9A'><center id='Fdk9A'></center></pre></bdo></b><th id='Fdk9A'></th></span></q></dt></tr></i><div id='Fdk9A'><tfoot id='Fdk9A'></tfoot><dl id='Fdk9A'><fieldset id='Fdk9A'></fieldset></dl></div>

                    <tbody id='Fdk9A'></tbody>
                  本文介绍了iOS Multipeer 连接框架invitationHandler 似乎不接受?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是第一次使用多点连接框架,我想要编程(而不是助手类)控制.

                  I'm using the mutlipeer connectivity framework for the first time, and I want programmatic ( not with the assistant classes) control.

                  当我在两个单独的设备上运行我的代码直到广告商"收到委托回调时,一切都完全按照描述的那样工作:

                  Everything is working exactly as described when I run my code on two separate devices up until the point when the 'advertiser' receives the delegate callback:

                  浏览客户端的代理回调在发现广告商时被调用:

                  The browsing client's delegate callback is called when it discovers the advertiser:

                  -(void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info{
                      [[[UIAlertView alloc] initWithTitle:@"Peer Found" message:peerID.displayName delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
                  
                      _session = [[MCSession alloc] initWithPeer:_myPeerID];
                      _session.delegate = self;
                  
                      //connect to the discovered peer.
                      [_browser invitePeer:peerID toSession:_session withContext:nil timeout:30.0];
                      [_browser stopBrowsingForPeers];
                  

                  }

                  然后广告客户端收到邀请后调用delegate回调:

                  Then the advertising client's delegate callback is called when it receives the invite:

                  -(void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void (^)(BOOL, MCSession *))invitationHandler{
                  
                      //when my code runs, everything looks correct here. 
                      //eg. peerID is definitely my 'browser' client's display name etc.
                  
                      _session = [[MCSession alloc] initWithPeer:_myPeerID];
                      _session.delegate = self;
                  
                      //using a simple version for testing... accept all invites.
                      invitationHandler(YES, _session);
                  
                      //stop advertising now.
                      [_advertiser stopAdvertisingPeer];
                  }
                  

                  调用invitationHandler(YES, _session)"后,浏览"客户端和广告"客户端之间似乎从未建立连接.

                  After 'invitationHandler(YES, _session)' is called, it seems like the connection is never established between the 'browsing' client and the 'advertising' client.

                  我从未在任一客户端设备上的 MCSession 对象上收到任何委托回调(我收到过一次或两次 MCSessionStateNotConnected ).我原以为我会收到 MCSession 委托回调:

                  I don't ever receive any delegate callbacks (once or twice I received a MCSessionStateNotConnected ) on the MCSession objects on either client device. I would have thought I would have received the MCSession delegate callback:

                  -(void)session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state;
                  

                  我错过了什么吗?有没有其他人遇到过这个问题?

                  Am I missing something? Has anyone else come across this issue?

                  推荐答案

                  Apple 显然意识到了一个错误.

                  There is a bug that Apple is aware of apparently.

                  这是导致发现的原因:为什么我的 MCSession 对等端随机断开连接?

                  您必须实现以下委托回调,即使它在文档中列为可选...

                  You must implement the following delegate callback even though it is listed as optional in the docs...

                  - (void) session:(MCSession *)session didReceiveCertificate:(NSArray *)certificate fromPeer:(MCPeerID *)peerID certificateHandler:(void (^)(BOOL accept))certificateHandler
                  {
                   certificateHandler(YES);
                  }
                  

                  这篇关于iOS Multipeer 连接框架invitationHandler 似乎不接受?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:“代表"的替代方案是什么?在控制器之间传递数据? 下一篇:没有segue的两个视图控制器之间的快速委托

                  相关文章

                  <tfoot id='wpKGd'></tfoot>
                • <legend id='wpKGd'><style id='wpKGd'><dir id='wpKGd'><q id='wpKGd'></q></dir></style></legend>

                • <small id='wpKGd'></small><noframes id='wpKGd'>

                        <bdo id='wpKGd'></bdo><ul id='wpKGd'></ul>
                      <i id='wpKGd'><tr id='wpKGd'><dt id='wpKGd'><q id='wpKGd'><span id='wpKGd'><b id='wpKGd'><form id='wpKGd'><ins id='wpKGd'></ins><ul id='wpKGd'></ul><sub id='wpKGd'></sub></form><legend id='wpKGd'></legend><bdo id='wpKGd'><pre id='wpKGd'><center id='wpKGd'></center></pre></bdo></b><th id='wpKGd'></th></span></q></dt></tr></i><div id='wpKGd'><tfoot id='wpKGd'></tfoot><dl id='wpKGd'><fieldset id='wpKGd'></fieldset></dl></div>