-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