You are on page 1of 31

Building Windows Store Apps for iOS Developers Jump Start

01 | Introduction to the Windows Store Platform and the tools 02 | C# for Objective-C developers 03 | Async programming & Networking intro Meal Break, around noon PST 45 to 60 mins 04 | Introduction to XAML & UI Patterns for XAML apps 05 | App Model & Storage 06 | Contracts 07 | Notifications 08 | Windows Store APIs

demo

State

Visible

Receives Events No Yes

Executes Code No Yes

State NotRunning Running

Visible Receives Events No Yes No Yes

App Executes Code No Yes

Not Running No Active Yes

Inactive Background
Suspended

Mostly No
No

No No
No

Yes Yes
No

(No Necessary Equivalent) (Accomplished by Background Tasks)


Suspended Terminated ClosedByUser No No No No No No No No No

App gets 5s to handle suspend

App is not notified before termination

User Launches App


Apps are notified when they have been resumed

Splash screen

MyGame.Common.SuspensionManager.SessionState["gameStatus"] = GameViewModel.CurrentGameStatus;

GameViewModel.CurrentGameStatus = MyGame.Common.SuspensionManager.SessionState["gameStatus"] as GameStatus;

public App() { this.InitializeComponent(); this.Suspending += OnSuspending; } private async void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); //serializes Page States and SessionState to local StorageFile await SuspensionManager.SaveAsync(); deferral.Complete(); }

protected override void SaveState(Dictionary<String, Object> pageState) { pageState.Add("greetingOutputText", greetingOutput.Text) }

protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { if (pageState == null) //Do Page State initialization else greetingOutput.Text = pageState["greetingOutputText"].ToString(); }

[[NSUserDefaults standardUserDefaults] setObject:@ejeffers forKey:MYAppDefaultsUsername];

ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; settings.Values[Username"] = ejeffers";

ApplicationDataContainer settings = ApplicationData.Current.RoamingSettings; settings.Values[Username"] = ejeffers";

demo

private void RegisterBackgroundTask() { BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); builder.Name = "FlickrBackgroundSearchTask"; builder.TaskEntryPoint = "FlickrBackgroundTasks.FlickrSearchTask"; IBackgroundTrigger trigger = new TimeTrigger(15, true); builder.SetTrigger(trigger); IBackgroundCondition condition = new SystemCondition(SystemConditionType.InternetAvailable);

namespace BackgroundTasks { public sealed class FlickrSearchTask : IBackgroundTask { async void Run(IBackgroundTaskInstance taskInstance) { var _deferral = taskInstance.GetDeferral(); HttpResponseMessage response = await client.GetAsync(queryUrl); String jsonString = await response.Content.ReadAsStringAsync(); await FileIO.WriteTextAsync(currentSearchResultsFile, jsonString); updateLiveTile(); _deferral.Complete();

Trigger name

Description

TimeTrigger
PushNotificationTrigger ControlChannelTrigger

Trigger Runs on a Timer (15 minute minimum period)


A Push Notification was received for the App Chat Programs, Audio

Trigger name

Description

InternetAvailable
NetworkStateChange OnlineIdConnectedStateChange SmsReceived TimeZoneChange

The Internet becomes available.


A network change such as a change in cost or connectivity occurs. Online ID associated with the account changes. A new SMS message is received by an installed mobile broadband device. The time zone changes on the device (for example, when the system adjusts the clock for daylight saving time).

Declare Capabilities in AppxManifest

Save State with Suspending Event using Suspension Manager

Use Background Tasks to keep app fresh when not running

You might also like