j3k0 / cordova-plugin-openwith

Get your Cordova App in the O.S. "Share" menu on iOS and Android
MIT License
137 stars 114 forks source link

PDF Documents #104

Open sc-keyzo opened 4 years ago

sc-keyzo commented 4 years ago

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

perelin commented 4 years ago

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

axel012 commented 4 years ago

@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/

sc-keyzo commented 4 years ago

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

mbohlaender commented 3 years ago

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?

sc-keyzo commented 3 years ago

Hi, it's potentially just a typo, here's my working 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">

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

`

mbohlaender commented 3 years ago

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"

sanek-mizin commented 3 years ago

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