nativescript-community / ui-webview

Extended WebView which adds many options such as custom scheme handlers, JavaScript execution, URL capturing, and more.
Apache License 2.0
13 stars 7 forks source link

Missing callback in event declaration [RequestPermissionsEventData] in TS #6

Open mobifly-dev opened 2 years ago

mobifly-dev commented 2 years ago

Which platform(s) does your issue occur on?

Problem description

Simple thing but important - there is no callback declaration in event RequestPermissionsEventData in TypeScript. Without calling this callback the WebRTC will not start, even the permissions will be granted.

This callback is implemented in the plugin, but there is no proper declaration available.

Code

Instead of this:

export interface RequestPermissionsEventData extends WebViewExtEventData {
    eventName: EventNames.RequestPermissions;
    url: string;
    permissions: string[];
}

Should be this:

export interface RequestPermissionsEventData extends WebViewEventData {
    eventName: EventNames.RequestPermissions;
    url: string;
    permissions: RequestPermissionsString[];
    callback: (response: boolean) => void;
}

as was on @nota/nativescript-webview-ext plugin (which this is based on).

Currently needs to use ts-ignore to compile TS with no declaration ie.

webview.on(AWebView.requestPermissionsEvent, (arg: RequestPermissionsEventData) => {
            const requiredAndroidPermissions = arg.permissions
                .map((p) => {
                    (...)
                    return p;
                })
                .filter((p) => !!p);

            permissions
                .requestPermissions(requiredAndroidPermissions)
                //@ts-ignore
                .then(() => arg.callback(true))
                //@ts-ignore
                .catch(() => arg.callback(false));
        });

Please update this declaration on next version. Thanks.