禁用连接警报(多重连接)

时间:2014-04-07 18:08:34

标签: ios bluetooth ios7.1 multipeer-connectivity

自从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;

有没有能力不显示此消息?

1 个答案:

答案 0 :(得分:2)

是的,使用MCNearbyServiceAdvertiser和MCNearbyServiceAdvertiserDelegate而不是MCAdvertiserAssistant和MCAdvertiserAssistantDelegate。 MCNearbyServiceAdvertiser允许您通过广告商以编程方式处理接受或拒绝邀请: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