连接浏览器&广告客户未在多重连接中显示警报消息 [英] Connect Browser & Advertiser without showing alert message in Multipeer connectivity

查看:113
本文介绍了连接浏览器&广告客户未在多重连接中显示警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在探索多重连接框架。我的应用程序中有2个选项广告客户&浏览器。

Currently i am exploring the multipeer connectivity framework.I have 2 option in my application Advertiser & Browser.

因此,当用户在一台设备上启动浏览器,而广告客户在另一台设备上启动时,他们应该能够找到对方。当设备出现在浏览器中并且用户点击它时,将向具有广告设备的用户显示警报,允许他们选择是否进行连接。

So when user fire up the browser on one device, and the advertiser on another then they should be able to find each other. When the device appears in the browser, and the user taps on it, then the user with the advertising device will be presented with an alert allowing them to choose whether or not to make the connection.

但我希望当浏览器点按任何特定广告客户时,它会自动建立连接而不显示提醒消息。

But i want when browser taps any particular advertiser it will automatically make connection without alert message.

注意: - 目前我正在使用 MCBrowserViewController MCAdvertiserAssistant

Note:- Currently i am using MCBrowserViewController and MCAdvertiserAssistant

那么可以吗?任何人都可以做到吗?

So is it possible to do ? Can any one have done it ?

推荐答案

Multipeer Connectivity框架提供了额外的API,支持程序化发现并定制超出提供的体验通过MCBrowserViewController和MCAdvertiserAssitant。

The Multipeer Connectivity framework provides additional APIs that support programmatic discovery and customize the experience beyond what’s provided by MCBrowserViewController and MCAdvertiserAssitant.

通过这种方式,您可以立即发送邀请,而无需等待用户交互。

This way you can immediately send out an invite without waiting for user interaction.

MCNearbyServiceBrowser和MCNearbyServiceAdvertiser分别提供了处理浏览器和广告商的编程发现的方法。 MCNearbyServiceBrowserDelegate协议支持您的自定义浏览器,使您能够响应查找附近的设备,而MCNearbyServiceAdvertiserDelegate可帮助您以编程方式处理浏览器邀请。

MCNearbyServiceBrowser and MCNearbyServiceAdvertiser provide methods to handle programmatic discovery for the browser and advertiser respectively. The MCNearbyServiceBrowserDelegate protocol supports your custom browser by enabling you to respond to finding nearby devices, while MCNearbyServiceAdvertiserDelegate helps you handle browser invitations programmatically.

您将不得不进行繁重的工作在您的代码中构建浏览器的UI,显示附近的设备并向对等方发起邀请。在广告客户端,UI工作涉及向用户呈现邀请,获取用户的响应,以及调用处理程序以将用户响应传递给浏览器。

You’ll have to do the heavy lifting in your code to construct your browser’s UI, present nearby devices and initiate invitations to peers. On the advertiser end, the UI work involves presenting the invitation to the user, getting the user’s response, and calling a handler to pass the user response to the browser.

但是,一旦连接了对等体,发送数据的工作方式与之前的
完全相同。

However, once the peers are connected, sending data works exactly the same as before.

要了解如何设置这些,请查看NSHipster的一些其他代码示例这在此链接。他使用的是UIActionSheet,但您只需接受广告客户的邀请:didReceiveInvitationFromPeer:withContext:invitationHandler:。

To see how to set up these check out NSHipster for some additional code examples of this at this link. He uses an UIActionSheet but you could simply just accept the invitation in advertiser:didReceiveInvitationFromPeer:withContext:invitationHandler:.

invitationHandler(YES, self.session);

这篇关于连接浏览器&广告客户未在多重连接中显示警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆