0

自 iOS 7.1 Apple 移除后:

- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID
       withContext:(NSData *)context
 invitationHandler:(void(^)(BOOL accept, MCSession *session))invitationHandler

并补充说:

- (void)advertiserAssitantWillPresentInvitation:(MCAdvertiserAssistant *)advertiserAssistant;

- (void)advertiserAssistantDidDismissInvitation:(MCAdvertiserAssistant *)advertiserAssistant;

是否有任何能力不显示此消息?

4

1 回答 1

2

是的,使用 MCNearbyServiceAdvertiser 和 MCNearbyServiceAdvertiserDelegate 代替 MCAdvertiserAssistant 和 MCAdvertiserAssistantDelegate。MCNearbyServiceAdvertiser 允许您通过 ads:didReceiveInvitationFromPeer 以编程方式处理接受或拒绝邀请。例如:

- (void)advertiser:(MCNearbyServiceAdvertiser *)theAdvertiser didReceiveInvitationFromPeer:(MCPeerID *)directorPeerId withContext:(NSData *)invitationData invitationHandler:(void (^)(BOOL, MCSession *))invitationHandler
{
    // accept the invitation and stop advertising
    invitationHandler(YES, self.session);
    [self.advertiser stopAdvertisingPeer];
    self.advertiser = nil;
}

在此处查看 Apple 文档:https ://developer.apple.com/library/ios/documentation/MultipeerConnectivity/Reference/MultipeerConnectivityFramework/_index.html

于 2014-04-09T02:38:12.277 回答