简体   繁体   English

我有在Android中发布的服务。 如何在iOS中浏览?

[英]I have a service that is published in Android. How to browser it in iOS?

We are creating a multi-platform apps for both Android and iOS. 我们正在为Android和iOS创建一个多平台应用程序。
Currently, we have a services that is published in Android with these information 目前,我们在Android中发布了包含这些信息的服务
Type:_http._tcp or _http._udp Name: abcController port 类型:_http._tcp或_http._udp名称:abcController端口

Now, I want to browse "abcController" services in iOS apps to get the list of host (ip) for connecting. 现在,我想浏览iOS应用程序中的“ abcController”服务以获取用于连接的主机(ip)的列表。 I'm trying to do it with these code 我正在尝试使用这些代码

 NSString* servicesOfType = @"abcController._http._tcp.";
NSString* domain  = @"";

domainBrowser = [[NSNetServiceBrowser alloc] init];
[domainBrowser setDelegate:self];
[domainBrowser searchForServicesOfType:servicesOfType inDomain:domain];

However, it only calls netServiceBrowserWillSearch and doesn't have any response. 但是,它仅调用netServiceBrowserWillSearch,并且没有任何响应。

Any helps is very appreciate ! 任何帮助都非常感谢!

您的服务名称必须以“ _”开头,否则会被混淆为域。

I found the solution for my issue. 我找到了解决我问题的方法。 It turns out that my service is published in udp, therefore. 原来,我的服务因此发布在udp中。 withthiscode. withthiscode。

- (void) initBrowsingServices
{
    NSString* servicesOfType = @"_http._udp.";
    NSString* domain  = @"local";


   domainBrowser = [[NSNetServiceBrowser alloc] init];
   [domainBrowser setDelegate:self];
   [domainBrowser searchForServicesOfType:servicesOfType inDomain:domain];

   domains = [[NSMutableArray alloc] init];

   searching = NO;
}

I can receive my service now. 我现在可以得到服务。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 服务不会在android中停止。 如何解决问题 - Service is not stop in android. how to fixed issues 如何托管共享云上同一数据库的用户可以在浏览器,Android和iOS上使用的Web服务? - How can I host a web service that can be used on browser, Android and iOS by users sharing a same database on cloud? 即使我们在Android中强制应用程序,如何启动服务? - How to start a Service even if we force the application in Android.? 如何从Android的Windows Azure移动服务中上传图像? - How to upload image in windows azure mobile service from android.? 如何在mvvm模式中有一个闪屏,在Android中有空间? - how to have a splash screen in mvvm pattern with room in android.? 我只想在android中单击新图片时启动服务。 我该怎么做? - I want to start a service only when a new picture is clicked in android. How do I go about doing that? 如何在android中回到我的gl屏幕。 我试图在我的代码中跳出并使用xml布局 - How do I get back to my gl screen in android. I have tried to jump out and use an xml layout in my code 我是Android新手。 我希望仅在服务启动时使用android服务来阻止通话 - I am new to android. I wish to use android service for blocking call only when the service is started 如果我已经发布了 5 个快捷方式,如何在 Android 11 上发布对话通知? - How do I issue conversation notifications on Android 11, if I already have published 5 shortcuts? 如何使任何视图增长,直到我按下 android 中的按钮。(kotlin 或 java 无关紧要)? - How to make any view grow till I have pressed the button in android.( kotlin or java doesn't matter )?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM