-
Notifications
You must be signed in to change notification settings - Fork 55
Option to use GeckoView PermissionDelegate #145
Comments
Hi @soend . There is no "generic" way to do that in BlazorMobile, i mean for all platform simultaneously, as it's very specific to the webview implementation, However you can do this in two way:
The last one doesn't require to override anything at Browser level, and it may be more convenient if you find a Xamarin.Forms API that can do geolocation management directly, or any other compatible NuGet package. If you really want to implement this directly at the WebView level on Android you must:
Then like i said by mail to someone recently: BlazorMobile don’t use the PromptDelegate functionality at the moment, maybe this is something I have missed, but I never required to override the default behavior on this. So on your side, the only things you have to do:
It must then work. |
Thanks again for a quick response. Your answere clears up some of it and gives me possible ways to continue. Since the goal is a hybrid-app then creating custom implementations for different platforms sounds not so great option. That leaves me to use Xamarin.Forms what i am totally ok with. |
Thanks ! Forgot to specify that the override i mention is for the OnNewSession virtual method on the renderer. Take a look at the source code of the BlazorWebViewRenderer, on the OnNewSession, you should see multiple delegate override, as an exemple. |
Quick question about this topic, when creating solution with using BlazorMobile.Templates then in which project should i create my custom renderer in to be able to inherit from BlazorWebViewRenderer? |
From memory, you should:
Then do what you want with the renderer! However, if you see that something is missing if not going through the Blazor Webview instanciator helper, tell me, that will mean that we must add a mecanism to forward the custom implementation when needed to the plugin. |
Thanks for the help. This is my first time using custom renderers in xamarin. The key to get it working was adding the ExportRenderer attribute to my custom renderers classes namespace.
For example now when website is requesting to use browsers Geolocation then first the |
Congratulation ! Good to know you found how to finish ! And yes, when i was talking about "listening to your class" it was about the ExportRenderer attribute. |
Has there been any changes in the BlazorMobile side what could stop this from working? |
Are you talking about GeckoView ? |
Talking about GeckoView and renderer used to get permission delegate to work. Why i am asking is because after updating it seems like my custom permission handler never gets called by geckoview. |
There is indeed some changes, as BlazorMobile is now implementing a specific PromptDelegate for managing access for file input and else. See the actual code here: https://github.com/Daddoon/BlazorMobile/blob/master/src/BlazorMobile.Android/Renderer/BlazorGeckoViewRenderer.cs There is now this line: _session.PromptDelegate = new BlazorGeckoViewPromptDelegate(this); I think the best way to resolve your issue is to:
|
I think i missing something, how does this affect PermissionDelegate? This looks just like implementation to handle PromptDelegate. I would assume the implementation i showd here should still work #145 (comment)? |
Sorry, i missread your text ! You are right, i didn't implement a permission delegate. I know some dynamic permission may be asked while using FileUpload feature, but i'm not relying on a override of the PermissionDelegate, as i don't use it. But actually...What is not working anymore on your app with Permission delegate ? |
Hi @soend , did you manage to fix your issue ? |
No, for some reason the PermissionDelegate is just not called by geckoview. (Im really thinking of just going with pure blazor PWA now since having too many issues) |
I don't think there is any changes on that part of the code, but i may be wrong. PWA may be totally fine for your project.
|
Add option to use
PermissionDelegate
to request users permission. For example if my blazor app wants to use geolocation the user has to allow that.More info about it here: Working with Site Permissions
The text was updated successfully, but these errors were encountered: