Permalink
Browse files

iOS 4.x and higher never call WillTerminate

  • Loading branch information...
1 parent ea8d834 commit 2028aa3fc37072ec0f31cc4233e19dc941b6c094 @paulcbetts paulcbetts committed Mar 20, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 ReactiveUI.Mobile/AutoSuspendAppDelegate.cs
@@ -30,6 +30,7 @@ public abstract class AutoSuspendAppDelegate : UIApplicationDelegate, IEnableLog
{
readonly Subject<UIApplication> _finishedLaunching = new Subject<UIApplication>();
readonly Subject<UIApplication> _activated = new Subject<UIApplication>();
+ readonly Subject<UIApplication> _backgrounded = new Subject<UIApplication>();
readonly Subject<UIApplication> _willTerminate = new Subject<UIApplication>();
internal SuspensionHost SuspensionHost;
@@ -59,7 +60,7 @@ public AutoSuspendAppDelegate()
AppDomain.CurrentDomain.UnhandledException += (o,e) => untimelyDeath.OnNext(Unit.Default);
host.ShouldInvalidateState = untimelyDeath;
- host.ShouldPersistState = _willTerminate.SelectMany(app => {
+ host.ShouldPersistState = _willTerminate.Merge(_backgrounded).SelectMany(app => {
var taskId = app.BeginBackgroundTask(new NSAction(() => {}));
// NB: We're being force-killed, signal invalidate instead
@@ -95,6 +96,11 @@ public override void OnActivated(UIApplication application)
_activated.OnNext(application);
}
+ public override void DidEnterBackground(UIApplication application)
+ {
+ _backgrounded.OnNext(application);
+ }
+
public override void WillTerminate(UIApplication application)
{
_willTerminate.OnNext(application);

0 comments on commit 2028aa3

Please sign in to comment.