如何将文本从iOS Notes应用程序导出到我的应用程序? [英] How do I export text from iOS Notes app to my app?

查看:147
本文介绍了如何将文本从iOS Notes应用程序导出到我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是可行的,许多大型应用程序都可以做到这一点,但是我无法在UTI,扩展,UIActivityTypes等中找出来,我特别需要为此使用拼写.我试图将我的应用程序添加到在iOS上的Notes应用程序中单击导出"按钮时出现的应用程序列表中,因为我希望能够在笔记中获取一堆文本并反复安全地发送到应用程序.

I know this is possible and is something many big apps do, but I can't figure out among UTIs, extensions, UIActivityTypes, etc. which spell I need to use for this in particular. I'm trying to add my app to the list of apps that appear when you hit the export button in the Notes app on iOS because I want to be able to take a bunch of text inside a note and repeatedly and safely send it into my app.

我希望我的应用显示在此列表中,直接从Notes中导出.这个问题似乎有很旧的副本,声称无法从Notes应用程序导出第三方应用程序",但是我认为它们现在是错误的,或者回答了一个不同的问题,因为如上所示屏幕截图,Messenger显然可以做到这一点.

I want my app to appear in this list, exporting directly from Notes. There appear to be duplicates of this question that are very old claiming that "exporting from Notes app is not possible for third party apps", but I think they're either now wrong or answering a different question because as you can see in the above screenshot, Messenger is plainly able to do this.

注册UTI看起来不适合我.我继续将我的应用程序注册到各种UTI,但是所有发生的事情是我的应用程序最终出现在

It does not look like registering UTIs gets this done for me. I went ahead and registered my app to all sorts of UTIs, but all that happens is my app ends up in popups like this one, which appears when trying to open a txt file, which is not what I'm looking for. Unless there is some other UTI that does not conform to public.data or public.content which I need to be using, in which case I'd be happy to hear it.

推荐答案

我使用分配给我的支持请求之一来询问Apple,经过一段时间后,我终于得到了答案!他们是这样说的:

I used one of my allotted support requests to ask Apple, and after some time and back and forth I was able to get my answer! Here is what they said:

您的项目缺少共享"应用扩展.首先查看 App Extension编程指南:

Your project is missing a Share app extension. Start by reviewing the App Extension Programming Guide: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/index.html#//apple_ref/doc/uid/TP40014214-CH20-SW1

特定于共享扩展点的信息:

Information specific to the Share extension point: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Share.html#//apple_ref/doc/uid/TP40014214-CH12-SW1

您无需在自己的计算机上注册文本内容类型 CFBundleDocumentTypes.就像您在样本中所做的一样.但是你 需要为扩展点提供激活规则,例如 如本文档的本节(标题为 声明共享或操作扩展的支持的数据类型):

You don’t need to register the text content type in your CFBundleDocumentTypes. as you’ve done in your sample. However, you will need to provide an activation rule for the extension point, such as the one shown in this section of the document (the section titled Declaring Supported Data Types for a Share or Action Extension): https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1

具体参见谓词示例,该谓词在以下情况下会激活扩展 随附com.adobe.pdf UTI的附件.您将需要 做类似的事情,以覆盖您想要的内容的UTI 您要使用的股票扩展名.作为起点,您可以消耗 文本与public.text UTI.有关更常见的UTI,请参阅此 文档:

See specifically the predicate example that activates the extension if an attachment with the com.adobe.pdf UTI is present. You will need to do something similar, to cover the UTIs for content you would like your share extension to consume. As a starting point, you can consume text with the public.text UTI. For more common UTIs, please see this document: https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1

我还发现有关提供激活规则的内容非常令人困惑,这个答案帮助解决了以下问题:

I also found the bits about providing an activation rule to be super confusing, and this answer helped that: How do I set NSExtensionActivationRule predicates?

这篇关于如何将文本从iOS Notes应用程序导出到我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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