Xamarin: Enable microphone from webview for iOS device - xamarin

I'm using Xamarin.Forms.WebView to display a website in my Xamarin application. The rendered website requires the user to record audio using microphone. The recording works fine when I open the website in safari browser on iPhone and iPad but doesn't work when opened from WebView. I also noticed that when I open the website in browser it asks permission to access microphone but that doesn't happen in WebView.

Try to Request Authorization for Media Capture on iOS before your start recording:
AVCaptureDevice.RequestAccessForMediaType(AVMediaType.Audio, (bool isAccessGranted) => {
//if has access
if (isAccessGranted)
{
//do something
}
//if has no access
else
{
//show an alert
}
});
Recording audio or video always requires explicit permission from the user
Refer: requestaccessformediatype

Related

Xamarin - White screen on ComposeEmail

Using a physical android device.
When ComposeEmail is called, the email client opens.
Once the email client opens, the app goes to white screen.
If I go back to the app it will stay on white screen.
If I hit the back button I will be brought to the login screen.
Does there need to be some session management here if an external app opens?
public async void SendEmail(EmailMessage message) {
await Xamarin.Essentials.Email.ComposeAsync(message);
}
According to your description, you want to solve the problem of the white screen of the application. You can implement the operation you want in the OnResume method in the App.xaml.cs class, OnResume will be called when the app goes from the background to the app interface.
In Xamarin, the official support for using Email is provided. You can use Xamarin.Essentials: Email, and it will not show a white screen interface.Information about using Xamarin.Essentials: Email can be found at :Xamarin.Essentials: Email.

Can I send message directly from Safari Web Extension’s background page to Native App?

I am developing a safari web extension. I need send data from Web Extension’s background page to native app. Native app gets this message and signs it with USB key to generate a signature value. Then Native app sends the signature value back to background page.
Messaging a Web Extension’s Native App
First, I create a port in background.js
let port = browser.runtime.connectNative("application.id");
Add a listener to that port to receive message from Native App,as follow:
port.onMessage.addListener(function(message) {
console.log("Received native port message:");
console.log(message);
});
In my native app, I can send message to background page with following codes:
SFSafariApplication.dispatchMessage(withName: "Hello from App",
toExtensionWithIdentifier: extensionBundleIdentifier,
userInfo: ["AdditionalInformation": "Goes Here"],
completionHandler: { (error) -> Void in
os_log(.default, "Dispatching message to the extension finished")
})
But how can I send message from background page to Native App?
In “Messaging a Web Extension’s Native App” demo, messages are send by following code:
port.postMessage("Hello from JavaScript Port");
But there are no codes to show how to receive this message in native app.
In native app, How can I receive messages sent by “postMessage” from background page? If you can provide a demo with object-C, I will be very grateful. Thanks!
Found the following answer to your question in the WWDC'20 session Meet Safari Web Extensions
App ⭤ extension:
Shared NSUserDefaults from an app group, or NSXPCConnection
See also WWDC NOTES

How to open up a zoom meeting url in device's browser in xamarin.forms?

I want to open up zoom meeting url from my app in device's browser, i.e. Safari in iOS and Google chrome in Android.
Here is the url of zoom meeting: Meeting ID
I have successfully opened up this url in browser using Xamarin.Essential:
public async void Button_Clicked(System.Object sender, System.EventArgs e)
{
var zoomMeetUrl = "https://us04web.zoom.us/j/7850637100?
pwd=bnJwWC8xOHZod2VyMzZlMFAzUkJ5QT09";
await Browser.OpenAsync(zoomMeetUrl, BrowserLaunchMode.SystemPreferred);
}
But in iOS when I click on Launch meeting button in browser it gives this error message:
Safari cannot Open the Page because the Address Is Invalid
Does anyone know, how to fix this problem?
Note: Zoom app is installed in my device, still it gives same message.

Apple Pay on web Merchant validation

I Managed to retrieve merchantSession object from Apple Pay server as below. I used Sandbox Test (Setup on itunesconnect and login the sandbox account on iphone and added tested visa card)
{
"epochTimestamp":15065...20,
"expiresAt":1506527672620,
"merchantSessionIdentifier":"2EF498A9E...C24",
"nonce":"f32....9",
"merchantIdentifier":"7941CB932...DE2",
"domainName":"mywebsite.com",
"displayName":"My Test Shop",
"signature":"30800609....0000"
}
However, in the Apple Pay pop-up sheet, it still stuck at "Processing", what do I need to do to able to process the next stage to show the "Touch Id"?
Also, below is my code snippet for onvalidatemerchant:
session.onvalidatemerchant = (event) => {
console.log("Validate merchant");
const validationURL = event.validationURL;
getApplePaySession(event.validationURL).then(function(response) {
console.log(response);
session.completeMerchantValidation(response);
});
};
Now if all the below are met, the payment sheet should be displayed on the iPhone. You should verify several things:
Your Mac and iPhone are connected to the same iCloud test account
Both are on the same WiFi
HandOff is on
AirDrop is on
Bluetooth is on
A simple check to see if they are connected is to open a browser on the iPhone/Mac and see it on the other device.

OAuth Approval Page won't fit on iPhone 4

The page used to give approval to a third pary app at https://www.yammer.com//dialog/oauth is called when using the Log In With Yammer button.
When viewed on an iPhone 4 screen the Approve and Deny buttons are off the bottom of the screen, and the page isn't scrollable, so you can never get to them.
Are we missing something, or is this process completely impossible in a browser of that resolution. Any workarounds ?
We have encountered the same issue on a recent project that uses Yammer as an oAuth provider and small screen heights can not click the approve button.
We have opted to use JavaScript client detection to send a custom browser message to these users, the custom message advises users to visit the page from their desktop on a one time only basis.
The next time they visit the page from their mobile device they will be authed and will be able to get past the next stage.
The lowest sized screen that could still auth on Yammer natively had a window.height of 460 hence the solution below to notify these users:
jQuery(document).ready(function () {
if (jQuery(window).height() < 460) {
jQuery('#wpoa-title').html("IMPORTANT: ");
}
});

Resources