Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor MAUI - Clipboard Android - NotAllowedError: Write permission denied #6846

Closed
wizd opened this issue May 5, 2022 · 5 comments
Closed
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android 🤖 s/needs-info Issue needs more info from the author t/bug Something isn't working

Comments

@wizd
Copy link

wizd commented May 5, 2022

Description

When try to set clipboard, error popup.
Android Emulator - Android_Emulator_31_5554 5_5_2022 4_25_47 PM

Steps to Reproduce

@code {
[Parameter] public string Text { get; set; }

private async Task CopyTextToClipboard()
{
    await JSRuntime.InvokeVoidAsync("clipboardCopy.copyText", Text);
}

}

in js:

    window.clipboardCopy = {
        copyText: function (text) {
            navigator.clipboard.writeText(text).then(function () {
                alert("Copied to clipboard!");
            })
                .catch(function (error) {
                    alert(error);
                });
        }
    };

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No response

Relevant log output

No response

@wizd wizd added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 5, 2022
@Redth Redth added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label May 5, 2022
@javiercn
Copy link
Member

javiercn commented May 5, 2022

@wizd thanks for contacting us.

It's very likely that you need to grant permissions to the webview to be able to copy things to the clipboard.

Blazor Hybrid exposes the underlying webview configuration for different platforms through a couple of events in Blazor Webview:

  • BlazorWebViewInitializing gives access to the settings used to create the WebView on each platform if there are any available.
  • BlazorWebViewInitialized gives access to the WebView to allow further configuring the settings.

These events are exposed by the BlazorWebview control and you can use the preferred patterns on each platform to attach an event handler and make any necessary tweaks.

@javiercn
Copy link
Member

javiercn commented May 5, 2022

@guardrex can we find a place to document how to configure the underlying webview platform?

Essentially, somewhere in the docs to put this comment:

Blazor Hybrid exposes the underlying webview configuration for different platforms through a couple of events in Blazor Webview:

  • BlazorWebViewInitializing gives access to the settings used to create the WebView on each platform if there are any available.
  • BlazorWebViewInitialized gives access to the WebView to allow further configuring the settings.

These events are exposed by the BlazorWebview control and you can use the preferred patterns on each platform to attach an event handler and make any necessary tweaks.

@javiercn
Copy link
Member

javiercn commented May 5, 2022

@wizd let us know if you still have issues after this.

@javiercn javiercn added s/needs-info Issue needs more info from the author and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels May 5, 2022
@ghost
Copy link

ghost commented May 5, 2022

Hi @wizd. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@mkArtakMSFT
Copy link
Member

Closing as this has already been documented here: https://docs.microsoft.com/en-us/aspnet/core/blazor/hybrid/?view=aspnetcore-6.0#-configuration

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
@samhouts samhouts added the t/bug Something isn't working label Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android 🤖 s/needs-info Issue needs more info from the author t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants