Cordoba Windows 10 - Native call exception with command - notification

I am having problems with my Windows 10 cordova application.

I try to use navigator.notification.confirm, but it keeps throwing me this error

Native call exception with the command :: Notification :: confirm :: exception = WinRTError: parameter is invalid

I run this command on another page and it works fine. I don’t know why it works on one page and not another.

This is the code for my index page - WORKS FINE

navigator.notification.confirm(
    'This will download new data, do you want to confirm?',
    'callback',
    'Are you sure?',
    ['Refresh', 'Cancel']
)

However, the code below doesn't work at all, and I don't know why at all

navigator.notification.confirm(
    'Please select an option',
    ImageCaptureInput.currentInstance.onConfirm2,
    'Photo / video',
    ['Photo','Cancel','Video']     
);

It works for me on WP8, Android and iOS, and it works great. Windows 10 throws this unknown error. Google crawling and quick browsing did not help here.

Any help would be greatly appreciated.

EDIT:

Visual Studio. , navigator.notification.

0x800a139e - JavaScript runtime error: InvalidAccessError
Exception was thrown at line 221, column 13 in ms-appx-web://cordova.platform.windowsUWP/www/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js
0x80070057 - JavaScript runtime error: The parameter is incorrect.
Exception was thrown at line 240, column 13 in ms-appx-web://cordova.platform.windowsUWP/www/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js

2ND EDIT

, showAsync() ,

confirm:function(win, loseX, args) {

    if (isAlertShowing) {
        var later = function () {
            module.exports.confirm(win, loseX, args);
        };
        alertStack.push(later);
        return;
    }

    isAlertShowing = true;

    try {
        var message = args[0];
        var _title = args[1];
        var buttons = args[2];

        var md = new Windows.UI.Popups.MessageDialog(message, _title);

        buttons.forEach(function(buttonLabel) {
            md.commands.append(new Windows.UI.Popups.UICommand(buttonLabel));
        });

        md.showAsync().then(function(res) {
            isAlertShowing = false;
            var result = res ? buttons.indexOf(res.label) + 1 : 0;
            if (win) {
                win(result);
            }
            if (alertStack.length) {
                setTimeout(alertStack.shift(), 0);
            }

        });
    } catch (e) {
        // set isAlertShowing flag back to false in case of exception
        isAlertShowing = false;
        if (alertStack.length) {
            setTimeout(alertStack.shift(), 0);
        }
        // rethrow exception
        throw e;
    }
},
+4

Source: https://habr.com/ru/post/1671260/


All Articles