-2
为了避免实施整体导航堆栈我想保持我的应用程序的持续性高速缓存逻辑,甚至在背景中“活着”(至少2小时)之后,所以当用户重新打开该应用程序是它在睡觉之前的地方。防止iOS版查杀我的应用程序3分钟
我试图用一个后台任务:
_timerBackgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask(() =>
{
// Run some dummy code here. Shouldn´t this prevent the task from actually stopping?
var remaining = UIApplication.SharedApplication.BackgroundTimeRemaining;
this.Log().Debug($"Expiration. Remaining: {remaining}. Timer seconds left: {_secondsLeft}");
});
// I´m actually using the timer for something :)
_nsTimer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1), delegate { TimerTick(); });
// later on (after 3 minutes)
UIApplication.SharedApplication.EndBackgroundTask(_timerBackgroundTaskId.Value);
无论我怎么努力,三分杀死的iOS应用后。 SO中的一些答案告诉我如何用假/无声背景音来做到这一点,但我不希望苹果评论有任何问题。
有什么建议吗?
这是更好地处理应用程序恢复正常,而不是尝试做一些棘手。您的应用只有3分钟的后台执行时间。这些限制的目的是最大限度地延长电池寿命,并供用户可能需要运行 – Paulw11
恢复是什么我正尝试避免其他应用程序的内存,但I'll做,如果没有其他的办法。 – xleon
三分钟是一个硬限制,除非您的应用程序合法使用其中一种可用的背景模式。 – Paulw11