{"id":18246606,"url":"https://github.com/datvm/jspermissionhandler","last_synced_at":"2025-04-04T14:31:19.251Z","repository":{"id":208000136,"uuid":"720590429","full_name":"datvm/JsPermissionHandler","owner":"datvm","description":"A MAUI Blazor library to simplify permission management for Blazor Javascript APIs like camera, microphone (getUserMedia) or geolocation","archived":false,"fork":false,"pushed_at":"2023-11-19T03:07:48.000Z","size":219,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T08:49:27.470Z","etag":null,"topics":["blazor","camera","geolocation","getusermedia","javascript","maui","maui-blazor","microphone","permissions"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datvm.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-19T00:11:28.000Z","updated_at":"2024-08-12T12:19:29.000Z","dependencies_parsed_at":"2023-11-19T02:41:25.216Z","dependency_job_id":"c7a0d037-bc93-48e5-bc32-5ab2af8c743d","html_url":"https://github.com/datvm/JsPermissionHandler","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"4e0d257c1b913e205ca86d6bd2373cae5b3aa2c3"},"previous_names":["datvm/jspermissionhandler","datvm/mauiblazorpermission"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FJsPermissionHandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FJsPermissionHandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FJsPermissionHandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FJsPermissionHandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datvm","download_url":"https://codeload.github.com/datvm/JsPermissionHandler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247193988,"owners_count":20899408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","camera","geolocation","getusermedia","javascript","maui","maui-blazor","microphone","permissions"],"created_at":"2024-11-05T09:26:58.034Z","updated_at":"2025-04-04T14:31:18.742Z","avatar_url":"https://github.com/datvm.png","language":"C#","readme":"This is a MAUI Blazor library to simplify permission management for Blazor Javascript APIs like camera, microphone (through `getUserMedia`) or `geolocation`. This is accomplished hugely thanks to [MackinnonBuck/MauiBlazorPermissionsExample](https://github.com/MackinnonBuck/MauiBlazorPermissionsExample). It worked for many of my projects so it's time to pack it to easily reuse it.\n\nThis library is highly customizable and extensible. Most methods are `virtual` and can be overriden to fit your needs.\n\nSee a full demo project at [project Github](https://github.com/datvm/JsPermissionHandler/tree/master/JsPermissionHandlerDemo).\n\nThis package does not support Tizen.\n\n# Installation\n\nInstall the [NuGet package](https://www.nuget.org/packages/JsPermissionHandler) in your project:\n\n```ps\ndotnet add package JsPermissionHandler\n```\n\n# Setup Permissions\n\n## Windows\n\nYou do not need to do anything special to use this library on Windows.\n\n## Android\n\nAdd permissions to your `AndroidManifest.xml` file (in `Platforms/Android`).\n\n```xml\n\u003cuses-permission android:name=\"android.permission.CAMERA\" /\u003e\n\u003cuses-permission android:name=\"android.permission.RECORD_AUDIO\" /\u003e\n\u003cuses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\" /\u003e\n\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n```\n\nNote: only add what you need. For `getUserMedia` with audio, you need both `RECORD_AUDIO` and `MODIFY_AUDIO_SETTINGS`.\n\n## iOS\n\nAdd permissions to your `Info.plist` file (in `Platforms/iOS`).\n\n```xml\n\u003ckey\u003eNSLocationWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app requires access to your location. Please grant access to your precise location when requested.\u003c/string\u003e\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app requires access to your camera. Please grant access to your camera when requested.\u003c/string\u003e\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app requires access to your microphone. Please grant access to your microphone when requested.\u003c/string\u003e\n```\n\n# Add the Handler to your WebView\n\nIn your `MainPage.xaml.cs` file, add the following code:\n\n```cs\npublic MainPage()\n{\n    InitializeComponent();\n\n    new BlazorWebViewHandler()            \n        // Add whichever you need:\n        .AddCamera()\n        .AddMicrophone()\n        .AddGeolocation()\n        // blazorWebView is the name of your BlazorWebView\n        .AddInitializingHandler(blazorWebView);\n}\n```\n\nAnd that's it, you can now use your Javascript APIs in the Blazor Webview.\n\n# Additional permissions\n\nThe default `BlazorWebViewHandler` gives the three common permissions call `AddCamera`, `AddMicrophone` and `AddGeolocation`. If you need more, you need to inherit `PermissionHandler` and add your own. This is only needed for Android. For example:\n\n```cs\n// MyHandler.Android.cs\n\npublic class MyHandler : PermissionHandler\n{\n\tpublic MyHandler AddMyPermission() =\u003e\n        AddWebkitPermission(\n            [\n                (Manifest.Permission.ModifyAudioSettings, null),\n                (Manifest.Permission.RecordAudio, rationale),\n            ],\n            PermissionRequest.ResourceAudioCapture\n        );\n}\n```\n\n# Opening Permission panel\n\nUsually working with permissions flow requires to open the permission panel especially when user denies your app access to permission. This is done with the `PermissionHandler.OpenAppPermissionPanelAsync` static method.\n\n```cs\npublic static partial Task OpenAppPermissionPanelAsync(string? windowsScheme = null);\n```\n\n- `windowsScheme` is used on Windows only. You can specify which [Windows Settings panel](https://learn.microsoft.com/en-us/windows/uwp/launch-resume/launch-settings-app#ms-settings-uri-scheme-reference) to open. If `null`, the default is `ms-settings:appsfeatures-app` to open the settings of the current app (which would include permissions).\n![Windows Permission](https://github.com/datvm/JsPermissionHandler/assets/6388546/b4dd4310-7791-49e9-9509-4e52c584a351)\n- On Android, this method opens the app settings panel. It's not possible to open the permission panel directly.\n- On iOS, this method opens the app settings panel which includes the permissions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatvm%2Fjspermissionhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatvm%2Fjspermissionhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatvm%2Fjspermissionhandler/lists"}