Presentation is loading. Please wait.

Presentation is loading. Please wait.

Additional Topics. API Bindings Bindings Binding Native API’s Create Binding Project Drop Jar or.a Done.

Similar presentations


Presentation on theme: "Additional Topics. API Bindings Bindings Binding Native API’s Create Binding Project Drop Jar or.a Done."— Presentation transcript:

1 Additional Topics

2 API Bindings

3 Bindings Binding Native API’s Create Binding Project Drop Jar or.a Done

4 You wish! Painful

5 Bindings Android Generate C# stubs from Java Classes Simple Jar’s work without issues XML transforms for differences in C# / Java: – Anonymous inner classes – Data Type Mapping – Enums Samples available Did I say it’s painful already?

6 Bindings iOS Have to define all Classes / Methods manually ObjectiveSharpie command line tool – Great help – Still a lot of manual work linkwith.cs file requires manual adaption – C Libraries – iOS Frameworks Errors appear when linking

7 Let’s have a look Urban Airship binding (MyWorldVision)

8 Bindings Conclusion Many API’s are already available, maintained by main developer (Facebook, Microsoft etc.) Try to avoid bindings if other Components / Packages are available (-> e.g. Parse) Read error messages Use Xamarin Forums, Stackoverflow Be patient!

9 SQLite Crossplattform DB

10 Data Model public class TodoItem { public TodoItem () { } [PrimaryKey, AutoIncrement] public int ID { get; set; } public string Name { get; set; } public string Notes { get; set; } public bool Done { get; set; } }

11 Get Connection (Dependency Service) public interface ISQLite { SQLiteConnection GetConnection(); }

12 Android Implementation public SQLite.SQLiteConnection GetConnection () { var sqliteFilename = "TodoSQLite.db3"; string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder var path = Path.Combine(documentsPath, sqliteFilename); // Create the connection var conn = new SQLite.SQLiteConnection(path); // Return the database connection return conn; }}

13 Usage Init: database = DependencyService.Get ().Get Connection (); database.CreateTable (); SQL Query: return database.Query ("SELECT * FROM [TodoItem] WHERE [Done] = 0");

14 Usage LINQ Expressions: TodoItem GetItem (int id){ return database.Table ().FirstOrDefault ( x => x.ID == id); } return database.Delete (id);

15 Let’s have a look SQLite Demo App

16 JSON.Net Jason!

17 Decisions, decisions System.Json vs Json.Net -> Use Json.Net unless you have a good reason -> Less restrictive

18 Basic example var todoItem = new TodoItem { ID = 1, Name = "Name” }; var json = JsonConvert.SerializeObject (todoItem); Debug.WriteLine ("JSON representation of todoItem: {0}", json); var person2 = JsonConvert.DeserializeObject (json); Debug.WriteLine ("{0} - {1}", person2.ID, person2.Name);

19 Linq example string jsontext = @"{ Name: 'Bob', HairColor: 'Brown' }"; var bob = JObject.Parse (jsontext); Debug.WriteLine ("{0} with {1} hair", bob["Name"], bob["HairColor"]);

20 Let’s have a quick look JSON Example

21 UI Tests Testcloud

22 TestCloud Physical devices mounted in Rack

23

24 UI Test For all native Apps Physical devices mounted in Rack Run locally in Simulator (iOS, Android) Deploy to Cloud for mass testing 60 Device Minutes included More is a bit expensive

25 UI Test – how it works iOS: e.NativeView.AccessibilityIdentifier = value; Android: e.NativeView.ContentDescription = value; [Test] public void WelcomeTextIsDisplayed () { AppResult[] results = app.WaitForElement (c => c.Marked ("Welcome to Xamarin Forms!")); app.Screenshot ("Welcome screen."); Assert.IsTrue (results.Any ()); }

26 Tests Let’s have a look (Local App)

27 Tests Let’s have a look (testcloud.xamarin.com)

28 Insights Analytics & Crash Reports made easy

29

30 Usage Import Package Register API Key Done

31 Hold your horses… Uncaught Exceptions get reported automatically Exception Reporting for caught exceptions: Insights.Report(ex); User Identification Events Timed Events

32 Insights https://xamarin.com/insights https://developer.xamarin.com/guides/cross- platform/insights/application/ https://developer.xamarin.com/guides/cross- platform/insights/application/


Download ppt "Additional Topics. API Bindings Bindings Binding Native API’s Create Binding Project Drop Jar or.a Done."

Similar presentations


Ads by Google