Compare commits

...

11 Commits

Author SHA1 Message Date
Andrea Busi cae5fee992 feat: Remove same type posted notifications
Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/48
2022-05-30 16:02:46 +02:00
Andrea Busi 53b8c0fab4 release: Increase version for release 2022-05-29 22:16:19 +02:00
Andrea Busi 8751d3c8f2 fix: Solve crazy behaviour with iOS 15 2022-05-29 22:14:06 +02:00
Andrea Busi 2d333f993b feat: Make slider with step values 2022-05-29 22:13:46 +02:00
Andrea Busi 22d421f1cc refactor: Add debug log 2022-05-26 21:51:30 +02:00
Andrea Busi cec8b39fc7 fix: Be sure to update push token in Firebase 2022-05-26 21:51:08 +02:00
Andrea Busi 5ceaa4a8be fix: Save user position after server registration 2022-05-26 18:06:37 +02:00
Andrea Busi 94bdb9dbe1 fix: Don't try to parse nil data 2022-05-26 18:06:27 +02:00
Andrea Busi ee1b762032 fix: Call callback for position endpoint 2022-05-26 18:06:13 +02:00
Andrea Busi 5a6c5a5cfc release: Increase version for release 2022-05-22 21:31:58 +02:00
Andrea Busi d55b2ec98f fix: Solve wrong value save in settings 2022-05-22 21:31:50 +02:00
12 changed files with 110 additions and 33 deletions
+14
View File
@@ -1,5 +1,19 @@
# Changelog
## Versione 5.0.3
### Build (89)
- Corretto problema con ultima posizione non salvata in app
- Forzato aggiornamento Firebase
- Corretti metodi deprecati in salvataggio dati
- Corretti comportamento filtri con iOS 15
- Slider con valori a step
## Versione 5.0.2
### Build (88)
- Corretto errato salvataggio raggio sismi forti in allerte tempo reale
## Versione 5.0.1
### Build (87)
@@ -2,3 +2,4 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "NotificationService.h"
@@ -0,0 +1,42 @@
//
// NotificationService+Extension.swift
// EQNNotificationService
//
// Created by Andrea Busi on 28/05/22.
// Copyright © 2022 Earthquake Network. All rights reserved.
//
import Foundation
import UserNotifications
extension NotificationService {
@objc(removeNotificationsForType:completion:)
func removeNotifications(
for type: String?,
completion: @escaping() -> Void
) {
guard let type = type else {
completion()
return
}
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.getDeliveredNotifications { notifications in
let sameTypeNotifications = notifications.filter { notification in
let payload = notification.request.content.userInfo
if let notificationType = payload["type"] as? String {
return notificationType == type
}
return false
}
let identifiers = sameTypeNotifications.map { $0.request.identifier }
notificationCenter.removeDeliveredNotifications(withIdentifiers: identifiers)
completion()
}
}
}
@@ -9,6 +9,8 @@
#import "NotificationService.h"
#import "EQNAllertaSismica.h"
#import "Costanti.h"
#import "EQNNotificationService-Swift.h"
@interface NotificationService ()
@@ -158,7 +160,10 @@ static NSString * const EQNSoundNotificationEQN = @"alert_sound.wav";
}
}
[self contentComplete];
// remove same type posted notification
[self removeNotificationsForType:notificationType completion:^{
[self contentComplete];
}];;
}
- (void)serviceExtensionTimeWillExpire
@@ -11,6 +11,7 @@
651901B925F5358700CAFF20 /* EQNMapAnnotationSeismic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 651901B825F5358700CAFF20 /* EQNMapAnnotationSeismic.swift */; };
6525A82625E13FD4008FE0D0 /* SeismicNetworkAdvertiseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6525A82525E13FD4008FE0D0 /* SeismicNetworkAdvertiseTableViewCell.swift */; };
652C37BD26092B3C0068EC3B /* FiltersViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652C37BC26092B3C0068EC3B /* FiltersViewModel.swift */; };
6531185928425B89006CBC29 /* NotificationService+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6531185828425B89006CBC29 /* NotificationService+Extension.swift */; };
65355FFF25F38D3300BB57D2 /* SegnalazioniMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65355FFE25F38D3300BB57D2 /* SegnalazioniMapViewController.swift */; };
6535600425F398CD00BB57D2 /* Costanti+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6535600325F398CD00BB57D2 /* Costanti+Extensions.swift */; };
653604E9262348FA00B2B651 /* EQNBaseMapFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653604E8262348FA00B2B651 /* EQNBaseMapFilter.swift */; };
@@ -288,6 +289,7 @@
651901B825F5358700CAFF20 /* EQNMapAnnotationSeismic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNMapAnnotationSeismic.swift; sourceTree = "<group>"; };
6525A82525E13FD4008FE0D0 /* SeismicNetworkAdvertiseTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeismicNetworkAdvertiseTableViewCell.swift; sourceTree = "<group>"; };
652C37BC26092B3C0068EC3B /* FiltersViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FiltersViewModel.swift; sourceTree = "<group>"; };
6531185828425B89006CBC29 /* NotificationService+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NotificationService+Extension.swift"; sourceTree = "<group>"; };
65355FFE25F38D3300BB57D2 /* SegnalazioniMapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegnalazioniMapViewController.swift; sourceTree = "<group>"; };
6535600325F398CD00BB57D2 /* Costanti+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Costanti+Extensions.swift"; sourceTree = "<group>"; };
653604E8262348FA00B2B651 /* EQNBaseMapFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNBaseMapFilter.swift; sourceTree = "<group>"; };
@@ -660,6 +662,7 @@
8C483CB521FDACD100259FD2 /* EQNNotificationService-Bridging-Header.h */,
8C4B0B7C21CACE3F00AED489 /* NotificationService.h */,
8C4B0B7D21CACE3F00AED489 /* NotificationService.m */,
6531185828425B89006CBC29 /* NotificationService+Extension.swift */,
DC30BC862534DBB30041B23B /* Icons */,
8C4B0B7F21CACE3F00AED489 /* Info.plist */,
);
@@ -1526,6 +1529,7 @@
buildActionMask = 2147483647;
files = (
DCDAB31925188BB3001AE40D /* EQNAllertaSismica.m in Sources */,
6531185928425B89006CBC29 /* NotificationService+Extension.swift in Sources */,
8C4B0B7E21CACE3F00AED489 /* NotificationService.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -1738,12 +1742,12 @@
CODE_SIGN_ENTITLEMENTS = EQNNotificationService/EQNNotificationService.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 87;
CURRENT_PROJECT_VERSION = 89;
DEVELOPMENT_TEAM = WJA4MR4CPC;
INFOPLIST_FILE = EQNNotificationService/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 5.0.1;
MARKETING_VERSION = 5.0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationservice;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "EQNetwork Extension Service - Development";
@@ -1762,12 +1766,12 @@
CODE_SIGN_ENTITLEMENTS = EQNNotificationService/EQNNotificationService.entitlements;
CODE_SIGN_IDENTITY = "Apple Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 87;
CURRENT_PROJECT_VERSION = 89;
DEVELOPMENT_TEAM = WJA4MR4CPC;
INFOPLIST_FILE = EQNNotificationService/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 5.0.1;
MARKETING_VERSION = 5.0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationservice;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "EQNetwork Extension Service - AppStore";
@@ -1907,14 +1911,14 @@
CODE_SIGN_ENTITLEMENTS = "Earthquake Network/Earthquake Network.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 87;
CURRENT_PROJECT_VERSION = 89;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = WJA4MR4CPC;
GCC_PREFIX_HEADER = "Earthquake Network/Earthquake Network-Prefix.pch";
INFOPLIST_FILE = "Earthquake Network/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 5.0.1;
MARKETING_VERSION = 5.0.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@@ -2017,13 +2021,13 @@
CODE_SIGN_ENTITLEMENTS = "Earthquake Network/Earthquake Network.entitlements";
CODE_SIGN_IDENTITY = "Apple Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 87;
CURRENT_PROJECT_VERSION = 89;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = WJA4MR4CPC;
GCC_PREFIX_HEADER = "Earthquake Network/Earthquake Network-Prefix.pch";
INFOPLIST_FILE = "Earthquake Network/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 5.0.1;
MARKETING_VERSION = 5.0.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@@ -2122,12 +2126,12 @@
CODE_SIGN_ENTITLEMENTS = EQNNotificationContent/EQNNotificationContent.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 87;
CURRENT_PROJECT_VERSION = 89;
DEVELOPMENT_TEAM = WJA4MR4CPC;
INFOPLIST_FILE = EQNNotificationContent/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 5.0.1;
MARKETING_VERSION = 5.0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationcontent;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "EQNetwork Extension Content - Development";
@@ -2146,12 +2150,12 @@
CODE_SIGN_ENTITLEMENTS = EQNNotificationContent/EQNNotificationContent.entitlements;
CODE_SIGN_IDENTITY = "Apple Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 87;
CURRENT_PROJECT_VERSION = 89;
DEVELOPMENT_TEAM = WJA4MR4CPC;
INFOPLIST_FILE = EQNNotificationContent/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 5.0.1;
MARKETING_VERSION = 5.0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.notificationcontent;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "EQNetwork Extension Content - AppStore";
+3
View File
@@ -124,7 +124,10 @@
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *token = [self stringWithDeviceToken:deviceToken];
NSLog(@"[DEBUG] push token: %@", token);
[[NSUserDefaults standardUserDefaults] setObject:token forKey:EQNUserDefaultPushToken];
FIRMessaging.messaging.APNSToken = deviceToken;
}
- (NSString *)stringWithDeviceToken:(NSData *)deviceToken
@@ -66,7 +66,8 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
super.viewDidLoad()
setupUI()
updateUI()
loadDataSource()
tableView.reloadData()
}
private func setupUI() {
@@ -83,7 +84,7 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
closeButton.setLocalizedTitle(key: "official_close", uppercased: false)
}
private func updateUI() {
private func loadDataSource() {
currentMagnitudoMinima = EQNData.magitudoDebole(for: EQNSeismic.shared.magnitudoMinima)
if initialMagnitudoMinima == nil {
initialMagnitudoMinima = currentMagnitudoMinima
@@ -97,7 +98,6 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
initialQualsiasiMagnitudo = currentSismiQualsiasiMagnitudo
}
currentModificaImpostazioni = EQNSeismic.shared.modificaImpostazioniAbilitato
tableView.reloadData()
}
// MARK: - Table view delegate and data source
@@ -111,7 +111,7 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
switch setting.type {
case .slider:
let cell = tableView.dequeueReusableCell(withIdentifier: SettingSliderTableViewCell.Identifier, for: indexPath) as! SettingSliderTableViewCell
let cell = SettingSliderTableViewCell(style: .default, reuseIdentifier: nil)
cell.titleLabel.text = setting.displayTitle
if indexPath.row == RowIdentifier.magnitudoMinima.rawValue {
@@ -120,7 +120,6 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentMagnitudoMinima = value
EQNSeismic.shared.magnitudoMinima = value.value
EQNSeismic.shared.saveFilters()
updateUI()
}
cell.dragEnded = { [unowned self] in
showWarningAlertIfNeeded(for: currentMagnitudoMinima)
@@ -131,7 +130,6 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentDistanzaMassima = value
EQNSeismic.shared.distanzaMassima = value.value
EQNSeismic.shared.saveFilters()
updateUI()
}
} else if indexPath.row == RowIdentifier.periodoTemporale.rawValue {
cell.configureSlider(with: dataSourcePeriodoTemporale, current: currentPeriodoTemporale)
@@ -139,7 +137,6 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentPeriodoTemporale = value
EQNSeismic.shared.periodoTemporale = value.value
EQNSeismic.shared.saveFilters()
updateUI()
}
} else if indexPath.row == RowIdentifier.sismiFortiDistanza.rawValue {
cell.isDisabled = !currentSismiFortiAbilitati
@@ -148,13 +145,12 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentSismiFortiDistanza = value
EQNSeismic.shared.sismiFortiMagnitudo = value.value
EQNSeismic.shared.saveFilters()
updateUI()
}
}
return cell
case .enable:
let cell = tableView.dequeueReusableCell(withIdentifier: SettingEnableTableViewCell.Identifier, for: indexPath) as! SettingEnableTableViewCell
let cell = SettingEnableTableViewCell(style: .default, reuseIdentifier: nil)
cell.titleLabel.text = setting.displayTitle
cell.detailTextLabel?.text = setting.subtitle
@@ -164,7 +160,9 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentSismiFortiAbilitati = value
EQNSeismic.shared.sismiFortiAbilitati = value
EQNSeismic.shared.saveFilters()
updateUI()
loadDataSource()
tableView.reloadData()
}
} else if indexPath.row == RowIdentifier.sismiQualsiasiMagnitudo.rawValue {
cell.toggleSwitch.isOn = currentSismiQualsiasiMagnitudo
@@ -172,7 +170,6 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentSismiQualsiasiMagnitudo = value
EQNSeismic.shared.sismiQualsiasiAbilitati = value
EQNSeismic.shared.saveFilters()
updateUI()
}
} else if indexPath.row == RowIdentifier.modificaImpostazioni.rawValue {
cell.toggleSwitch.isOn = currentModificaImpostazioni
@@ -180,7 +177,6 @@ class SeismicFiltersViewController: UIViewController, UITableViewDelegate, UITab
currentModificaImpostazioni = value
EQNSeismic.shared.modificaImpostazioniAbilitato = value
EQNSeismic.shared.saveFilters()
updateUI()
}
}
@@ -98,6 +98,12 @@ class SettingSliderTableViewCell: UITableViewCell {
let index = Int(sender.value)
let item = items[index]
// make slider with step values
let step: Float = 1
let roundedValue = round(sender.value / step) * step
sender.value = roundedValue
// update value
valueLabel.text = item.display
valueChanged?(item)
}
+4 -7
View File
@@ -130,14 +130,11 @@
- (void)inviaPosizioneServer
{
NSLog(@"URLPosizione %@", [EQNGeneratoreURLServer urlPosizione]);
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlPosizione] richiesta:EQNTipoChiamataPosizione success:^(id result) {
NSLog(@"inviato");
} failure:^(NSError *errore) {
NSLog(@"[EQNUtility] Position saved on server");
[self saveUserInfo];
} failure:^(NSError *error) {
NSLog(@"[EQNUtility] Unable to save position. Error: %@", error.localizedDescription);
}];
}
@@ -102,6 +102,10 @@
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *data = [defaults objectForKey:keyName];
if (!data) {
NSLog(@"[EQNUtility] No array saved for key '%@'", keyName);
return nil;
}
NSError *error;
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data error:&error];
@@ -119,6 +123,10 @@
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *data = [defaults objectForKey:keyName];
if (!data) {
NSLog(@"[EQNUtility] No dictionary saved for key '%@'", keyName);
return nil;
}
NSError *error;
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data error:&error];
@@ -53,7 +53,7 @@
[userDefaults setBool:self.isAbilitato forKey:NOTIFICHE_ALLERA_SISMICA_ABILITATO];
[userDefaults setObject:self.sismiDaNotificare forKey:NOTIFICHE_ALLERA_SISMICA_SISMI_DA_NOTIFICARE];
[userDefaults setObject:self.raggioSismiLievi forKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_LIEVI];
[userDefaults setObject:self.raggioSismiLievi forKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_FORTI];
[userDefaults setObject:self.raggioSismiForti forKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_FORTI];
[userDefaults setBool:self.isintervalloAllarme forKey:NOTIFICHE_ALLERA_SISMICA_ABILITA_INTERVALLO];
[userDefaults setObject:self.oraioInizio forKey:NOTIFICHE_ALLERA_SISMICA_ORA_INIZIO];
[userDefaults setObject:self.orarioFine forKey:NOTIFICHE_ALLERA_SISMICA_ORA_FINE];
@@ -137,6 +137,7 @@
case EQNTipoChiamataRilevamento:
onSuccess([EQNUtility clearStringMessaggi:newStr]);
break;
case EQNTipoChiamataPosizione:
case EQNTipoChiamataCalibrazione:
case EQNTipoChiamataImpostazioniNotifiche:
case EQNTipoChiamataAlertSimulator: