cordova-plugin-openwith icon indicating copy to clipboard operation
cordova-plugin-openwith copied to clipboard

PDF Documents

Open sc-keyzo opened this issue 4 years ago • 7 comments

Hi

i'm trying to use your plugin to receive PDF documents from other iPad apps but not having any success. This is the command i use to enable the plugin:

cordova plugin add cc.fovea.cordova.openwith --variable IOS_URL_SCHEME=keyzoopenwith --variable IOS_UNIFORM_TYPE_IDENTIFIER=com.adobe.pdf

The cordova app compiles ok and runs on my iPad however, the app does not show up in the "Copy to" form of any other apps that handle PDF document.

If i reconfigure the plugin to look for public.image, the same as the example you provide, then all works ok.

Am i missing a configuration step somewhere or is this a bug?

thanks

sc-keyzo avatar Jun 16 '20 10:06 sc-keyzo

Hi, same issue. @sc-keyzo did you made any progress?

perelin avatar Jun 28 '20 10:06 perelin

@perelin @sc-keyzo I made this changes to ShareExtension-Info.plist to solve this issue

...
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
    SUBQUERY (
        extensionItems,
        $extensionItem,
            SUBQUERY (
                $extensionItem.attachments,
                $attachment,
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
            ).@count == $extensionItem.attachments.@count
    ).@count == 1
	</string>
				...
</dict>
...

And use public.data as uti

Source: https://pspdfkit.com/blog/2016/hiding-action-share-extensions-in-your-own-apps/

axel012 avatar Jul 01 '20 01:07 axel012

@axel012 Thanks for posting this, i will try it out and let you know how i get on

sc-keyzo avatar Jul 02 '20 11:07 sc-keyzo

I'm getting error: unable to read property list from file: /Users//cordova/platforms/ios/ShareExtension/ShareExtension-Info.plist: The operation couldn’t be completed. (XCBUtil.PropertyListConversionError error 1.) (in target 'ShareExt' from project '') from xcode then. What can I do?

mbohlaender avatar Oct 01 '20 11:10 mbohlaender

Hi, it's potentially just a typo, here's my working plist

`

    <dict>
            <key>CFBundleDevelopmentRegion</key>
            <string>en</string>
            <key>CFBundleDisplayName</key>
            <string>OpenWithItThree</string>
            <key>CFBundleExecutable</key>
            <string>$(EXECUTABLE_NAME)</string>
            <key>CFBundleIdentifier</key>
            <string>$(PRODUCT_BUNDLE_IDENTIFIER).shareextension</string>
            <key>CFBundleInfoDictionaryVersion</key>
            <string>6.0</string>
            <key>CFBundleName</key>
            <string>$(PRODUCT_NAME)</string>
            <key>CFBundlePackageType</key>
            <string>XPC!</string>
            <key>CFBundleShortVersionString</key>
            <string>1.0.0</string>
            <key>CFBundleVersion</key>
            <string>1.0.0</string>
            <key>NSExtension</key>
            <dict>
                    <key>NSExtensionAttributes</key>
                    <dict>
                        <key>NSExtensionActivationRule</key>
                        <string>
                        SUBQUERY (
                            extensionItems,
                            $extensionItem,
                                SUBQUERY (
                                    $extensionItem.attachments,
                                    $attachment,
                                    ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf"
                                ).@count == $extensionItem.attachments.@count
                        ).@count == 1
                        </string>
                    </dict>
                    <key>NSExtensionMainStoryboard</key>
                    <string>MainInterface</string>
                    <key>NSExtensionPointIdentifier</key>
                    <string>com.apple.share-services</string>
            </dict>
    </dict>
`

sc-keyzo avatar Oct 01 '20 13:10 sc-keyzo

Thanks, app is build again. But unfortunately I'm still not able to import a document inside my app. It's just not shown as possibility in share menu.

Here's my ShareExtension-Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleDisplayName</key>
        <string>MyApp</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER).shareextension</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>$(PRODUCT_NAME)</string>
        <key>CFBundlePackageType</key>
        <string>XPC!</string>
        <key>CFBundleShortVersionString</key>
        <string>4.4.9</string>
        <key>CFBundleVersion</key>
        <string>4.4.9</string>
        <key>NSExtension</key>
                    <dict>
                            <key>NSExtensionAttributes</key>
                            <dict>
                                <key>NSExtensionActivationRule</key>
                                <string>
                                SUBQUERY (
                                    extensionItems,
                                    $extensionItem,
                                        SUBQUERY (
                                            $extensionItem.attachments,
                                            $attachment,
                                            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" OR
                                            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" OR
                                            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
                                            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
                                        ).@count == $extensionItem.attachments.@count
                                ).@count == 1
                                </string>
                            </dict>
                            <key>NSExtensionMainStoryboard</key>
                            <string>MainInterface</string>
                            <key>NSExtensionPointIdentifier</key>
                            <string>com.apple.share-services</string>
                    </dict>
    </dict>
</plist>

Do you @sc-keyzo or @axel012 have any ideas if there is something wrong? Do I forgot to configure something else? Btw UTI is set to: "IOS_UNIFORM_TYPE_IDENTIFIER": "public.content"

mbohlaender avatar Oct 05 '20 07:10 mbohlaender

maybe help https://github.com/sanek-mizin/cordova-plugin-openwith

sanek-mizin avatar Oct 28 '20 11:10 sanek-mizin