Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Page Properties
hiddentrue

Status

Status
colourYellowGreen
titlefor reviewapproved

Approver

Nadzeya Karaban

The File Import (or Open With) feature allows importing of “Open with…” feature enables transporting images and PDF files from other apps via iOS Share functionality.

Enabling your app to open PDFs and images allows your users to open any kind of files that are identified by the OS as PDFs or images. To integrate this feature, follow these steps:

1. Register PDF and image file types. Add the following to your Info.plist:

Code Block
languageswift
<key>CFBundleDocumentTypes</key>
<array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>PDF</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.adobe.pdf</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeName</key>
            <string>Images</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.jpeg</string>
                <string>public.png</string>
                <string>public.tiff</string>
                <string>com.compuserve.gif</string>
            </array>
        </dict>
</array>

You can also add these by going to your target’s Info tab and entering the values into the Document Types section.

In order to initiate Open with from your app’s Documents folder, add UISupportsDocumentBrowser to your Info.plist.

Read more about Document types in the Apple documentation.

2. Enable it inside Gini Bank SDK

In order to allow the Gini Bank SDK to handle files imported from other apps and to show the Open With tutorial in the Help menu, it is necessary to indicate it in the GiniBankConfiguration.

Code Block
languageswift
        let giniBankConfiguration = GiniBankConfiguration.shared
        ...
        ...
        giniBankConfiguration.openWithEnabled = true

3. Handle incoming PDFs and images

When your app is requested to handle a PDF or an image your AppDelegate’s application(_:open:options:) (Swift) method is called. You can then use the supplied URL to create a document as shown below.

In some cases, in particular when the LSSupportsOpeningDocumentsInPlace flag is enabled in your Info.plist file, reading data directly from the URL may fail. For that reason, GiniCapture uses the asynchronous UIDocument API internally which handles any of the potential security requirements.

In order to determine that the file opened is valid (correct size, correct type, and the number of pages below the threshold on PDFs), it is necessary to validate it before using it.

Gini Bank

...

languageswift

...

iOS’s Share functionality. Users can take a screenshot or choose an image or a PDF file and, by clicking the Share button, have their payment details automatically recognized. Then, users only need to check and confirm the transaction:

IMG_0004.PNGImage Added

For more information, see Open with (Share) Guide.