uno.xamarin.essentials/README.md

114 строки
6.7 KiB
Markdown
Исходник Обычный вид История

# Xamarin.Essentials
2018-02-20 22:56:56 +03:00
Xamarin.Essentials gives developers essential cross-platform APIs for their mobile applications.
2018-03-02 22:28:42 +03:00
2018-10-20 22:32:07 +03:00
iOS, Android, and UWP offer unique operating system and platform APIs that developers have access to, all in C# leveraging Xamarin. It is great that developers have 100% API access in C# with Xamarin, but these APIs are different per platform. This means developers have to learn three different APIs to access platform-specific features. With Xamarin.Essentials, developers have a single cross-platform API that works with any iOS, Android, or UWP application that can be accessed from shared code no matter how the user interface is created.
2018-03-02 22:28:42 +03:00
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/xamarin/Essentials)
2018-03-02 22:28:42 +03:00
## Build Status
2018-03-10 05:25:49 +03:00
2018-03-10 19:16:54 +03:00
| Build Server | Type | Platform | Status |
|--------------|--------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| VSTS | Build | Windows | ![VSTS Build Status](https://devdiv.visualstudio.com/_apis/public/build/definitions/0bdbc590-a062-4c3f-b0f6-9383f67865ee/8538/badge) |
2018-04-06 21:07:19 +03:00
| Jenkins | Device Tests | macOS | [![Build Status](https://jenkins.mono-project.com/buildStatus/icon?job=Components-Essentials-DeviceTests-Mac)](https://jenkins.mono-project.com/job/Components-Essentials-DeviceTests-Mac) |
| App Center | Sample App | Android | [![Build status](https://build.appcenter.ms/v0.1/apps/7a1f46ca-ba2f-477e-aacc-ff013c7d5f7a/branches/master/badge)](https://appcenter.ms) |
| App Center | Sample App | iOS | [![Build status](https://build.appcenter.ms/v0.1/apps/43b39e9e-2b2b-482f-8afa-e9906334c85e/branches/master/badge)](https://appcenter.ms) |
2018-03-02 22:28:42 +03:00
## Sample App
Try out Xamarin.Essentials on your device!
* [Android Sample App](https://install.appcenter.ms/orgs/microsoft-liveplayer/apps/essentials-android/distribution_groups/public%20testers) via App Center.
2018-03-02 22:28:42 +03:00
## Installation
2018-10-20 22:32:07 +03:00
Xamarin.Essentials is available via:
2018-10-20 22:32:07 +03:00
* NuGet Official Releases: [![NuGet](https://img.shields.io/nuget/vpre/Xamarin.Essentials.svg?label=NuGet)](https://www.nuget.org/packages/Xamarin.Essentials)
Please read our [Getting Started with Xamarin.Essentials guide](https://docs.microsoft.com/xamarin/essentials/get-started) for full setup instructions.
## Documentation
2018-10-20 22:32:07 +03:00
Browse our [full documentation for Xamarin.Essentials](https://docs.microsoft.com/xamarin/essentials), including feature guides, on how to use each feature.
2018-02-20 22:56:56 +03:00
## Supported Platforms
2018-10-20 22:32:07 +03:00
2018-06-25 18:56:51 +03:00
Xamarin.Essentials is focused on the following platforms:
2018-02-20 22:56:56 +03:00
2018-10-20 22:32:07 +03:00
* iOS (10+)
* Android (4.4+)
* UWP (Fall Creators Update+)
## API Documentation
2018-06-25 18:56:51 +03:00
The following cross-platform APIs are available in Xamarin.Essentials:
2018-10-20 22:32:07 +03:00
* [Accelerometer](https://docs.microsoft.com/xamarin/essentials/accelerometer)
* [App Information](https://docs.microsoft.com/xamarin/essentials/app-information)
* [Battery](https://docs.microsoft.com/xamarin/essentials/battery)
* [Clipboard](https://docs.microsoft.com/xamarin/essentials/clipboard)
* [Compass](https://docs.microsoft.com/xamarin/essentials/compass)
* [Connectivity](https://docs.microsoft.com/xamarin/essentials/connectivity)
* [Device Display Information](https://docs.microsoft.com/en-us/xamarin/essentials/device-display)
* [Device Information](https://docs.microsoft.com/xamarin/essentials/device-information)
* [Email](https://docs.microsoft.com/xamarin/essentials/email)
* [File System Helpers](https://docs.microsoft.com/xamarin/essentials/file-system-helpers)
* [Flashlight](https://docs.microsoft.com/xamarin/essentials/flashlight)
* [Geocoding](https://docs.microsoft.com/xamarin/essentials/geocoding)
* [Geolocation](https://docs.microsoft.com/xamarin/essentials/geolocation)
* [Gyroscope](https://docs.microsoft.com/xamarin/essentials/gyroscope)
* [Launcher](https://docs.microsoft.com/xamarin/essentials/launcher)
* [Magnetometer](https://docs.microsoft.com/xamarin/essentials/magnetometer)
* [MainThread](https://docs.microsoft.com/xamarin/essentials/main-thread)
* [Maps](https://docs.microsoft.com/xamarin/essentials/maps)
* [Open Browser](https://docs.microsoft.com/xamarin/essentials/open-browser)
* [Orientation Sensor](https://docs.microsoft.com/en-us/xamarin/essentials/orientation-sensor)
* [Phone Dialer](https://docs.microsoft.com/xamarin/essentials/phone-dialer)
* [Preferences](https://docs.microsoft.com/xamarin/essentials/preferences)
* [Screen Lock](https://docs.microsoft.com/xamarin/essentials/screen-lock)
* [Secure Storage](https://docs.microsoft.com/xamarin/essentials/secure-storage)
* [Share](https://docs.microsoft.com/xamarin/essentials/share)
2018-10-20 22:32:07 +03:00
* [SMS](https://docs.microsoft.com/xamarin/essentials/sms)
* [Text-to-Speech](https://docs.microsoft.com/xamarin/essentials/text-to-speech)
* [Version Tracking](https://docs.microsoft.com/xamarin/essentials/version-tracking)
* [Vibrate](https://docs.microsoft.com/xamarin/essentials/vibrate)
2018-03-02 22:28:42 +03:00
## Contributing
2018-10-20 22:32:07 +03:00
Please read through our [Contribution Guide](CONTRIBUTING.md). We are not accepting new PRs for full features, however any [issue that is marked as `up for grabs`](https://github.com/xamarin/Essentials/issues?q=is%3Aissue+is%3Aopen+label%3A%22up+for+grabs%22) are open for community contributions. We encourage creating new issues for bugs found during usage that the team will triage. Additionally, we are open for code refactoring suggestions in PRs.
2018-03-02 22:28:42 +03:00
## Building Xamarin.Essentials
2018-03-05 20:43:05 +03:00
2018-10-20 22:32:07 +03:00
Xamarin.Essentials is built with the new SDK-style projects with multi-targeting enabled. This means that all code for iOS, Android, and UWP exist inside of the Xamarin.Essentials project.
If building on Visual Studio 2017, you will need the following SDKs and workloads installed:
2018-07-06 18:59:20 +03:00
### Workloads need:
2018-10-20 22:32:07 +03:00
* Xamarin
* .NET Core
* UWP
2018-07-06 18:59:20 +03:00
### You will need the following SDKs
2018-03-05 20:43:05 +03:00
[WIP] Xamarin.Essentials 1.1.0 (#663) * Use SharedPreferences.Editor.Apply when editing to force disk write to be asynchronous (#637) * GH-182 Color/Point/Rect/Size Extension Converters (#651) * Add extension helpers for iOS and Android * Add UWP colors and adjsut android colors. * Add UWP Point/Rect/Size * Rename and optimize! * Add tests and color helpers! * Fix unit test and add WithAlpha * Cleanup iOS as it stores it from 0-1 * Tests are all green! * Add generate-docs cmd :) * Add docs config to all :) * Additional clenaup for docs * Added some docs * Updated the mdoc target and regenerated the docs * Allow for code reuse on macOS (#665) Even though macOS is not yet officially supported, it is nice to reuse this code. macOS is exactly the same, except for this single property not supported. * GH-196 Browser Customization (#646) * Implemented GH-196 * Apply suggestions from code review: Naming Renamed incorrectly spelled variables Co-Authored-By: Mrnikbobjeff <schillinik@yahoo.de> * Implemented GH-196 * Browser update work as requested. Using System.Drawing.Color now * Adopted more review changes. Type forwarded. * Review changes * Made equals operator null safe, removed constructor * Add documentation and simplify the API! * Update viewmodel * Back to 7.2 * GH-676 Require To Check GPS Location is Fake Or Not In GeoLocation (#677) * Added bool IsFromMockProvider in Location class * Checkin * csproj original * Revert "csproj original" This reverts commit 6302b95782006288862f0ce11100c81936baa7fb. * Revert "Checkin" This reverts commit 0881e4f12c36caecd08b3b9bb8757d8bd1025502. * Revert "Added bool IsFromMockProvider in Location class" This reverts commit e56d9406cf0a92d24b04607afe81aef23aca696c. * Revert the Xamarin.Essentials.csproj and Samples.Android.csproj to original; Adjust the property IsFromMockProvider in Location.shared and LocationExetensions. * Edited sample to show if the location is from moking provider. * Update docs * Fixes #694 (#699) * Update the mdoc to use the new minimum for VS2019 * GH-126: Finish Shake Detector API (#693) * Update CONTRIBUTING.md (#692) * GH-126 Detect Shake API (#666) * Added shaken support * name vhange * check-in * doc update * Implements the Shake API inside Accelerometer Class; Change sample to AccelorometerViewModel * Fix the sample project * Update the docs * Added Queue mechanism based off seismic with tests as well. Something is not right yet with calulating isaccelerating. * Finalize shake detection!!! * Re-generated the docs. * Fix the VM after merge * GH-704 Handle duplicate item in keychain (#705) * Update CONTRIBUTING.md (#692) * #704 if we get a duplicate item try to remove and then re-add if possible. * Add all possible combinations for coords to km or mile (#721) * Add all possible combinations for coords to km or mile * Update UnitConverters_Tests.cs * Use more explicit job definitions * Update UnitConverters_Tests.cs * GH-698 Set longer delay on connectivity changes - Android (#700) * Update CONTRIBUTING.md (#692) * Fixes #698 * Use original string instead of uri (#716) * GH-643: Add Android P targeting and support 28 support (#669) * Update PULL_REQUEST_TEMPLATE.md * Fixes #643 to add android P targeting and support 28 support * Add suppresses for Android P * Cleanup SDKs based on @redth * Update more nugets * More optimizations for Retargeting * Refactor HasApiLevelN and updated support to 28.0.0.1 * Update manifest and key :) * Update the device tests certificates * Make sure to run the checks always * Updating the certs again to see if CI notices this time... * Change order to reflect enum (#735) * Lock keystore on Android for cipher (#734) * Add locks around android keystore. * move convert out of lock * GH-130 & GH-129: Android support for safe shareable file URI’s (#416) * Android: Support for safe shareable file URI’s On later versions of Android, you have to wrap streams of data you want to share outside your app (between apps) in a stream through a content provider. Android Support providers a general use FileProvider we can use for this. This commit basically adds support for getting all the right AndroidManifest declarations for the custom file provider based on the android support provider, so that we expose an internal method which gets a URI safe for sharing outside of the app. * Fix absolute type naming * Add a user interaction test for File Provider * Fix vibration code the ifdef meant an empty `else { }` statement with no `if { }` for platforms < 26. This fixes that. * Reorder using statements * Fix test attribute * Get provider authority properly * Added external storage permission * Change file provider path This is md5(“xamarin_essentials”) * Copy file into temp folder instead of file We keep the filename the same this way but use a GUID for a temp sub-folder to ensure a unique path. * Resgen * Permissions may need to be checked to control functionality * The Android FileProvider now can detect permissions - internal / external storage can be controlled - KitKat+ does not require the permissions - corrected the FileProvider resource xml * Added support for email attachments - support for a string path and native file types * Added attachments to the sample app * Updated the docs with the new types * Some fixes for iOS * Fix the mdoc target * regen docs * remove the obsolete armeabi ABI * Reworked the file logic to try and use public folders first - if the file is already exposed, then just use it directly - if the file is private, copy to an exposed location first - exposing the internal and external caches and the public/external files * Be more specific with the external storage permission name * Added some more depth to the comments here * Unnecessary else * Added base file info class * EmailAttachment now derives from FileBase * Added File Sharing * Keep track of IStorageFile internally * Prefer internal IStorageFile in UWP * Use attachment name properly in UWP * Add ctor to create from existing FileBase This will let us use UWP to create a new instance of something derived from FileBase with another instance of something else derived from FileBase, all while keeping track of the same `IStorageFile` instance. So we can conceivably do something like: ```csharp var mediaFile = await MediaPicker.PickPhotoAsync(); var attachment = new EmailAttachment(mediaFile); ``` * Add ctors for FileBase * Add ctors for ShareFileRequest * We can't use N on pre-N platforms * Updated the docs * Update some docs. * Bump * Gate Email/Share files with feature flags * Add sample for ShareFileRequest * Added test for share method in netstandard * [WIP] Adding the Device Tests to the yaml (#737) * Add the device tests to the yaml * Select the latest version of xamarin/xcode * Specify the iPhone simulator in the yaml * Install the Android emulator * Fix the shared test * try to resolve build issue with missing nuget * Fix docs * Fix ref * Trim . off start of extension for getting mimetype * Don't add empty strings on UWP to email (#738) * Cleanup UWP a bit
2019-03-15 23:36:34 +03:00
* Android 9.0, 8.1, 8.0, 7.1, 7.0, & 6.0 SDK Installed
2018-10-20 22:32:07 +03:00
* UWP 10.0.16299 SDK Installed
If using Visual Studio for Mac the project can be built at the command line with MSBuild. To change the project type that you are working with, simply edit Xamarin.Essentials.csproj and modify the TargetFrameworks for only the project type you want to use.
2018-03-05 20:43:05 +03:00
2018-07-06 18:59:20 +03:00
To build through the command line, navigate to where Xamarin.Essentials.csproj exists then run:
```csharp
2018-11-05 18:12:08 +03:00
msbuild /restore Xamarin.Essentials.csproj
2018-07-06 18:59:20 +03:00
```
## FAQ
2018-10-20 22:32:07 +03:00
2018-04-26 00:17:17 +03:00
Here are some frequently asked questions about Xamarin.Essentials, but be sure to read our full [FAQ on our Wiki](https://github.com/xamarin/Essentials/wiki#feature-faq).
2018-03-02 22:28:42 +03:00
## License
2018-10-20 22:32:07 +03:00
2018-03-02 22:28:42 +03:00
Please see the [License](LICENSE).
[WIP] Xamarin.Essentials 1.1.0 (#663) * Use SharedPreferences.Editor.Apply when editing to force disk write to be asynchronous (#637) * GH-182 Color/Point/Rect/Size Extension Converters (#651) * Add extension helpers for iOS and Android * Add UWP colors and adjsut android colors. * Add UWP Point/Rect/Size * Rename and optimize! * Add tests and color helpers! * Fix unit test and add WithAlpha * Cleanup iOS as it stores it from 0-1 * Tests are all green! * Add generate-docs cmd :) * Add docs config to all :) * Additional clenaup for docs * Added some docs * Updated the mdoc target and regenerated the docs * Allow for code reuse on macOS (#665) Even though macOS is not yet officially supported, it is nice to reuse this code. macOS is exactly the same, except for this single property not supported. * GH-196 Browser Customization (#646) * Implemented GH-196 * Apply suggestions from code review: Naming Renamed incorrectly spelled variables Co-Authored-By: Mrnikbobjeff <schillinik@yahoo.de> * Implemented GH-196 * Browser update work as requested. Using System.Drawing.Color now * Adopted more review changes. Type forwarded. * Review changes * Made equals operator null safe, removed constructor * Add documentation and simplify the API! * Update viewmodel * Back to 7.2 * GH-676 Require To Check GPS Location is Fake Or Not In GeoLocation (#677) * Added bool IsFromMockProvider in Location class * Checkin * csproj original * Revert "csproj original" This reverts commit 6302b95782006288862f0ce11100c81936baa7fb. * Revert "Checkin" This reverts commit 0881e4f12c36caecd08b3b9bb8757d8bd1025502. * Revert "Added bool IsFromMockProvider in Location class" This reverts commit e56d9406cf0a92d24b04607afe81aef23aca696c. * Revert the Xamarin.Essentials.csproj and Samples.Android.csproj to original; Adjust the property IsFromMockProvider in Location.shared and LocationExetensions. * Edited sample to show if the location is from moking provider. * Update docs * Fixes #694 (#699) * Update the mdoc to use the new minimum for VS2019 * GH-126: Finish Shake Detector API (#693) * Update CONTRIBUTING.md (#692) * GH-126 Detect Shake API (#666) * Added shaken support * name vhange * check-in * doc update * Implements the Shake API inside Accelerometer Class; Change sample to AccelorometerViewModel * Fix the sample project * Update the docs * Added Queue mechanism based off seismic with tests as well. Something is not right yet with calulating isaccelerating. * Finalize shake detection!!! * Re-generated the docs. * Fix the VM after merge * GH-704 Handle duplicate item in keychain (#705) * Update CONTRIBUTING.md (#692) * #704 if we get a duplicate item try to remove and then re-add if possible. * Add all possible combinations for coords to km or mile (#721) * Add all possible combinations for coords to km or mile * Update UnitConverters_Tests.cs * Use more explicit job definitions * Update UnitConverters_Tests.cs * GH-698 Set longer delay on connectivity changes - Android (#700) * Update CONTRIBUTING.md (#692) * Fixes #698 * Use original string instead of uri (#716) * GH-643: Add Android P targeting and support 28 support (#669) * Update PULL_REQUEST_TEMPLATE.md * Fixes #643 to add android P targeting and support 28 support * Add suppresses for Android P * Cleanup SDKs based on @redth * Update more nugets * More optimizations for Retargeting * Refactor HasApiLevelN and updated support to 28.0.0.1 * Update manifest and key :) * Update the device tests certificates * Make sure to run the checks always * Updating the certs again to see if CI notices this time... * Change order to reflect enum (#735) * Lock keystore on Android for cipher (#734) * Add locks around android keystore. * move convert out of lock * GH-130 & GH-129: Android support for safe shareable file URI’s (#416) * Android: Support for safe shareable file URI’s On later versions of Android, you have to wrap streams of data you want to share outside your app (between apps) in a stream through a content provider. Android Support providers a general use FileProvider we can use for this. This commit basically adds support for getting all the right AndroidManifest declarations for the custom file provider based on the android support provider, so that we expose an internal method which gets a URI safe for sharing outside of the app. * Fix absolute type naming * Add a user interaction test for File Provider * Fix vibration code the ifdef meant an empty `else { }` statement with no `if { }` for platforms < 26. This fixes that. * Reorder using statements * Fix test attribute * Get provider authority properly * Added external storage permission * Change file provider path This is md5(“xamarin_essentials”) * Copy file into temp folder instead of file We keep the filename the same this way but use a GUID for a temp sub-folder to ensure a unique path. * Resgen * Permissions may need to be checked to control functionality * The Android FileProvider now can detect permissions - internal / external storage can be controlled - KitKat+ does not require the permissions - corrected the FileProvider resource xml * Added support for email attachments - support for a string path and native file types * Added attachments to the sample app * Updated the docs with the new types * Some fixes for iOS * Fix the mdoc target * regen docs * remove the obsolete armeabi ABI * Reworked the file logic to try and use public folders first - if the file is already exposed, then just use it directly - if the file is private, copy to an exposed location first - exposing the internal and external caches and the public/external files * Be more specific with the external storage permission name * Added some more depth to the comments here * Unnecessary else * Added base file info class * EmailAttachment now derives from FileBase * Added File Sharing * Keep track of IStorageFile internally * Prefer internal IStorageFile in UWP * Use attachment name properly in UWP * Add ctor to create from existing FileBase This will let us use UWP to create a new instance of something derived from FileBase with another instance of something else derived from FileBase, all while keeping track of the same `IStorageFile` instance. So we can conceivably do something like: ```csharp var mediaFile = await MediaPicker.PickPhotoAsync(); var attachment = new EmailAttachment(mediaFile); ``` * Add ctors for FileBase * Add ctors for ShareFileRequest * We can't use N on pre-N platforms * Updated the docs * Update some docs. * Bump * Gate Email/Share files with feature flags * Add sample for ShareFileRequest * Added test for share method in netstandard * [WIP] Adding the Device Tests to the yaml (#737) * Add the device tests to the yaml * Select the latest version of xamarin/xcode * Specify the iPhone simulator in the yaml * Install the Android emulator * Fix the shared test * try to resolve build issue with missing nuget * Fix docs * Fix ref * Trim . off start of extension for getting mimetype * Don't add empty strings on UWP to email (#738) * Cleanup UWP a bit
2019-03-15 23:36:34 +03:00