Daddoon / BlazorMobile

Create full C# driven hybrid-apps for iOS, Android, UWP & Desktop with Blazor!
MIT License
413 stars 55 forks source link

IOS Webcam Access #218

Open nejis opened 4 years ago

nejis commented 4 years ago

Is there any solution/workaround for the current "ios Bug" for ios WebViews to Acces the Camera of an device?

Daddoon commented 4 years ago

I don’t what but you are talking about, but I assume that you are talking about something with the native webview.

At least, know that in the worst case, you can still call the camera API from native side (Xamarin).

If controlled from Blazor it would be:

nejis commented 4 years ago

Thats the problem i cant use the default contoll, because i need to use the navigator.mediadevices Api of the browser and do not want to write serveral version of the same logic. But in Ios is curenntly an bug on all webview Contols that prevent the using of this api. Only in Safary it self it works. So i need an workaround to get the stream of the camera devices, to polifill the api or somthing like that, for streaming and live processing in an existing blazor pwa.

Daddoon commented 4 years ago

I understand your issue.

From what i see and read, this issue is likely fixed in iOS 13.5.1 ? Can you take a look ?

I am refering to this:

https://stackoverflow.com/questions/59685235/camera-bug-on-ios-13-3-pwa https://bugs.webkit.org/show_bug.cgi?id=206219

If you still have issue, as this is a PWA InApp browser bug there is nothing more you can do except the tricks i mentionned, that are of course not specifically PWA standard.

Also, just double checking, do you have given any right in your app for camera access ? (even if you will be using it through webview). Like implementing this in your Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos.</string>
nejis commented 4 years ago

Unfortunately no. thats an other bug. it's this bug https://bugs.webkit.org/show_bug.cgi?id=208667

Daddoon commented 4 years ago

Seem that Apple is not wanting to fix this so fast. (https://stackoverflow.com/questions/45055329/does-webkit-in-ios-11-beta-support-webrtc/49467964#49467964 , https://developer.apple.com/forums/thread/134216 ).

Sorry, but if this kind of functionnality is mandatory for your app, i don't see any other solution at the moment than using the "native capabilities" of your app, i mean if you are using BlazorMobile for a standalone app, if it's a pure PWA, you are out of luck.

In my opinion, as you are working with Blazor, i would do 2 different interfaces implementation in C# as services for your WebRTC/Media functionnality. One that would call the regular implementation in javascript under the hood, and the other one that would do the "tricks" in native for getting the same informations and results for iOS.

It seem that there is some implementations of WebRTC for Xamarin and iOS for native side, you may try to implement them in native, depending the complexity of your needs of course.