introduction to ios 9 (xamarin evolve 2016)

40
Introduction to iOS… 9 Craig Dunn Xamarin @conceptdev

Upload: craig-dunn

Post on 21-Jan-2017

486 views

Category:

Mobile


2 download

TRANSCRIPT

Page 1: Introduction to iOS 9 (Xamarin Evolve 2016)

Introduction to iOS… 9Craig DunnXamarin@conceptdev

Page 2: Introduction to iOS 9 (Xamarin Evolve 2016)

On the menu?File New App How it works iOS 9

Configuration UI design C# code

Page 3: Introduction to iOS 9 (Xamarin Evolve 2016)
Page 4: Introduction to iOS 9 (Xamarin Evolve 2016)

File > New

Page 5: Introduction to iOS 9 (Xamarin Evolve 2016)

iPad Multitasking

-‐ Adaptive layout -‐ Size classes -‐ Configuration: + LaunchScreen.storyboard + support all iPad orientation options

Page 6: Introduction to iOS 9 (Xamarin Evolve 2016)

How it works

Page 7: Introduction to iOS 9 (Xamarin Evolve 2016)

Xamarin’s Unique Approach

iOS C# UI

Windows C# UI Android C# UI

Shared C# Code

github.com/xamarinhq/app-‐acquaint

Page 8: Introduction to iOS 9 (Xamarin Evolve 2016)

Under the Hood Bonnet

Native UI

Storyboards & XIBs User Interface code (﴾C#)﴿

UIKit, MapKit, CoreLocation…

Shared C# Code • Business Logic • Database • Web services • File operations

cust

om

bind

ings

Mono (﴾.NET Framework)﴿ • System.Net

CocoaPods Objective-‐C

NSUrlSession SQLite

iOS

iOS C# UI

Windows C# UI Android C# UI

Shared C# Code

Xamarin

Page 9: Introduction to iOS 9 (Xamarin Evolve 2016)

System.Net

Choose the Mono managed or the native iOS network stack for WebClient & HttpClient

*

*

Page 10: Introduction to iOS 9 (Xamarin Evolve 2016)

Application Transport Security

-‐ HTTPS “just works” -‐ HTTP exceptions

-‐ HTTP opt-‐out

Page 11: Introduction to iOS 9 (Xamarin Evolve 2016)

Native Performance

Xamarin.iOS does full Ahead Of Time (﴾AOT)﴿ compilation with LLVM to produce an ARM binary for Apple’s App Store.

Page 12: Introduction to iOS 9 (Xamarin Evolve 2016)

Shine with iOS 9

Page 13: Introduction to iOS 9 (Xamarin Evolve 2016)

iOS 9

-‐ UIStackView & Localization -‐ Core Spotlight -‐ NSUserActivity / Handoff -‐ Universal linking -‐ 3D Touch + Quick Actions

Page 14: Introduction to iOS 9 (Xamarin Evolve 2016)

UIStackView

Page 15: Introduction to iOS 9 (Xamarin Evolve 2016)

UIStackView

Horizontal & vertical orientation

Leading and Trailing (﴾not Left and Right)﴿

Page 16: Introduction to iOS 9 (Xamarin Evolve 2016)

UIStackView & Localization

Page 17: Introduction to iOS 9 (Xamarin Evolve 2016)

Localization Configuration

<key>CFBundleLocalizations</key> <array> <string>de</string> <string>es</string> <string>ja</string> <string>he</string> <string>ar</string> </array> <key>CFBundleDevelopmentRegion</key> <string>en</string>

Info.plist

Page 18: Introduction to iOS 9 (Xamarin Evolve 2016)

Localized Content

Page 19: Introduction to iOS 9 (Xamarin Evolve 2016)

Localized Content

Page 20: Introduction to iOS 9 (Xamarin Evolve 2016)

Localization

Page 21: Introduction to iOS 9 (Xamarin Evolve 2016)

Core Spotlight

Page 22: Introduction to iOS 9 (Xamarin Evolve 2016)

Core Spotlight (﴾Search)﴿public override void Index (Task t) { var attributeSet = new CSSearchableItemAttributeSet (UTType.Text); attributeSet.Title = t.Name; attributeSet.ContentDescription = t.Notes; attributeSet.TextContent = t.Notes; var dataItem = new CSSearchableItem (t.Id.ToString(), "co.conceptdev.to9o", attributeSet); }

// delete items CSSearchableIndex.DefaultSearchableIndex.Delete (new string[] {t.Id.ToString()}, err => {}) // index all-at-once (for reference material) var dataItems = new List<CSSearchableItem>();foreach (var session in sessions){ Index (session); }

Page 23: Introduction to iOS 9 (Xamarin Evolve 2016)

Responding to Search

public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler) { // Take action based on the activity type if (userActivity.ActivityType == CSSearchableItem.ActionType) { var uuid = userActivity.UserInfo.ObjectForKey (CSSearchableItem.ActivityIdentifier); ContinueNavigation (); // custom implementation }

Page 24: Introduction to iOS 9 (Xamarin Evolve 2016)

NSUserActivity / Handoff

Page 25: Introduction to iOS 9 (Xamarin Evolve 2016)

NSUserActivity / Handoff

Page 26: Introduction to iOS 9 (Xamarin Evolve 2016)

Creating NSUserActivity for Handoff

<key>NSUserActivityTypes</key> <array> <string>my.custom.identifier.add</string> <string>my.custom.identifier.edit</string> </array>

Info.plist

Page 27: Introduction to iOS 9 (Xamarin Evolve 2016)

Creating NSUserActivity for Handoff

var activity = new NSUserActivity ("my.custom.identifier.add")(;activity.EligibleForSearch = false; // don’t use this _and_ CoreSpotlightactivity.EligibleForPublicIndexing = false; activity.EligibleForHandoff = true; activity.Title = "Todo Detail";

var attributeSet = new CoreSpotlight.CSSearchableItemAttributeSet (); attributeSet.DisplayName = "Add Todo"; attributeSet.ContentDescription = NSBundle.MainBundle.LocalizedString ("(new)",""); activity.AddUserInfoEntries (NSDictionary.FromObjectAndKey(new NSString("0"), ActivityKeys.Id));

activity.ContentAttributeSet = attributeSet; activity.BecomeCurrent (); // ViewWillDisappear: don’t forget to ResignCurrent()

ViewController

Page 28: Introduction to iOS 9 (Xamarin Evolve 2016)

Responding to NSUserActivity

public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler) { // Take action based on the activity type if (userActivity.ActivityType == "my.custom.identifier.add") { var uuid = userActivity.UserInfo.ObjectForKey (CSSearchableItem.ActivityIdentifier); ContinueNavigation (); // custom implementation }; }

AppDelegate

Page 29: Introduction to iOS 9 (Xamarin Evolve 2016)

Universal Links

Deep link into your app

Great for search, mail-‐outs

https://evolve.xamarin.com/session/56f441a3de91c6253c277bf6

Page 30: Introduction to iOS 9 (Xamarin Evolve 2016)

Set up Universal Links

https://evolve.xamarin.com/apple-‐app-‐site-‐association { "applinks": { "apps": [], "details": [ { "appID": "XXXX421985.com.xamarin.evolve", "paths": [ "/session/*" ] } ] } }

Entitlements.plist

App ID

apple-‐app-‐site-‐association

Page 31: Introduction to iOS 9 (Xamarin Evolve 2016)

Responding to Universal Links

public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler) { if (userActivity.ActivityType == NSUserActivityType.BrowsingWeb) { var data = userActivity.WebPageUrl.AbsoluteString; if (string.IsNullOrWhiteSpace (data) || !data.Contains ("/session/")) return true; var id = data.Substring (data.LastIndexOf ("/", StringComparison.Ordinal) + 1); ContinueNavigation (); // custom implementation } }

AppDelegate

Page 32: Introduction to iOS 9 (Xamarin Evolve 2016)

3D Touch Quick Actions

Info.plist

Page 33: Introduction to iOS 9 (Xamarin Evolve 2016)

Responding to Quick Actions

public UIApplicationShortcutItem LaunchedShortcutItem { get; set; } public override void OnActivated (UIApplication application) { HandleShortcutItem(LaunchedShortcutItem); LaunchedShortcutItem = null; } public override void PerformActionForShortcutItem (UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler) { // app already running var handled = HandleShortcutItem (shortcutItem); completionHandler (handled); } public bool HandleShortcutItem (UIApplicationShortcutItem shortcutItem) { // show required view controller }

AppDelegate

Page 34: Introduction to iOS 9 (Xamarin Evolve 2016)

Xamarin.Forms too!

Evolve app: -‐ Core Spotlight -‐ NSUserActivity -‐ Universal Linking -‐ 3D Touch Quick Actions

EVOLVE APP!!

Page 35: Introduction to iOS 9 (Xamarin Evolve 2016)

VISUAL STUDIO

one more thing…

Page 36: Introduction to iOS 9 (Xamarin Evolve 2016)

Visual Studio on Windows Storyboards

Page 37: Introduction to iOS 9 (Xamarin Evolve 2016)

Visual Studio on Windows iOS Simulator

Page 38: Introduction to iOS 9 (Xamarin Evolve 2016)

Visual Studio on Windows USB Remoting

Page 39: Introduction to iOS 9 (Xamarin Evolve 2016)

Sample Codegithub.com/conceptdev/xamarin-‐ios-‐samples > Traveller (﴾iOS)﴿ github.com/conceptdev/xamarin-‐ios-‐samples > To9o (﴾iOS)﴿

github.com/xamarin/xamarin-‐forms-‐samples > Todo (﴾Xamarin.Forms)﴿ github.com/xamarinhq/app-‐evolve > Evolve (﴾Xamarin.Forms)﴿

github.com/nishanil/TouristAttractions > Android app (﴾@nishanil)﴿

Page 40: Introduction to iOS 9 (Xamarin Evolve 2016)

Craig DunnXamarin

@conceptdev

THANK YOU!