introduction to ios 9 (xamarin evolve 2016)

Post on 21-Jan-2017

487 Views

Category:

Mobile

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Introduction to iOS… 9Craig DunnXamarin@conceptdev

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

Configuration UI design C# code

File > New

iPad Multitasking

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

How it works

Xamarin’s Unique Approach

iOS C# UI

Windows C# UI Android C# UI

Shared C# Code

github.com/xamarinhq/app-‐acquaint

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

System.Net

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

*

*

Application Transport Security

-‐ HTTPS “just works” -‐ HTTP exceptions

-‐ HTTP opt-‐out

Native Performance

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

Shine with iOS 9

iOS 9

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

UIStackView

UIStackView

Horizontal & vertical orientation

Leading and Trailing (﴾not Left and Right)﴿

UIStackView & Localization

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

Localized Content

Localized Content

Localization

Core Spotlight

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); }

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 }

NSUserActivity / Handoff

NSUserActivity / Handoff

Creating NSUserActivity for Handoff

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

Info.plist

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

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

Universal Links

Deep link into your app

Great for search, mail-‐outs

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

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

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

3D Touch Quick Actions

Info.plist

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

Xamarin.Forms too!

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

EVOLVE APP!!

VISUAL STUDIO

one more thing…

Visual Studio on Windows Storyboards

Visual Studio on Windows iOS Simulator

Visual Studio on Windows USB Remoting

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)﴿

Craig DunnXamarin

@conceptdev

THANK YOU!

top related