自从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;
有没有能力不显示此消息?
答案 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;
}