Contents

activityViewController(_:dataTypeIdentifierForActivityType:)

For items that are provided as data, returns the UTI for the item.

Declaration

optional func activityViewController(_ activityViewController: UIActivityViewController, dataTypeIdentifierForActivityType activityType: UIActivity.ActivityType?) -> String

Parameters

  • activityViewController:

    The activity view controller object requesting information about the data item.

  • activityType:

    The selected activity type; may be nil.

Return Value

The UTI for the item.

Discussion

Providing the UTI allows services to handle specific data types in appropriate ways, such as an email service formatting an image to display in-line. If you provide items as NSData objects, implement this method to allow those services to better handle your data.

To ensure that Mail can handle an attachment that uses your exported UTI, include the UTExportedTypeDeclarations key in your app’s Info.plist file, describing the UTI and providing the MIME type for it. The following example shows how public.jpeg might be defined as an exported type (only the required keys are shown):

<key>UTExportedTypeDeclarations</key>
        <array>
            <dict>
                <key>UTTypeIdentifier</key>
                <string>public.jpeg</string>
                <key>UTTypeConformsTo</key>
                <array>
                    <string>public.image</string>
                    <string>public.data</string>
                </array>
                <key>UTTypeTagSpecification</key>
                <dict>
                    <key>com.apple.ostype</key>
                    <string>JPEG</string>
                    <key>public.filename-extension</key>
                    <array>
                        <string>jpeg</string>
                        <string>jpg</string>
                    </array>
                    <key>public.mime-type</key>
                    <string>image/jpeg</string>
                </dict>
            </dict>
        </array>

See Also

Providing information about the data items