Disable connection alert (Multipeer connectivity)

独自空忆成欢 提交于 2019-12-13 04:22:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!