问题
Since iOS 7.1 Apple removed:
- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID
withContext:(NSData *)context
invitationHandler:(void(^)(BOOL accept, MCSession *session))invitationHandler
and added:
- (void)advertiserAssitantWillPresentInvitation:(MCAdvertiserAssistant *)advertiserAssistant;
- (void)advertiserAssistantDidDismissInvitation:(MCAdvertiserAssistant *)advertiserAssistant;
Is there any ability not to show this message?
回答1:
Yes, use MCNearbyServiceAdvertiser and MCNearbyServiceAdvertiserDelegate instead of MCAdvertiserAssistant and MCAdvertiserAssistantDelegate. MCNearbyServiceAdvertiser allows you to handle acceptance or rejection of the invitation programmatically via advertiser:didReceiveInvitationFromPeer. For example:
- (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;
}
See the Apple docs here: https://developer.apple.com/library/ios/documentation/MultipeerConnectivity/Reference/MultipeerConnectivityFramework/_index.html
来源:https://stackoverflow.com/questions/22919905/disable-connection-alert-multipeer-connectivity