This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1118 from cocoa-mhlw/feature/bug-ios-crash
iOSで起動時にクラッシュすることがある不具合の対応
- Loading branch information
Showing
4 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Covid19Radar/Covid19Radar.iOS/Services/Migration/BGTaskMigrator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
using System.Threading.Tasks; | ||
using BackgroundTasks; | ||
using Covid19Radar.Services.Logs; | ||
using Xamarin.Essentials; | ||
|
||
namespace Covid19Radar.iOS.Services.Migration | ||
{ | ||
internal class BGTaskMigrator | ||
{ | ||
// Array of old identifier. | ||
private static readonly string[] OLD_IDENTIFIER_ARRAY = { | ||
AppInfo.PackageName + ".delete-old-logs", | ||
}; | ||
|
||
private readonly ILoggerService _loggerService; | ||
|
||
public BGTaskMigrator( | ||
ILoggerService loggerService | ||
) | ||
{ | ||
_loggerService = loggerService; | ||
} | ||
|
||
internal Task ExecuteAsync() | ||
{ | ||
_loggerService.StartMethod(); | ||
|
||
foreach (var identifier in OLD_IDENTIFIER_ARRAY) | ||
{ | ||
BGTaskScheduler.Shared.Cancel(identifier); | ||
_loggerService.Info($"BGTask {identifier} has been canceled."); | ||
} | ||
|
||
_loggerService.EndMethod(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters