IOS adds an extension to maps
I want to add an extension to Apple Maps, does anyone know how. I am trying to set NSExtensionAttributes as shown below but it doesn't work, my APP doesn't show up in the Maps shared folder.
NSExtensionAttributes
NSExtensionActivationRule
NSExetnsionActivationSupportsWebURLWithMaxCount
NSExetnsionActivationSupportsWebPageWithMaxCount
source to share
I'm not sure why it NSExtensionActivationSupportsText
doesn't work with Maps, but I get the same result when I try.
What you need is a more complex activation rule. Set the activation rule type to "string" and configure the value in the format SUBQUERY
described in the Application Extensions Programming Guide . When you do, you can request one or more specific UTIs. Maps will provide plain text ( public.plain-text
), which should be equivalent NSExtensionActivationSupportsText
, but apparently not. It also provides location map ( public.card
) and url ( public.url
).
An activation rule that checks any of them with a UTI 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
These are just three sentences SUBQUERY
that test each of these UTIs, OR-ed together.
Depending on what kind of data you can handle, you can reduce this to only cover the UTIs that your extension knows how to deal with. For example, if all you want is a URL, only use this 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 are getting a URL that is not the URL of the file.
The maps contain an Apple Maps URL which will look like http://maps.apple.com/?q=37.332331,-122.031219&sll=37.332331,-122.031219
If you are using UART vcard you will get NSString
encoded in 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
source to share