Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9bf6b75dac | |||
| 69b83e9944 | |||
| 5061e36a45 | |||
| 8919f3c08f | |||
| 9cf9ef8a64 | |||
| 9ee3a478f0 | |||
| 8744595b56 | |||
| fa05d6b5c4 | |||
| 471ccc9e4a | |||
| 55de6f5ba0 | |||
| b12a9cc476 |
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 5.10
|
||||
- Usato endpoint cache per distquake_download_areacheck
|
||||
- Aggiunta impostazione per non riprodurre suono notifiche per simsi deboli
|
||||
|
||||
## Versione 5.9.1
|
||||
- Corretto ordinamento in sottoscrizioni attive (prima Top10k)
|
||||
- Modificato parsing per risolvere crash con valori nulli
|
||||
|
||||
## Versione 5.9
|
||||
- Aggiunta barra laterale in lista sismi
|
||||
- Aggiunto filtro "sismi percepiti"
|
||||
|
||||
@@ -51,6 +51,43 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
bestAttemptContent.sound = UNNotificationSound(named: Self.EQNSoundNotification)
|
||||
}
|
||||
|
||||
// evaluate intensity and get proper string to display
|
||||
guard let latitude = userInfo.double(forKey: "latitude"),
|
||||
let longitude = userInfo.double(forKey: "longitude"),
|
||||
let peak = userInfo.double(forKey: "peak") else {
|
||||
print("[NotificationService] Unable to get base info for intensity calculation")
|
||||
return
|
||||
}
|
||||
|
||||
let magnitude = userInfo.double(forKey: "mag") ?? 0
|
||||
let location = CLLocation(latitude: latitude, longitude: longitude)
|
||||
guard let distance = EQNUserData.shared.lastLocation?.distance(from: location) else {
|
||||
print("[NotificationService] Unable to calculate distance or get last location")
|
||||
return
|
||||
}
|
||||
|
||||
let distanceKm = distance / 1_000
|
||||
|
||||
// If the shake is mild, user can disale sound and use default notification sound
|
||||
// This logic is done here and not with the rest because distance and other informations are needed
|
||||
let mildQuakeSoundDisabled = UserDefaults.appGroup?.bool(forKey: UserDefaults.AllertaSismicaSuonoDisabilitatoSismaDebole) ?? true
|
||||
let isMildQuake = isMildQuake(magnitude: magnitude, distance: distanceKm)
|
||||
if isMildQuake && mildQuakeSoundDisabled {
|
||||
bestAttemptContent.sound = UNNotificationSound.default
|
||||
}
|
||||
|
||||
let intensita = peak * exp(-distanceKm/peak/250)
|
||||
let stringSuffix = if intensita < 0.004 {
|
||||
"no_shaking"
|
||||
} else if intensita < 0.30 {
|
||||
"mild"
|
||||
} else if intensita < 0.70 {
|
||||
"moderate"
|
||||
} else {
|
||||
"strong"
|
||||
}
|
||||
bestAttemptContent.body = "alert_intensity_\(stringSuffix)".localized
|
||||
|
||||
let intensity = userInfo.integer(forKey: "intensity")
|
||||
switch intensity {
|
||||
case 0:
|
||||
@@ -63,35 +100,6 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
break
|
||||
}
|
||||
|
||||
// evaluate intensity and get proper string to display
|
||||
guard let latitude = userInfo.double(forKey: "latitude"),
|
||||
let longitude = userInfo.double(forKey: "longitude"),
|
||||
let peak = userInfo.double(forKey: "peak") else {
|
||||
print("[NotificationService] Unable to get base info for intensity calculation")
|
||||
return
|
||||
}
|
||||
|
||||
let location = CLLocation(latitude: latitude, longitude: longitude)
|
||||
guard let distance = EQNUserData.shared.lastLocation?.distance(from: location) else {
|
||||
print("[NotificationService] Unable to calculate distance or get last location")
|
||||
return
|
||||
}
|
||||
|
||||
let distanceKm = distance / 1_000
|
||||
let intensita = peak * exp(-distanceKm/peak/250)
|
||||
let stringSuffix: String
|
||||
|
||||
if intensita < 0.004 {
|
||||
stringSuffix = "no_shaking"
|
||||
} else if intensita < 0.30 {
|
||||
stringSuffix = "mild"
|
||||
} else if intensita < 0.70 {
|
||||
stringSuffix = "moderate"
|
||||
} else {
|
||||
stringSuffix = "strong"
|
||||
}
|
||||
bestAttemptContent.body = "alert_intensity_\(stringSuffix)".localized
|
||||
|
||||
case "manual":
|
||||
// there are 12 levels, so a customized icon doesn't make sense
|
||||
// use a generic warning icon instead
|
||||
@@ -159,7 +167,7 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
notificationCenter.removeDeliveredNotifications(withIdentifiers: identifiers)
|
||||
|
||||
// !! Note: this is a known issue/bug
|
||||
// we need to add a delay before invoking the completion, otherwise the notification will not be remved
|
||||
// we need to add a delay before invoking the completion, otherwise the notification will not be removed
|
||||
// ref: https://stackoverflow.com/questions/53697279/why-are-notifications-not-removed-with-removedeliverednotifications
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
completion()
|
||||
@@ -167,6 +175,20 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private func isMildQuake(
|
||||
magnitude: Double,
|
||||
distance: Double
|
||||
) -> Bool {
|
||||
var intensity_at_location: Double = 0
|
||||
if distance > 0 {
|
||||
let R: Double = 6371
|
||||
let eq_depth: Double = 10.0
|
||||
let hyp_distance = sqrt(pow(eq_depth, 2) + 4 * R * (R - eq_depth) * pow(sin(distance / (2 * R)), 2))
|
||||
intensity_at_location = -2.15 * log10(hyp_distance) + 1.0 * magnitude + 2.31
|
||||
}
|
||||
return intensity_at_location < 3
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func manualIconName(for provider: String, color: String) -> String {
|
||||
|
||||
@@ -1818,7 +1818,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 151;
|
||||
CURRENT_PROJECT_VERSION = "$(inherited)";
|
||||
DEVELOPMENT_TEAM = "";
|
||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = WJA4MR4CPC;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
@@ -1835,7 +1835,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.9.0;
|
||||
MARKETING_VERSION = "$(inherited)";
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationservice;
|
||||
@@ -1860,7 +1860,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 151;
|
||||
CURRENT_PROJECT_VERSION = "$(inherited)";
|
||||
DEVELOPMENT_TEAM = "";
|
||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = WJA4MR4CPC;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -1873,7 +1873,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.9.0;
|
||||
MARKETING_VERSION = "$(inherited)";
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationservice;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -1923,6 +1923,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 154;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = WJA4MR4CPC;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
@@ -1943,6 +1944,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MARKETING_VERSION = 5.10.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -1985,6 +1987,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 154;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = WJA4MR4CPC;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
@@ -1999,6 +2002,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MARKETING_VERSION = 5.10.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
@@ -2014,7 +2018,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "Earthquake Network/Earthquake Network.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 151;
|
||||
CURRENT_PROJECT_VERSION = "$(inherited)";
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = WJA4MR4CPC;
|
||||
@@ -2026,7 +2030,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.9.0;
|
||||
MARKETING_VERSION = "$(inherited)";
|
||||
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
@@ -2102,7 +2106,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "Earthquake Network/Earthquake Network.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 151;
|
||||
CURRENT_PROJECT_VERSION = "$(inherited)";
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = WJA4MR4CPC;
|
||||
ENABLE_MODULE_VERIFIER = YES;
|
||||
@@ -2113,7 +2117,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.9.0;
|
||||
MARKETING_VERSION = "$(inherited)";
|
||||
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
@@ -2187,7 +2191,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = EQNNotificationContent/EQNNotificationContent.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 151;
|
||||
CURRENT_PROJECT_VERSION = "$(inherited)";
|
||||
DEVELOPMENT_TEAM = WJA4MR4CPC;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@@ -2202,7 +2206,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.9.0;
|
||||
MARKETING_VERSION = "$(inherited)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationcontent;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "EQNetwork Extension Content - Development";
|
||||
@@ -2221,7 +2225,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = EQNNotificationContent/EQNNotificationContent.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 151;
|
||||
CURRENT_PROJECT_VERSION = "$(inherited)";
|
||||
DEVELOPMENT_TEAM = WJA4MR4CPC;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"ADS_ENABLED=0",
|
||||
@@ -2234,7 +2238,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.9.0;
|
||||
MARKETING_VERSION = "$(inherited)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationcontent;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "EQNetwork Extension Content - AppStore";
|
||||
|
||||
+10
-10
@@ -6,8 +6,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/abseil-cpp-binary.git",
|
||||
"state" : {
|
||||
"revision" : "194a6706acbd25e4ef639bcaddea16e8758a3e27",
|
||||
"version" : "1.2024011602.0"
|
||||
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5",
|
||||
"version" : "1.2024072200.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -42,8 +42,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
|
||||
"state" : {
|
||||
"revision" : "075679d6b25b28f4cb167f1d7769b58fb556fb30",
|
||||
"version" : "11.8.0"
|
||||
"revision" : "fbd463894af94d90eb4d6a4e54080459a8179519",
|
||||
"version" : "11.12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -51,8 +51,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleAppMeasurement.git",
|
||||
"state" : {
|
||||
"revision" : "be0881ff728eca210ccb628092af400c086abda3",
|
||||
"version" : "11.7.0"
|
||||
"revision" : "f7460ea630bddf172115c28493ae8b3798d95ce3",
|
||||
"version" : "11.12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -78,8 +78,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/grpc-binary.git",
|
||||
"state" : {
|
||||
"revision" : "f56d8fc3162de9a498377c7b6cea43431f4f5083",
|
||||
"version" : "1.65.1"
|
||||
"revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71",
|
||||
"version" : "1.69.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -96,8 +96,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
|
||||
"state" : {
|
||||
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
|
||||
"version" : "100.0.0"
|
||||
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
|
||||
"version" : "101.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ extension UserDefaults {
|
||||
|
||||
// Impostazioni della sezione `Allerta in tempo reale`
|
||||
static let AllertaSismicaAbilitato = "NOTIFICHE_ALLERA_SISMICA_ABILITATO"
|
||||
static let AllertaSismicaSuonoDisabilitatoSismaDebole = "NOTIFICHE_ALLERA_SISMICA_SUONO_DISABILITATO_SISMA_DEBOLE"
|
||||
static let AllertaSismicaCriticalAlerts = "NOTIFICHE_ALLERA_SISMICA_CRITICAL_ALERTS"
|
||||
static let AllertaSismicaSismiDaNotificare = "NOTIFICHE_ALLERA_SISMICA_SISMI_DA_NOTIFICARE"
|
||||
static let AllertaSismicaRaggioSismiLievi = "NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_LIEVI"
|
||||
@@ -69,6 +70,7 @@ extension UserDefaults {
|
||||
static let AppMigrationV5_8 = "EQNUserDefaultMigrationV5_8"
|
||||
static let AppMigrationV5_8_2 = "EQNUserDefaultMigrationV5_8_2"
|
||||
static let AppMigrationV5_9 = "EQNUserDefaultMigrationV5_9"
|
||||
static let AppMigrationV5_10 = "EQNUserDefaultMigrationV5_10"
|
||||
|
||||
static let SettingsSeismicNetworkNotificationMigrationV5_8 = "EQNUserDefaultSettingsSeismicNetworkNotificationMigrationV5_8"
|
||||
static let SettingsUserReportNotificationMigrationV5_8 = "EQNUserDefaultSettingsUserReportNotificationMigrationV5_8"
|
||||
|
||||
@@ -119,14 +119,21 @@ class SubscriptionsViewController: UITableViewController {
|
||||
let isSubscription = product.isSubscription
|
||||
return isPurchased && isSubscription
|
||||
}.sorted { lProduct, rProduct in
|
||||
// if user has more than one subscriptions,
|
||||
// show first the Top10k
|
||||
let lIs10k = lProduct.isTop100k
|
||||
let rIs10k = rProduct.isTop100k
|
||||
if lIs10k {
|
||||
return lIs10k
|
||||
// If user has more than one subscriptions,
|
||||
// show first the Top10k.
|
||||
let lIs10k = lProduct.isTop10k
|
||||
let rIs10k = rProduct.isTop10k
|
||||
|
||||
// If left item is Top10k, order first
|
||||
if lIs10k && !rIs10k {
|
||||
return true
|
||||
} else if !lProduct.isTop10k && rProduct.isTop10k {
|
||||
// right product is Top10k, left no
|
||||
return false
|
||||
} else {
|
||||
// both products Top10k or Top100k, keep existing order
|
||||
return false
|
||||
}
|
||||
return rIs10k
|
||||
}
|
||||
self.productSubscribed = purchased.first
|
||||
self.products = products.sorted(by: { $0.productIdentifier > $1.productIdentifier })
|
||||
|
||||
+17
@@ -13,14 +13,17 @@ class SettingsRealTimeAlertsViewController: SettingsBaseTableViewController {
|
||||
|
||||
private enum RowIdentifier: Int {
|
||||
case abilitaNotifiche
|
||||
case disabilitaSuonoAllerta
|
||||
case abilitaCriticalAlerts
|
||||
}
|
||||
|
||||
private var isNotificationEnabled = false
|
||||
private var isMildQuakeSoundDisabled = false
|
||||
private var isCriticalAlertsEnabled = false
|
||||
|
||||
private let settings: [SettingItem] = [
|
||||
.init(type: .enable, title: NSLocalizedString("options_notification_enable_alarm", comment: "")),
|
||||
.init(type: .enable, title: NSLocalizedString("options_notification_disable_sound", comment: "")),
|
||||
.init(type: .enable, title: NSLocalizedString("critical_alerts_setting", comment: ""))
|
||||
]
|
||||
|
||||
@@ -56,6 +59,7 @@ class SettingsRealTimeAlertsViewController: SettingsBaseTableViewController {
|
||||
let saved = EQNSettingRealTimeAlert.shared
|
||||
|
||||
isNotificationEnabled = saved.isAbilitato
|
||||
isMildQuakeSoundDisabled = saved.isMildQuakeSoundDisabled
|
||||
isCriticalAlertsEnabled = saved.isCriticalAlertsEnabled
|
||||
}
|
||||
|
||||
@@ -93,6 +97,11 @@ class SettingsRealTimeAlertsViewController: SettingsBaseTableViewController {
|
||||
cell.valueChanged = { [weak self] enabled in
|
||||
self?.onChangeNotificationEnabled(enabled)
|
||||
}
|
||||
case .disabilitaSuonoAllerta:
|
||||
cell.toggleSwitch.isOn = isMildQuakeSoundDisabled
|
||||
cell.valueChanged = { [weak self] enabled in
|
||||
self?.onChangeDisableSoundEnabled(enabled)
|
||||
}
|
||||
case .abilitaCriticalAlerts:
|
||||
cell.toggleSwitch.isOn = isCriticalAlertsEnabled
|
||||
cell.valueChanged = { [weak self] enabled in
|
||||
@@ -116,6 +125,14 @@ class SettingsRealTimeAlertsViewController: SettingsBaseTableViewController {
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
private func onChangeDisableSoundEnabled(_ enabled: Bool) {
|
||||
isMildQuakeSoundDisabled = enabled
|
||||
EQNSettingRealTimeAlert.shared.isMildQuakeSoundDisabled = isMildQuakeSoundDisabled
|
||||
EQNSettingRealTimeAlert.shared.saveUserInfo()
|
||||
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
private func onChangeCriticalAlertsEnabled(_ enabled: Bool) {
|
||||
if enabled {
|
||||
askForCriticalAlertsPermission()
|
||||
|
||||
@@ -49,7 +49,7 @@ static NSString * const EQNServerUrlCalibration = @"https://srv.earthquakenetwor
|
||||
// download rete smartphone
|
||||
static NSString * const EQNServerUrlDownloadSmartphoneNetwork = @"https://cache.earthquakenetwork.it/distquake_count_redis3.php";
|
||||
// download area check
|
||||
static NSString * const EQNServerUrlDownloadAreaCheck = @"https://srv.earthquakenetwork.it/distquake_download_areacheck.php";
|
||||
static NSString * const EQNServerUrlDownloadAreaCheck = @"https://cache.earthquakenetwork.it/distquake_download_areacheck.php";
|
||||
// download pastquakes
|
||||
static NSString * const EQNServerUrlDownloadPastQuakes = @"https://srv.earthquakenetwork.it/distquake_download_pastquakes.php";
|
||||
// download segnalazioni
|
||||
|
||||
@@ -21,6 +21,7 @@ public class EQNUserDefaultsCommand: EQNCommandProtocol {
|
||||
migrationFirstAppStat()
|
||||
migrationCriticalAlerts()
|
||||
migrationV5_9()
|
||||
migrationV5_10()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -119,4 +120,19 @@ public class EQNUserDefaultsCommand: EQNCommandProtocol {
|
||||
|
||||
userDefaults.set(true, forKey: UserDefaults.AppMigrationV5_9)
|
||||
}
|
||||
|
||||
private func migrationV5_10() {
|
||||
let userDefaults = UserDefaults.standard
|
||||
let migrationPerformed = userDefaults.bool(forKey: UserDefaults.AppMigrationV5_10)
|
||||
if migrationPerformed {
|
||||
print("[EQNUserDefaultsCommand] Migration v5.10 already performed")
|
||||
return
|
||||
}
|
||||
|
||||
print("[EQNUserDefaultsCommand] Save default value for mildQuakeSoundDisabled")
|
||||
EQNSettingRealTimeAlert.shared.isMildQuakeSoundDisabled = true
|
||||
EQNSettingRealTimeAlert.shared.saveUserInfo()
|
||||
|
||||
userDefaults.set(true, forKey: UserDefaults.AppMigrationV5_10)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,14 @@
|
||||
- (void)scaricaDatiReteSmartphone
|
||||
{
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadSmartphoneNetwork] richiesta:EQNTipoChiamataDownloadDati success:^(id result) {
|
||||
|
||||
self.rete_smartphone = [[EQNReteSmartphone alloc] initWithInfo:result];
|
||||
|
||||
// Parsiamo la risposta (assicurandoci che non contenga valori nulli)
|
||||
EQNReteSmartphone *rete = [EQNReteSmartphone fromResponse:result];
|
||||
if (rete != nil) {
|
||||
self.rete_smartphone = rete;
|
||||
} else {
|
||||
NSLog(@"[EQNManager] Impossibile parsare la risposta di DownloadSmartphoneNetwork");
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(scaricaAreaCheck) withObject:nil waitUntilDone:YES];
|
||||
} failure:^(NSError * error) {
|
||||
@@ -72,7 +78,12 @@
|
||||
|
||||
- (void)scaricaAreaCheck
|
||||
{
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?lat=%f&lon=%f", EQNServerUrlDownloadAreaCheck, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude]] richiesta:EQNTipoChiamataAreaCheck success:^(id result) {
|
||||
// Quantizziamo le coordinate, in modo che venga sfruttata la cache lato server
|
||||
CLLocation *lastPosition = [EQNUser defaultUser].lastPosition;
|
||||
double latitude = round(lastPosition.coordinate.latitude * 5.0) / 5.0;
|
||||
double longitude = round(lastPosition.coordinate.longitude * 5.0) / 5.0;
|
||||
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?lat=%f&lon=%f", EQNServerUrlDownloadAreaCheck, latitude, longitude]] richiesta:EQNTipoChiamataAreaCheck success:^(id result) {
|
||||
|
||||
self.area_check = [[EQNAreaCheck alloc] initWithInfo:result];
|
||||
|
||||
|
||||
@@ -21,13 +21,27 @@ class EQNReteSmartphone: NSObject {
|
||||
let top10kAvailable: Int
|
||||
let top100kAvailable: Int
|
||||
|
||||
// MARK: - Class
|
||||
|
||||
// Sometimes the response returns a broken response, with all values to null.
|
||||
// In order to avoid crashes due to ObjC-Swift bridging, we need to take a generic nullable object,
|
||||
// and then cast to the expected type (a dictionary).
|
||||
@objc static func from(response: Any?) -> EQNReteSmartphone? {
|
||||
if let info = response as? [[String: Any]?] {
|
||||
return .init(info: info)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
@objc init(info: [[String: Any]]) {
|
||||
private init(info: [[String: Any]?]) {
|
||||
// merge array in a single dictionary
|
||||
let allValues = info.reduce([:]) { (result, dictionary) -> [String: Any] in
|
||||
return result.merging(dictionary, uniquingKeysWith: { (_, new) in new })
|
||||
}
|
||||
let allValues = info
|
||||
.compactMap { $0 }
|
||||
.reduce([:]) { (result, dictionary) -> [String: Any] in
|
||||
return result.merging(dictionary, uniquingKeysWith: { (_, new) in new })
|
||||
}
|
||||
|
||||
self.counterLastDayAlerts = allValues.integer(forKey: "eq", orDefault: 0)
|
||||
self.counterTotalAlerts = allValues.integer(forKey: "eq_p", orDefault: 0)
|
||||
|
||||
@@ -16,11 +16,12 @@ class EQNSettingRealTimeAlert: NSObject {
|
||||
static let shared = EQNSettingRealTimeAlert()
|
||||
|
||||
@objc var isAbilitato: Bool
|
||||
@objc var isCriticalAlertsEnabled: Bool
|
||||
var isMildQuakeSoundDisabled: Bool
|
||||
var isCriticalAlertsEnabled: Bool
|
||||
|
||||
@objc var sismiDaNotificare: String
|
||||
var sismiDaNotificare: String
|
||||
@objc var raggioSismiLievi: String
|
||||
@objc var raggioSismiForti: String
|
||||
var raggioSismiForti: String
|
||||
|
||||
private static let DefaultSismiDaNotificare = "0"
|
||||
private static let DefaultRaggioSismiLievi = "250"
|
||||
@@ -38,6 +39,7 @@ class EQNSettingRealTimeAlert: NSObject {
|
||||
|
||||
let sharedDefaults = UserDefaults.appGroup
|
||||
isCriticalAlertsEnabled = sharedDefaults?.bool(forKey: UserDefaults.AllertaSismicaCriticalAlerts) ?? false
|
||||
isMildQuakeSoundDisabled = sharedDefaults?.bool(forKey: UserDefaults.AllertaSismicaSuonoDisabilitatoSismaDebole) ?? true
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -50,12 +52,14 @@ class EQNSettingRealTimeAlert: NSObject {
|
||||
defaults.set(raggioSismiForti, forKey: UserDefaults.AllertaSismicaRaggioSismiForti)
|
||||
if let sharedDefaults = UserDefaults.appGroup {
|
||||
sharedDefaults.set(isCriticalAlertsEnabled, forKey: UserDefaults.AllertaSismicaCriticalAlerts)
|
||||
sharedDefaults.set(isMildQuakeSoundDisabled, forKey: UserDefaults.AllertaSismicaSuonoDisabilitatoSismaDebole)
|
||||
}
|
||||
}
|
||||
|
||||
@objc class func saveDefaultValues() {
|
||||
shared.isAbilitato = true
|
||||
shared.isCriticalAlertsEnabled = false
|
||||
shared.isMildQuakeSoundDisabled = true
|
||||
shared.sismiDaNotificare = Self.DefaultSismiDaNotificare
|
||||
shared.raggioSismiLievi = Self.DefaultRaggioSismiLievi
|
||||
shared.raggioSismiForti = Self.DefaultRaggioSismiForti
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "ألغي";
|
||||
"options_alarms" = "تنبيه بوقت فعلي";
|
||||
"options_notification_enable_alarm" = "قم بتفعيل الإنذار عند اكتشاف زلزال في الوقت الفعلي بواسطة شبكة الهواتف الذكية";
|
||||
"options_notification_disable_sound" = "قم بتعطيل صوت المنبه إذا كان الاهتزاز في موقعك خفيفًا";
|
||||
"options_notification_official" = "إخطارات الشبكة الزلزالية";
|
||||
"options_notification_enable_official" = "تلقي إشعارات بشأن الزلازل التي اكتشفتها شبكات الزلازل الوطنية والدولية";
|
||||
"options_official_type" = "مرشح الإشعارات";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Διαγραφή";
|
||||
"options_alarms" = "Ειδοποίηση σε πραγματικό χρόνο";
|
||||
"options_notification_enable_alarm" = "Να ακούγεται συναγερμός όταν ανιχνεύεται σεισμός σε πραγματικό χρόνο από το δίκτυο smartphone";
|
||||
"options_notification_disable_sound" = "Απενεργοποιήστε τον ήχο συναγερμού εάν το κούνημα στην τοποθεσία σας είναι ήπιο";
|
||||
"options_notification_official" = "Κοινοποιήσεις σεισμικών δικτύων";
|
||||
"options_notification_enable_official" = "Λήψη ειδοποιήσεων για τους σεισμούς που εντοπίζονται από τα εθνικά και διεθνή σεισμικά δίκτυα";
|
||||
"options_official_type" = "Φίλτρο ειδοποιήσεων";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Cancel";
|
||||
"options_alarms" = "Real time alert";
|
||||
"options_notification_enable_alarm" = "Activate an alarm when a quake is detected in real time by the network of smartphones";
|
||||
"options_notification_disable_sound" = "Disable the alarm sound if the shaking at your location is mild";
|
||||
"options_notification_official" = "Seismic network notifications";
|
||||
"options_notification_enable_official" = "Receive notifications for the earthquakes detected by the national and international seismic networks";
|
||||
"options_official_type" = "Notification filter";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Clara";
|
||||
"options_alarms" = "Alerta en tiempo real";
|
||||
"options_notification_enable_alarm" = "Suena una alarma cuando se detecta un sismo en tiempo real por la red de los teléfonos inteligentes";
|
||||
"options_notification_disable_sound" = "Desactive el sonido de la alarma si el sismo en tu ubicación es leve";
|
||||
"options_notification_official" = "Notificaciones redes sísmicas";
|
||||
"options_notification_enable_official" = "Recibe las notificaciones de los sismos detectados por las redes sísmicas nacionales e internacionales";
|
||||
"options_official_type" = "Filtro de notificaciones";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Supprimer";
|
||||
"options_alarms" = "Alerte en temps réel";
|
||||
"options_notification_enable_alarm" = "Une alarme retentit lorsqu'un séisme est détecté par le réseau des smartphones";
|
||||
"options_notification_disable_sound" = "Désactivez le son de l'alarme si les secousses à votre emplacement sont légères";
|
||||
"options_notification_official" = "Notifications de réseaux sismiquex";
|
||||
"options_notification_enable_official" = "Recevez les notifications des séismes détectés par les réseaux sismiques nationaux et internationaux";
|
||||
"options_official_type" = "Filtre de notificatio";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Poništi";
|
||||
"options_alarms" = "Upozorenje u stvarnom vremenu";
|
||||
"options_notification_enable_alarm" = "Aktiviraj alarm kada mreža pametnih telefona u stvarnom vremenu otkrije potres";
|
||||
"options_notification_disable_sound" = "Onemogućite zvuk alarma ako je podrhtavanje na vašoj lokaciji blago";
|
||||
"options_notification_official" = "Obavijesti o seizmološkim mrežama";
|
||||
"options_notification_enable_official" = "Primajte obavijesti o potresima koje su otkrile nacionalne i međunarodne seizmičke mreže";
|
||||
"options_official_type" = "Filter obavijesti";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Batal";
|
||||
"options_alarms" = "Peringatan real time";
|
||||
"options_notification_enable_alarm" = "Nyalakan alarm saat gempa terdeteksi secara real time oleh jaringan smartphone";
|
||||
"options_notification_disable_sound" = "Nonaktifkan suara alarm jika guncangan di lokasi Anda ringan";
|
||||
"options_notification_official" = "Pemberitahuan jaringan seismik";
|
||||
"options_notification_enable_official" = "Terima pemberitahuan untuk gempa bumi yang terdeteksi oleh jaringan seismik nasional dan internasional";
|
||||
"options_official_type" = "Filter notifikasi";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "Cancella";
|
||||
"options_alarms" = "Allerta in tempo reale";
|
||||
"options_notification_enable_alarm" = "Attiva un allarme quando un sisma è rilevato dalla rete smartphone";
|
||||
"options_notification_disable_sound" = "Disabilita il suono di allerta se l'intensità del sisma nella tua zona è debole";
|
||||
"options_notification_official" = "Notifiche da reti sismiche";
|
||||
"options_notification_enable_official" = "Ricevi notifiche per i sismi rilevati dalle reti sismiche nazionali e internazionali";
|
||||
"options_official_type" = "Filtro notifiche";
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"status_cancel" = "İptal et";
|
||||
"options_alarms" = "Gerçek zamanlı uyarı";
|
||||
"options_notification_enable_alarm" = "Bir deprem akıllı telefon ağı tarafından gerçek zamanlı olarak tespit edildiğinde bir alarm çal";
|
||||
"options_notification_disable_sound" = "Bulunduğunuz yerdeki sarsıntı hafifse alarm sesini devre dışı bırakın";
|
||||
"options_notification_official" = "Sismik ağ bildirimleri";
|
||||
"options_notification_enable_official" = "Ulusal ve uluslararası sismik ağlar tarafından tespit edilen depremler için bildirim alın";
|
||||
"options_official_type" = "Bildirim filtresi";
|
||||
|
||||
Reference in New Issue
Block a user