Xamarin Essentials : Easy access Native feature Platforms
ในบางครั้งการเขียน app เพื่อ access location ปัจจุบันของผู้ใช้ หรือต้องการสั่งให้โทรศัพท์สั่นตาม activity ที่ตั้งไว้ หรือแม้แต่จะ access ข้อมูล device information ของอุปกรณ์ ไม่ใช่เรื่องง่ายเลยสำหรับเหล่า developer ที่เขียน mobile app ยิ่งมีหลาย platform ไม่ว่าจะเป็น android , iOS, Windows ก็มีวิธีการเขียน code การขอ Access permission คนละรูปแบบไปอีก ซึ่งบทความนี้ผู้เขียนจะมาแนะนำให้รู้จักกับ Xamarin Essentials ที่จะมาเป็นตัวช่วยให้ผู้พัฒนาเขียน code แก้ปัญหาเหล่านี้ได้ง่ายขึ้นนั่นเอง Xamarin.Essentials คืออะไร? คือ official library ที่ทาง Microsoft ได้พัฒนาและรวบรวม library ที่เป็น cross-platform APIs สำหรับให้นักพัฒนา mobile app ที่พัฒนาด้วย Xamarin.Forms ได้ใช้งานในการเข้าถึง native features ของแต่ละ platforms ด้วยการเขียน code จากที่เดียว มีอะไรให้เรียกใช้บ้าง ปัจจุบันมีทั้งหมด 33 feature ให้เรียกใช้งาน อ้างอิงจาก Microsoft Doc ซึ่งมีดังนี้ Accelerometer – Retrieve acceleration data of the device in three dimensional space. App Information – Find out information about the application. Barometer – Monitor the barometer for pressure changes. Battery – Easily detect battery level, source, and state. Clipboard – Quickly and easily set or read text on the clipboard. Color Converters – Helper methods for System.Drawing.Color. Compass – Monitor compass for changes. Connectivity – Check connectivity state and detect changes. Detect Shake – Detect a shake movement of the device. Device Display Information – Get the device’s screen metrics and orientation. Device Information – Find out about the device with ease. Email – Easily send email messages. File System Helpers – Easily save files to app data. Flashlight – A simple way to turn the flashlight on/off. Geocoding – Geocode and reverse geocode addresses and coordinates. Geolocation – Retrieve the device’s GPS