如何将文本从 iOS Notes 应用程序导出到我的应用程序?
How do I export text from iOS Notes app to my app?
我知道这是可能的,而且很多大型应用程序都会这样做,但我无法在 UTI、扩展、UIActivityTypes 等中找出我需要为此特别使用的拼写。我正在尝试将我的应用程序添加到当您在 iOS 上点击 Notes 应用程序中的导出按钮时出现的应用程序列表,因为我希望能够在笔记中重复和安全地提取一堆文本将它发送到我的应用程序。
I want my app to appear in this list, exporting directly from Notes. 这个问题似乎有重复,声称 "exporting from Notes app is not possible for third party apps",但我认为他们现在错了,或者回答了不同的问题,因为正如您在上面的截图,Messenger 显然可以做到这一点。
注册 UTI 似乎无法帮我完成这件事。我继续将我的应用程序注册到各种 UTI,但所有发生的事情都是我的应用程序最终出现在像 this one, which appears when trying to open a txt file 这样的弹出窗口中,这不是我想要的。除非有其他一些不符合我需要使用的 public.data 或 public.content 的 UTI,在这种情况下我很乐意听到它。
我使用了我分配的支持请求之一来询问 Apple,经过一段时间来回,我能够得到我的答案!他们是这样说的:
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
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
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
我还发现有关提供激活规则的部分非常混乱,这个答案对此有所帮助:
我知道这是可能的,而且很多大型应用程序都会这样做,但我无法在 UTI、扩展、UIActivityTypes 等中找出我需要为此特别使用的拼写。我正在尝试将我的应用程序添加到当您在 iOS 上点击 Notes 应用程序中的导出按钮时出现的应用程序列表,因为我希望能够在笔记中重复和安全地提取一堆文本将它发送到我的应用程序。
I want my app to appear in this list, exporting directly from Notes. 这个问题似乎有重复,声称 "exporting from Notes app is not possible for third party apps",但我认为他们现在错了,或者回答了不同的问题,因为正如您在上面的截图,Messenger 显然可以做到这一点。
注册 UTI 似乎无法帮我完成这件事。我继续将我的应用程序注册到各种 UTI,但所有发生的事情都是我的应用程序最终出现在像 this one, which appears when trying to open a txt file 这样的弹出窗口中,这不是我想要的。除非有其他一些不符合我需要使用的 public.data 或 public.content 的 UTI,在这种情况下我很乐意听到它。
我使用了我分配的支持请求之一来询问 Apple,经过一段时间来回,我能够得到我的答案!他们是这样说的:
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
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
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
我还发现有关提供激活规则的部分非常混乱,这个答案对此有所帮助: