IOS Safari URL UTI share sheet

随声附和 提交于 2021-01-27 07:15:38

问题


I am trying to pass the current URL from safari to my app using the safari share button and share sheet. I want this to go to my app and not have it be a share extension. From safari, the share sheet does not show my app. I have registered the following document types (UTI) without success:

public.url  
public.file-url 
public.url-name  

My app does show up from a pdf document share using com.adobe.pdf without any issues. Any help sharing the URL from safari would be most appreciated. I am also having a similar issue with using share button from a photo displayed from the apple app.

What are the correct UTI for safari url and a photo via the share button to properly appear on the share sheet? Thanks.

Bob


回答1:


  • Go to the project (root element in the Project Navigator) and select your Share target
  • Go to Info
  • Open NSEXtension -> NSExtensionAttributes -> NSExtensionActivationRule
  • For URL Support: Add NSExtensionActivationSupportsWebURLWithMaxCount underneath NSExtensionActivationRule (type is Number, the value is any number higher than 0 depending how many URL's you allow to handle in one share action)
  • For Photo and/or Video Support add NSExtensionActivationSupportsImageWithMaxCount and/or NSExtensionActivationSupportsMovieWithMaxCount
  • For other file types add NSExtensionActivationSupportsFileWithMaxCount

In the raw code of the Info.plist file of your Share target it will look like this:

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsFileWithMaxCount</key>
            <integer>10</integer>
            <key>NSExtensionActivationSupportsImageWithMaxCount</key>
            <integer>10</integer>
            <key>NSExtensionActivationSupportsMovieWithMaxCount</key>
            <integer>10</integer>
            <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
            <integer>1</integer>
        </dict>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>YourStoryboard</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
</dict>

NOTE for people who don't see their app appearing in Dropbox'es Export sheet: Dropbox passes a URL to the share sheet, you'd have to support NSExtensionActivationSupportsWebURLWithMaxCount



来源:https://stackoverflow.com/questions/43528568/ios-safari-url-uti-share-sheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!