在iOS中跨应用程序共享UDP数据

在iOS中跨应用程序共享UDP数据

本文介绍了在iOS中跨应用程序共享UDP数据(后台/前景或分屏多任务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在编写一个研究应用程序,该应用程序利用通过UDP广播数据的特定传感器的优势.有许多使用此传感器的商业应用程序,我们希望能够同时运行我们的应用程序和现有应用程序.

I'm writing a research application that takes advantage of a specific sensor that broadcasts data over UDP. There are various commercial apps that use this sensor and we are hoping to be able to run both our application and an existing application side by side.

过去(iOS 8及更低版本),我们将在后台运行我们的应用程序以记录数据,而在前台运行另一个应用程序.不幸的是,似乎只有一个应用程序能够绑定传入的UDP数据(这很有意义),但是随着即将到来的并排"应用程序功能,我想知道是否有任何解决方案可以在应用程序之间共享数据.

In the past (iOS 8 and below) we would run our application in the background to record data and a different application in the foreground. Unfortunately it appears only a single application was able to bind to the incoming UDP data (which makes sense), however with the coming 'side-by-side' application capabilities I was wondering if there was any solution to share data between the applications.

我唯一能想到的就是让我们的应用程序以某种方式捕获数据并将其重新广播到另一个应用程序中,但是我不知道在iOS中这是否可行,即使您如何将确定谁"对UDP流具有锁定.

The only thing I could think of was to somehow have our app capture the data and re-broadcast it out to the other application but I'm not aware of whether that is possible in iOS, and even if it was how you would determine "who" has a lock on the UDP stream.

Apples文档,位于: https://developer.apple.com/library/prerelease/ios/documentation/WindowsViews/Conceptual/AdoptingMultitaskingOniPad/index.html#//apple_ref/doc/uid/TP40015145 似乎没有提供太多信息

Apples documentation at: https://developer.apple.com/library/prerelease/ios/documentation/WindowsViews/Conceptual/AdoptingMultitaskingOniPad/index.html#//apple_ref/doc/uid/TP40015145 doesn't seem to offer much information.

推荐答案

我不确定这是否适用于您的用例,但您可能想使用 CloudKit 将数据发送到自定义应用容器.在第二个应用程序的应用程序功能"部分中,您可以访问共享容器.

I am not certain of whether or not this will apply to your use-case but you may want to use CloudKit to send data to a custom app container. In the app capabilities section of your second app you can access the shared container.

来自 iCloud设计指南:

来自Apple,请参阅原始内容以获取更多详细信息

(可选)将您的应用配置为使用多个容器或与其他应用共享一个容器.例如,您可能在内部使用一个应用程序来创建记录类型,并以编程方式将数据库返回到已知状态.此应用程序需要与您正在开发和测试的最终用户应用程序共享相同的容器.为此,您可以使第一个应用程序使用第二个应用程序的默认容器,或者创建两个应用程序共享的自定义容器.还可以将iOS和Mac应用程序配置为共享相同的容器.

Optionally, configure your app to use multiple containers or share a container with other apps. For example, you might use one app internally to create record types and records programmatically to return a database to a known state. This app needs to share the same container as the end-user app you are developing and testing. To do this, you enable the first app to use the default container of the second app or create a custom container that both apps share. iOS and Mac apps can also be configured to share the same containers.

将容器添加到应用

选择另一个应用程序使用的现有容器ID或创建一个新的容器ID.

Select an existing container ID used by another app or create a new one.

向应用添加容器

在iCloud设置下的功能"窗格中,选择指定自定义容器".

In the Capabilities pane under the iCloud settings, select "Specify custom containers."

您先前选择CloudKit服务时,Xcode为您的应用程序创建了一个与容器ID匹配的默认容器ID.默认容器ID旁边会出现一个复选标记.

When you previously selected the CloudKit service, Xcode created a default container ID for your app that matches the bundle ID. A checkmark appears next to the default container ID.

如有必要,请单击容器"表下方的刷新"按钮,以从Member Center下载其他应用程序使用的容器.在您要添加的容器ID的行中,选中复选框.Xcode更新权利文件中的容器ID列表.

If necessary, click the Refresh button below the Containers table to download containers from Member Center that are used by other apps.In the row of the container ID you want to add, select the checkbox.Xcode updates the list of container IDs in the entitlements file.

下面的屏幕截图显示了Curator and Gallery应用程序,它们共享Gallery应用程序的默认容器.

The screenshot below shows the Curator and Gallery app sharing the Gallery app’s default container.

或者,创建一个由多个应用共享的自定义容器.

Alternatively, create a custom container shared by multiple apps.

重要提示:只有团队管理员才能创建容器.如果您是个人,则您是一个人团队的团队代理(具有管理员权限).

Important: Only team admins can create containers. If you are an individual, you are the team agent (with admin privileges) for your one person team.

创建自定义容器

如果选择了使用默认容器",则选择指定自定义容器".

If "Use default container" is selected, select "Specify custom containers."

单击表格底部的添加按钮(+).在出现的对话框中,输入要添加的容器的标识符.

Click the Add button (+) at the bottom of the table.In the dialog that appears, enter an identifier for the container you want to add.

警告:您无法删除容器ID,因此请仔细选择容器ID.

Warning: You can’t delete a container ID, so choose the container ID carefully.

容器ID以iCloud开头.后跟一个反向DNS表示法的字符串,如iCloud.com.example.gkumar1.SharedGallery容器ID.

A container ID begins with iCloud. followed by a string in reverse DNS notation, as in the iCloud.com.example.gkumar1.SharedGallery container ID.

单击确定".

Xcode将新的容器ID添加到Xcode项目授权文件和成员中心.

Xcode adds the new container ID to the Xcode project entitlements file and to Member Center.

如果您要与其他应用共享新的容器ID,请按照将容器添加到应用中的说明将容器添加到该应用.

If you want to share the new container ID with another app, add the container to the app, as described in Add Containers to an App.

验证您的步骤

您可以在iCloud设置或会员中心中查看团队的所有容器ID.在会员中心中,您还可以添加容器并编辑容器的名称.

You can view all the container IDs for your team in the iCloud settings or Member Center. In Member Center, you can also add containers and edit the name of containers.

要在会员中心中查看容器ID

To view container IDs in Member Center

在会员中心"中,选择证书,标识符和凭证".个人资料.在标识符"下,选择"iCloud容器".

In Member Center, select Certificates, Identifiers & Profiles.Under Identifiers, select iCloud Containers.

这篇关于在iOS中跨应用程序共享UDP数据(后台/前景或分屏多任务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 08:00