jibon57 / nativescript-mediafilepicker

A complete file picker solution for NativeScript
Apache License 2.0
51 stars 39 forks source link

getFiles not triggered #127

Open marcocasadio opened 3 years ago

marcocasadio commented 3 years ago

When I select a file getFiles isn't triggered

✔ Component nativescript has 7.0.10 version and is up to date. ✔ Component @nativescript/core has 7.0.11 version and is up to date. ✔ Component @nativescript/ios has 7.0.3 version and is up to date. ✔ Component @nativescript/android has ^7.0.0 version and is up to date.

Before NS7, with NS6, it work correctly.

import { Mediafilepicker } from 'nativescript-mediafilepicker';

....
    mounted() {
        if (isIOS) {
            this.filePickerOptions = {
                ios: {
                    extensions: [kUTTypePDF, kUTTypeText, kUTTypeRTF, kUTTypeImage],
                    multipleSelection: true,
                }
            };
        } else {
            this.filePickerOptions = {
                android: {
                    extensions: ['txt', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'png', 'jpg'],
                    multipleSelection: true,
                }
            };
        }
    }
....

// *** Init picker ***
                    let mediafilepicker = new Mediafilepicker();

                    mediafilepicker.on("error", function (res) {
                        let msg = res.object.get('msg');
                        console.log("mediafilepicker error", msg);
                    });

                    mediafilepicker.on("cancel", function (res) {
                        let msg = res.object.get('msg');
                        console.log("mediafilepicker cancel", msg);
                    });

                    mediafilepicker.on("getFiles", function (res) {
                        let results = res.object.get('results');

                        console.dir("mediapicker results", results);
                        console.log("mediapicker file", results[0]);
                        console.log("mediapicker file src", results[0].file);
                    });

                    mediafilepicker.openFilePicker(this.filePickerOptions);
jerbob92 commented 3 years ago

As said on Slack, I can't get NS7 to work anymore with xCode 12, so I can't debug this. Would help me a ton if you try to do it.

jerbob92 commented 3 years ago

I just noticed that I missed a @NativeClass() in the iOS code. I just pushed 4.0.1, can you check if it's fixed @marcocasadio?

marcocasadio commented 3 years ago

it works! thank you @jerbob92

Upd4ting commented 3 years ago

@jerbob92 you would probably be interrested by this issue for your problem with NS7 and xCode 12.3 https://github.com/NativeScript/NativeScript/issues/9097#issuecomment-747554116