{"id":47070,"date":"2020-04-23T10:09:35","date_gmt":"2020-04-23T17:09:35","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/xamarin\/?p=47070"},"modified":"2020-08-31T15:19:10","modified_gmt":"2020-08-31T22:19:10","slug":"xamarin-essentials-now-with-permissions-app-theme-authentication","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/xamarin-essentials-now-with-permissions-app-theme-authentication\/","title":{"rendered":"Xamarin.Essentials: Now with Permissions, App Theme, &#038; Authentication"},"content":{"rendered":"<p>Since the first release of <a href=\"http:\/\/docs.microsoft.com\/xamarin\/essentials?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">Xamarin.Essentials<\/a>, developers have enjoyed the simplification of complex native features into a single cross-platform library. They can do this across iOS, Android, UWP, Tizen, watchOS, and even tvOS! No matter what type of app you are writing, there is absolutely something in Xamarin.Essentials for you. With the recent release of Xamarin.Essentials 1.5, even more cross-platform capabilities are unlocked for developers. Let us review just a few features that you can access right now. <center>\n  <img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2018\/12\/Essentials.png\" alt=\"Logo for Xamarin.Essentials\" width=\"426\" height=\"272\" class=\"aligncenter size-full wp-image-40907\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2018\/12\/Essentials.png 426w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2018\/12\/Essentials-300x192.png 300w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/>\n<\/center><\/p>\n<h2><a href=\"https:\/\/docs.microsoft.com\/xamarin\/essentials\/app-theme?WT.mc_id=essentialsupdates-blog-jamont\">App Theme<\/a> Just about every operating system has fully embraced dark mode for apps. Checking what the user has selected as their device default should be easy. Which is why we included a new way to select the requested theme.<\/h2>\n<pre><code>AppTheme appTheme = AppInfo.RequestedTheme;\n When using this new API and dynamic themes, easily enable your app to react to light\/dark mode changes: \n<\/code><\/pre>\n<p><center>\n  <img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/04\/App-Theme-Support-in-Xamarin.Essentials.gif\" alt=\"Image App Theme Support in Xamarin Essentials\" width=\"245\" height=\"507\" class=\"aligncenter size-full wp-image-47072\" \/>\n<\/center> Checkout the<\/p>\n<p><a href=\"https:\/\/github.com\/xamarin\/app-contacts?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">MyContacts sample on GitHub<\/a> for a real-world sample. Then watch the Xamarin.Essentials API of the Week on App Theme: <center><\/p>\n<p><iframe src=\"https:\/\/channel9.msdn.com\/Shows\/XamarinShow\/Theme-Detection-XamarinEssentials-API-of-the-Week\/player\" width=\"560\" height=\"315\" allowFullScreen frameBorder=\"0\" title=\"App Theme Detection (Xamarin.Essentials API of the Week) - Microsoft Channel 9 Video\"><\/iframe><\/p>\n<p><\/center> \u00a0<\/p>\n<h2>Permissions Want to use geolocation, contacts, or the camera? You will need to ask for permission from your users. Xamarin.Essentials makes this easier than ever with just a few lines of code. Simply add the permissions into your application configuration, then check and request permissions from your shared code:<\/h2>\n<pre><code>public async Task&lt;permissionstatus&gt; CheckAndRequestLocationPermission()\n{\n    var status = await Permissions.CheckStatusAsync&lt;Permissions.LocationWhenInUse&gt;();\n    if (status != PermissionStatus.Granted)\n    {\n        status = await Permissions.RequestAsync&lt;Permissions.LocationWhenInUse&gt;();\n    }\n\n    \/\/ Additionally could prompt the user to turn on in settings\n\n    return status;\n}\n&lt;\/permissionstatus&gt;\n<\/code><\/pre>\n<p><center>\n  <img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/04\/Check-Permissions-with-Xamarin.Essentials.gif\" alt=\"Image Check Permissions with Xamarin Essentials\" width=\"245\" height=\"507\" class=\"aligncenter size-full wp-image-47073\" \/>\n<\/center> Want more? Checkout the full Xamarin.Essentials API of the Week video:<\/p>\n<p><center><\/p>\n<p><iframe src=\"https:\/\/channel9.msdn.com\/Shows\/XamarinShow\/Permissions-XamarinEssentials-API-of-the-Week\/player\" width=\"560\" height=\"315\" allowFullScreen frameBorder=\"0\" title=\"Permissions (Xamarin.Essentials API of the Week) - Microsoft Channel 9 Video\"><\/iframe><\/p>\n<p><\/center><\/p>\n<h2><a href=\"https:\/\/docs.microsoft.com\/xamarin\/essentials\/web-authenticator?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">Web Authentication<\/a> Looking to add authentication to your mobile app? Xamarin.Essentials has you covered! It pairs beautifully with ASP.NET Core.<\/h2>\n<p><center>\n  <img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/04\/Web-Authentication-with-Xamarin.Essentials.gif\" alt=\"Image Web Authentication with Xamarin Essentials\" width=\"245\" height=\"507\" class=\"aligncenter size-full wp-image-47074\" \/>\n<\/center><\/p>\n<p><a href=\"https:\/\/twitter.com\/redth\">Jon Dick<\/a> just did a <a href=\"https:\/\/devblogs.microsoft.com\/xamarin\/authentication-xamarin-essentials-aspnet?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">full blog post<\/a> on how to setup web authentication with Xamarin.Essentials. If needed, read through Jon&#8217;s blog to get set up and then come back to this post.<\/p>\n<h2>What is Next? We are glad that you asked! At the<\/h2>\n<p><a href=\"https:\/\/channel9.msdn.com\/Events\/dotnetConf\/Focus-on-Xamarin\/Spectacular-Components-for-Xamarin-Apps\" rel=\"noopener noreferrer\" target=\"_blank\">.NET Conf &#8211; Focus on Xamarin<\/a> event, we announced our plans for Xamarin.Essentials 1.6. This release will include official support for macOS. Additionally, there will be integration of amazing community pull requests. PRs including <a href=\"https:\/\/github.com\/xamarin\/Essentials\/pull\/975?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">File Picker<\/a>, <a href=\"https:\/\/github.com\/xamarin\/Essentials\/pull\/1138\" rel=\"noopener noreferrer\" target=\"_blank\">Haptic Feedback<\/a>, <a href=\"https:\/\/github.com\/xamarin\/Essentials\/pull\/1190?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">App Actions<\/a>, <a href=\"https:\/\/github.com\/xamarin\/Essentials\/pull\/1010?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">Calendar<\/a>, and more! Be sure to Like and Follow <a href=\"https:\/\/github.com\/xamarin\/essentials\" rel=\"noopener noreferrer\" target=\"_blank\">Xamarin.Essentials on GitHub<\/a>.<\/p>\n<h2>Get Started Xamarin.Essentials is included with every project template! Make sure you upgrade to the latest version in NuGet today. Integrate Xamarin.Essentials into an existing app through our<\/h2>\n<p><a href=\"http:\/\/docs.microsoft.com\/xamarin\/essentials\/get-started?WT.mc_id=essentialsupdates-blog-jamont\" rel=\"noopener noreferrer\" target=\"_blank\">getting started documentation<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The latest version of Xamarin.Essentials (1.5) is packed full of beautiful native cross-platform APIs including app theme detection, permissions, web authentication, and so much more. Read on for details, samples, and guides to get started today.<\/p>\n","protected":false},"author":544,"featured_media":47072,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,1,291],"tags":[429,24],"class_list":["post-47070","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","category-xamarin","category-xamarin-platform","tag-components","tag-xamarin-essentials"],"acf":[],"blog_post_summary":"<p>The latest version of Xamarin.Essentials (1.5) is packed full of beautiful native cross-platform APIs including app theme detection, permissions, web authentication, and so much more. Read on for details, samples, and guides to get started today.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/47070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/544"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=47070"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/47070\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/47072"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=47070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=47070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=47070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}