Custom extension not registered and not opening files with AppArg on iOS

105 views
Skip to first unread message

P5music

unread,
Jun 3, 2021, 9:36:41 AM6/3/21
to CodenameOne Discussions

My CN1 app has to open data files with custom extension when the user selects one of them to be opened from the Files app, or another app (like opening it as e-mail attachment, for example).
The import/export feature works.

This is a part of the ios.plistInject string:


<key>UTExportedTypeDeclarations</key><array> <dict><key>UTTypeDescription</key><string>List of datatype</string><key>UTTypeConformsTo</key><array><string>public.json</string><string>public.database</string><string>public.data</string><string>public.text</string><string>public.content</string></array><key>UTTypeIdentifier</key><string>com.myapp.datatype</string><key>UTTypeTagSpecification</key><dict><key>public.filename-extension</key><array><string>ext</string></array><key>public.mime-type</key><array><string>application/json</string> </array> </dict> </dict> </array>

the ios.plistInject has also other keys that correspond to working features of the app, so it means that the plist injection is accepted and processed by XCode.

Instead, the custom extension is not registered in the system (iOS simulator).

The Swift counterpart of the CN1 app is able to register the extension, so when the data file with custom extension is displayed as json it shows its description
"List of datatype"

Only the file name is displayed instead with the CN1 app installed.

The CN1 app does not open the file if the user selects it in the Files app, and no option is available.

The following code is used, and it works on the CN1 simulator

// it is in the start() method
String arg=Display.getInstance().getProperty("AppArg",null);
        System.out.println("arg="+arg);
        if (arg!=null) importArg(arg);

Is that string in ios.plistInject wrong? It is the same of the Swift app, it was pasted from there in fact (see below).

Thanks in advance.

<key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeDescription</key>
            <string>List of datatype</string>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.json</string>
                <string>public.database</string>
                <string>public.data</string>
                <string>public.text</string>
                <string>public.content</string>
            </array>
            <key>UTTypeIdentifier</key>
            <string>com.myapp.datatype</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>ext</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>application/json</string>
                </array>
            </dict>
        </dict>
    </array>

Shai Almog

unread,
Jun 3, 2021, 11:13:30 PM6/3/21
to CodenameOne Discussions
So if I understand correctly your app appears correctly in the list of options for the file. But the arg isn't passed when you click on the app. On which version of iOS are you testing this?

P5music

unread,
Jun 4, 2021, 2:35:12 AM6/4/21
to CodenameOne Discussions
Sorry no,
Only the Swift version of my app is able to register the type, but that just means that the description is visible, so I think it is registered.
The feature is not yet developed.

Instead the feature is fully developed in the CN1 version and it works on the CN1 simulator.
But the CN1 app is not even able to register the type on the iOS simulator (the description is not displayed and the option to open with the app is not presented).
When selecting a file with custom extension the start method is not called, indeed the app is not even brought to the foreground.
No log messages are printed in the console about that part of code (they are when the app runs in the CN1 simulator).
So that code is not executed.

Regards

Shai Almog

unread,
Jun 5, 2021, 2:13:52 AM6/5/21
to CodenameOne Discussions
When you generate the xcode project can you review what's different between the project we generated and the one that works for you in Swift?
I'm guessing it's some different configuration in the plist or something of that type.

P5music

unread,
Jun 5, 2021, 3:16:57 AM6/5/21
to CodenameOne Discussions
Well there are differences between the two projects, they have almost the same features, but how could I compare them, what do you  mean?
If you mean the plist file, the ext registering part is the same.

However, have you a working sample, like Kitchen Sink, that has the feature working to inspect it?

Thanks

Shai Almog

unread,
Jun 5, 2021, 9:08:03 PM6/5/21
to CodenameOne Discussions
Maybe under Codename One Samples: https://github.com/codenameone/CodenameOne/tree/master/Samples
If there isn't anything there then probably not.
Reply all
Reply to author
Forward
0 new messages