iOS在地图上添加共享扩展 [英] iOS add share extension on maps

查看:198
本文介绍了iOS在地图上添加共享扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Apple的地图上添加分享扩展,有谁知道该怎么做。我尝试将NSExtensionAttributes设置如下,但它不起作用,我的APP没有显示在地图的共享表中。

I want to add share extension on Apple's Maps, does anyone know how to do. I try to set NSExtensionAttributes as below but it don't work, my APP doesn't show in the Maps's share sheet.

NSExtensionAttributes

NSExtensionActivationRule
  NSExetnsionActivationSupportsWebURLWithMaxCount
  NSExetnsionActivationSupportsWebPageWithMaxCount


推荐答案

我不确定为什么 NSExtensionActivationSupportsText 不适用于Maps,但是当我尝试时我得到相同的结果。

I'm not sure why NSExtensionActivationSupportsText doesn't work with Maps, but I get the same result when I try.

您需要的是更复杂的激活规则。将激活规则的类型设置为string,并使用 SUBQUERY 格式设置值。 com / library / ios / documentation / General / Conceptual / ExtensibilityPG / ExtensionScenarios.html#// apple_ref / doc / uid / TP40014214-CH21-SW1> App Extension Programming Guide 。当您这样做时,您可以请求一个或多个特定的UTI。地图将提供纯文本( public.plain-text ),其中等同于 NSExtensionActivationSupportsText 但显然不是。它还提供了一张位置卡( public.card )和一个URL( public.url )。

What you need is a more complex activation rule. Set the type of the activation rule to "string", and set up the value using the SUBQUERY format described in the App Extension Programming Guide. When you do that you can request one or more specific UTIs. Maps will provide plain text (public.plain-text), which should be equivalent to NSExtensionActivationSupportsText but apparently is not. It also provides a location card (public.card) and a URL (public.url).

UTI检查任何这些内容的激活规则看起来像

An activation rule that checks for any of these by the UTIs would look like

SUBQUERY(extensionItems, $extensionItem, SUBQUERY($extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text").@count >= 1).@count >= 1 OR SUBQUERY(extensionItems, $extensionItem, SUBQUERY($extensionItem.attachments, $attachment, SUBQUERY($attachment.registeredTypeIdentifiers, $uti, $uti UTI-CONFORMS-TO "public.url" AND NOT $uti UTI-CONFORMS-TO "public.file-url").@count >= 1).@count >= 1).@count >= 1 OR SUBQUERY(extensionItems, $extensionItem, SUBQUERY($extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard").@count >= 1).@count >= 1

这只是三个 SUBQUERY 条款,用于检查每个o那些UTI,或者在一起。

That's just three SUBQUERY clauses that check for each of those UTIs, OR-ed together.

根据您可以处理的数据,您可能希望减少它以仅涵盖您的扩展知道如何处理的UTI 。例如,如果你想要的只是URL,只使用那个部分:

Depending on what data you can handle, you might want to reduce that to cover only UTIs that your extension knows how to deal with. For example if all you want is the URL, only use that part:

SUBQUERY(extensionItems, $extensionItem, SUBQUERY($extensionItem.attachments, $attachment, SUBQUERY($attachment.registeredTypeIdentifiers, $uti, $uti UTI-CONFORMS-TO "public.url" AND NOT $uti UTI-CONFORMS-TO "public.file-url").@count >= 1).@count >= 1).@count >= 1

这个版本只是检查您是否获得了不是文件网址的网址。

This version just checks that you're getting a URL which is not a file URL.

地图提供的Apple地图网址类似于http://maps.apple.com/?q=37.332331,-122.031219&sll=37.332331,-122.031219

Maps provides an Apple Maps URL which will be something like http://maps.apple.com/?q=37.332331,-122.031219&sll=37.332331,-122.031219

如果您使用vcard UTI,您将获得 NSString 编码为 NSData的。如果你解码它,它看起来像这样:

If you use the vcard UTI, you'll get an NSString encoded into an NSData. If you decode it, it looks something like this:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//iOS 8.2//EN
N:;Shared Location;;;
FN:Shared Location
item1.ADR;type=HOME;type=pref:;;;;;;
item2.URL;type=pref:http://maps.apple.com/?q=37.332331\,-122.031219&sll=37.332331\,-122.031219
item2.X-ABLabel:map url
END:VCARD

这篇关于iOS在地图上添加共享扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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