Compare commits

...

10 Commits

Author SHA1 Message Date
Andrea Busi d8fdba5e4f release: Increase version for release 2020-12-08 16:20:10 +01:00
Andrea Busi a05e186275 refactor: Rewrite EQNReteSmartphone model in Swift and use proper types for properties 2020-12-08 16:20:10 +01:00
Andrea Busi 7730da5faa dependency: Update Pods 2020-12-07 09:57:27 +01:00
Andrea Busi 9844dc9ac2 fix: Add missing return 2020-12-07 09:57:27 +01:00
Andrea Busi a9f16bca4a refactor: Reorganise code related to background monitoring
- Move to Models folder
- Improve code and nullability notation
- Rename class with typo in name
2020-12-07 09:46:43 +01:00
Andrea Busi 5612768d7f refactor: Remove useless imports 2020-12-07 09:46:43 +01:00
Andrea Busi ad1487afdf feat: Add server request to register in-app purchase
Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/29
2020-12-07 09:46:24 +01:00
Andrea Busi f707186dea refactor: Show restored product in alert 2020-12-02 21:16:10 +01:00
Andrea Busi 24f63c7d4b feat: Add message if no subscriptions are available to restore 2020-12-02 21:16:10 +01:00
Andrea Busi 9678040d51 refactor: Improve log in in-app purchase manager 2020-12-02 21:16:10 +01:00
38 changed files with 385 additions and 334 deletions
+10
View File
@@ -1,5 +1,15 @@
# Changelog
## Versione 3.2.1
### Build (50)
- Aggiunta chiamata per registrazione acquisto
- Rivisto modell EQNReteSmartphone
### Build (49)
- Aggiunta indicazione prodotto ripristinato
- Aggiunto messaggio se nessun prodotto da ripristinare
## Versione 3.2.0
### Build (48)
@@ -28,7 +28,7 @@
8C4DD4F9228237E000AE77ED /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8C4DD4FB228237E000AE77ED /* InfoPlist.strings */; };
8C4E343F215012FA008B0D2A /* EQNManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E343E215012FA008B0D2A /* EQNManager.m */; };
8C4E34422152B5E8008B0D2A /* EQNRilevamento.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E34412152B5E8008B0D2A /* EQNRilevamento.m */; };
8C4E34452152B707008B0D2A /* EQMAccelerometroManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E34442152B707008B0D2A /* EQMAccelerometroManager.m */; };
8C4E34452152B707008B0D2A /* EQNAccelerometroManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E34442152B707008B0D2A /* EQNAccelerometroManager.m */; };
8C4E344B2152EE5B008B0D2A /* EQNGeneratoreURLServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E344A2152EE5B008B0D2A /* EQNGeneratoreURLServer.m */; };
8C593E8A217BA2470008B260 /* EQNSegnalazione.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C593E89217BA2470008B260 /* EQNSegnalazione.m */; };
8C5EA22D21763103002DC156 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C5EA22C21763102002DC156 /* MapKit.framework */; };
@@ -65,7 +65,6 @@
8CF12CD921DE49B600613AC5 /* NotificationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CF12CD821DE49B600613AC5 /* NotificationViewController.m */; };
8CF12CDC21DE49B600613AC5 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8CF12CDA21DE49B600613AC5 /* MainInterface.storyboard */; };
8CF12CE021DE49B600613AC5 /* EQNNotificationContent.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 8CF12CD121DE49B600613AC5 /* EQNNotificationContent.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
8CF4F4D2216D2C780057110B /* EQNReteSmartphone.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CF4F4D1216D2C780057110B /* EQNReteSmartphone.m */; };
8CF4F4D8216D3A110057110B /* EQNAreaCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CF4F4D7216D3A110057110B /* EQNAreaCheck.m */; };
8CF4F4DB216D44930057110B /* EQNPastquakes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CF4F4DA216D44930057110B /* EQNPastquakes.m */; };
8CF6604F214C0E58009F4314 /* EQNCalibrazione.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CF6604E214C0E58009F4314 /* EQNCalibrazione.m */; };
@@ -86,6 +85,7 @@
DC2814302519C24400C1AFF7 /* SeismicNetworkTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC28142F2519C24400C1AFF7 /* SeismicNetworkTableViewCell.swift */; };
DC2814382519C56100C1AFF7 /* SeismicNetworksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC2814372519C56100C1AFF7 /* SeismicNetworksViewController.swift */; };
DC30BC882534DBBD0041B23B /* star_white1.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30BC872534DBBD0041B23B /* star_white1.png */; };
DC3B5429257FCBCA00C0B6A5 /* EQNReteSmartphone.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3B5428257FCBCA00C0B6A5 /* EQNReteSmartphone.swift */; };
DC3BA11124D1A9C90062EE7F /* SubscriptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3BA11024D1A9C90062EE7F /* SubscriptionsViewController.swift */; };
DC3CE50A250EB7A8005A7DD5 /* EQNGenericPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3CE509250EB7A8005A7DD5 /* EQNGenericPickerViewController.swift */; };
DC47D1BC252A0C2B004119F6 /* AlertsPastEartquakesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC47D1BB252A0C2B004119F6 /* AlertsPastEartquakesTableViewCell.swift */; };
@@ -308,8 +308,8 @@
8C4E343E215012FA008B0D2A /* EQNManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNManager.m; sourceTree = "<group>"; };
8C4E34402152B5E8008B0D2A /* EQNRilevamento.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNRilevamento.h; sourceTree = "<group>"; };
8C4E34412152B5E8008B0D2A /* EQNRilevamento.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNRilevamento.m; sourceTree = "<group>"; };
8C4E34432152B707008B0D2A /* EQMAccelerometroManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQMAccelerometroManager.h; sourceTree = "<group>"; };
8C4E34442152B707008B0D2A /* EQMAccelerometroManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQMAccelerometroManager.m; sourceTree = "<group>"; };
8C4E34432152B707008B0D2A /* EQNAccelerometroManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNAccelerometroManager.h; sourceTree = "<group>"; };
8C4E34442152B707008B0D2A /* EQNAccelerometroManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNAccelerometroManager.m; sourceTree = "<group>"; };
8C4E34492152EE5B008B0D2A /* EQNGeneratoreURLServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNGeneratoreURLServer.h; sourceTree = "<group>"; };
8C4E344A2152EE5B008B0D2A /* EQNGeneratoreURLServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNGeneratoreURLServer.m; sourceTree = "<group>"; };
8C593E88217BA2470008B260 /* EQNSegnalazione.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNSegnalazione.h; sourceTree = "<group>"; };
@@ -367,8 +367,6 @@
8CF12CD821DE49B600613AC5 /* NotificationViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationViewController.m; sourceTree = "<group>"; };
8CF12CDB21DE49B600613AC5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
8CF12CDD21DE49B600613AC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8CF4F4D0216D2C780057110B /* EQNReteSmartphone.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNReteSmartphone.h; sourceTree = "<group>"; };
8CF4F4D1216D2C780057110B /* EQNReteSmartphone.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNReteSmartphone.m; sourceTree = "<group>"; };
8CF4F4D6216D3A110057110B /* EQNAreaCheck.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNAreaCheck.h; sourceTree = "<group>"; };
8CF4F4D7216D3A110057110B /* EQNAreaCheck.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNAreaCheck.m; sourceTree = "<group>"; };
8CF4F4D9216D44930057110B /* EQNPastquakes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNPastquakes.h; sourceTree = "<group>"; };
@@ -394,6 +392,7 @@
DC28142F2519C24400C1AFF7 /* SeismicNetworkTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeismicNetworkTableViewCell.swift; sourceTree = "<group>"; };
DC2814372519C56100C1AFF7 /* SeismicNetworksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeismicNetworksViewController.swift; sourceTree = "<group>"; };
DC30BC872534DBBD0041B23B /* star_white1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = star_white1.png; sourceTree = "<group>"; };
DC3B5428257FCBCA00C0B6A5 /* EQNReteSmartphone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNReteSmartphone.swift; sourceTree = "<group>"; };
DC3BA11024D1A9C90062EE7F /* SubscriptionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionsViewController.swift; sourceTree = "<group>"; };
DC3CE509250EB7A8005A7DD5 /* EQNGenericPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNGenericPickerViewController.swift; sourceTree = "<group>"; };
DC414C0024CDA09A008D9AE4 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = "<group>"; };
@@ -726,14 +725,6 @@
8C60224B218EDBF700C799C2 /* annotation */,
8C4E343D215012FA008B0D2A /* EQNManager.h */,
8C4E343E215012FA008B0D2A /* EQNManager.m */,
8CF66051214C12DC009F4314 /* EQNMath.h */,
8CF66052214C12DC009F4314 /* EQNMath.m */,
8C4E34432152B707008B0D2A /* EQMAccelerometroManager.h */,
8C4E34442152B707008B0D2A /* EQMAccelerometroManager.m */,
8CF6604D214C0E58009F4314 /* EQNCalibrazione.h */,
8CF6604E214C0E58009F4314 /* EQNCalibrazione.m */,
8C4E34402152B5E8008B0D2A /* EQNRilevamento.h */,
8C4E34412152B5E8008B0D2A /* EQNRilevamento.m */,
8CF4F4D9216D44930057110B /* EQNPastquakes.h */,
8CF4F4DA216D44930057110B /* EQNPastquakes.m */,
8C593E88217BA2470008B260 /* EQNSegnalazione.h */,
@@ -893,6 +884,21 @@
path = Icons;
sourceTree = "<group>";
};
DC3640DF257E19A00037A4B7 /* Monitoring */ = {
isa = PBXGroup;
children = (
8CF66051214C12DC009F4314 /* EQNMath.h */,
8CF66052214C12DC009F4314 /* EQNMath.m */,
8C4E34432152B707008B0D2A /* EQNAccelerometroManager.h */,
8C4E34442152B707008B0D2A /* EQNAccelerometroManager.m */,
8CF6604D214C0E58009F4314 /* EQNCalibrazione.h */,
8CF6604E214C0E58009F4314 /* EQNCalibrazione.m */,
8C4E34402152B5E8008B0D2A /* EQNRilevamento.h */,
8C4E34412152B5E8008B0D2A /* EQNRilevamento.m */,
);
path = Monitoring;
sourceTree = "<group>";
};
DC3ADD2A24CB1E6600737919 /* Supporting Files */ = {
isa = PBXGroup;
children = (
@@ -1020,6 +1026,7 @@
DCB6FBE924D0B0DF00ED23B8 /* Models */ = {
isa = PBXGroup;
children = (
DC3640DF257E19A00037A4B7 /* Monitoring */,
DCF9E15024F6EA0B002B6B1D /* Networks */,
DC99A50124E66DFB0071BC9F /* Commands */,
DCEFF21824F587CC009D3FE1 /* Settings */,
@@ -1039,8 +1046,7 @@
DCF0188E252F09C500C783F0 /* EQNUtility+Extensions.swift */,
8C8EBBA521540039002784BA /* EQNUser.h */,
8C8EBBA621540039002784BA /* EQNUser.m */,
8CF4F4D0216D2C780057110B /* EQNReteSmartphone.h */,
8CF4F4D1216D2C780057110B /* EQNReteSmartphone.m */,
DC3B5428257FCBCA00C0B6A5 /* EQNReteSmartphone.swift */,
8CF4F4D6216D3A110057110B /* EQNAreaCheck.h */,
8CF4F4D7216D3A110057110B /* EQNAreaCheck.m */,
);
@@ -1503,6 +1509,7 @@
buildActionMask = 2147483647;
files = (
DCEFF21324F5821E009D3FE1 /* SettingDetailTableViewCell.swift in Sources */,
DC3B5429257FCBCA00C0B6A5 /* EQNReteSmartphone.swift in Sources */,
DCC23DEF24D28F58003A2404 /* EQNEdgeInsetLabel.swift in Sources */,
DCF0188F252F09C500C783F0 /* EQNUtility+Extensions.swift in Sources */,
8CCE165121E7BAEC00173CD9 /* EQNNotificheReteSismiche.m in Sources */,
@@ -1561,7 +1568,6 @@
8C14113121ED3E5B00A59729 /* SettingsRealTimeAlertsViewController.m in Sources */,
DCBB267A24D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift in Sources */,
DC65B391250F243E00251693 /* SeismicSettingsNetworksViewController.swift in Sources */,
8CF4F4D2216D2C780057110B /* EQNReteSmartphone.m in Sources */,
DC08804124F5B41400186D97 /* SettingSliderTableViewCell.swift in Sources */,
8CBD3DD82149B9AD0070C963 /* main.m in Sources */,
8CF05B57218C93BA0055012B /* EQNUtility.m in Sources */,
@@ -1576,7 +1582,7 @@
8CC1B15A217CB09100F22178 /* DettagliMappaViewController.m in Sources */,
8C5EA23D2177B51C002DC156 /* SegnalazioniViewController.m in Sources */,
8CF4F4D8216D3A110057110B /* EQNAreaCheck.m in Sources */,
8C4E34452152B707008B0D2A /* EQMAccelerometroManager.m in Sources */,
8C4E34452152B707008B0D2A /* EQNAccelerometroManager.m in Sources */,
8CBD3DC72149B9AD0070C963 /* AppDelegate.m in Sources */,
DC974AFF251748B300A139EC /* SeismicFiltersViewController.swift in Sources */,
DC105641251E7ECE002579BB /* UIFont+Extensions.swift in Sources */,
@@ -1683,12 +1689,12 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 50;
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 = 3.2.0;
MARKETING_VERSION = 3.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.EQNNotificationService;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Earthquake Network Extensions - Development";
@@ -1705,12 +1711,12 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 50;
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 = 3.2.0;
MARKETING_VERSION = 3.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.EQNNotificationService;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Earthquake Network Extensions - Development";
@@ -1843,14 +1849,14 @@
CODE_SIGN_ENTITLEMENTS = "Earthquake Network/Earthquake Network.entitlements";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 50;
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 = 3.2.0;
MARKETING_VERSION = 3.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
@@ -1871,13 +1877,13 @@
CODE_SIGN_ENTITLEMENTS = "Earthquake Network/Earthquake Network.entitlements";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 50;
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 = 3.2.0;
MARKETING_VERSION = 3.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
@@ -1893,12 +1899,12 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 50;
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 = 3.2.0;
MARKETING_VERSION = 3.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.EQNNotificationContent;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Earthquake Network Extensions - Development";
@@ -1915,12 +1921,12 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 50;
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 = 3.2.0;
MARKETING_VERSION = 3.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.finazzi.distquake.EQNNotificationContent;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Earthquake Network Extensions - Development";
+3 -3
View File
@@ -11,7 +11,7 @@
#import "ServerRequest.h"
#import "EQNGeneratoreURLServer.h"
#import "EQNUser.h"
#import "EQMAccelerometroManager.h"
#import "EQNAccelerometroManager.h"
#import "EQNManager.h"
#import "EQNUtility.h"
#import "EQNAllertaSismica.h"
@@ -76,7 +76,7 @@
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
[[EQNManager defaultManager] avviaManager];
[[EQMAccelerometroManager sharedInstance] startUpdatingLocationBackground];
[[EQNAccelerometroManager sharedInstance] startUpdatingLocationBackground];
NSUInteger counter = [[NSUserDefaults standardUserDefaults] integerForKey:CONTEGGIO_APERTURE_PER_SCONTO];
counter += 1;
@@ -87,7 +87,7 @@
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
[[EQNManager defaultManager] stopManager];
[[EQMAccelerometroManager sharedInstance] stopUpdatingLocation];
[[EQNAccelerometroManager sharedInstance] stopUpdatingLocation];
}
@@ -12,9 +12,7 @@
#import "EQNGeneratoreURLServer.h"
#import "EQNManager.h"
#import "PastquakesDettagliMappa.h"
#import "PastquakesAnnotation.h"
#import "EQNUser.h"
#import "AppDelegate.h"
#import "EQNAreaCheck.h"
@import StoreKit;
@import SafariServices;
@@ -29,8 +29,8 @@ class AlertsPastEartquakesTableViewCell: EQNBaseTableViewCell {
private func updateUI() {
guard let smartphoneNetwork = smartphoneNetwork else { return }
last24hLabel.text = smartphoneNetwork.eq;
from2013Label.text = smartphoneNetwork.eq_p;
last24hLabel.text = "\(smartphoneNetwork.counterLastDayAlerts)"
from2013Label.text = "\(smartphoneNetwork.counterTotalAlerts)"
}
// MARK: - Actions
@@ -23,9 +23,9 @@ class AlertsPriorityServiceTableViewCell: EQNBaseTableViewCell {
// MARK: - Private
private func updateUI() {
guard let smartphoneNetwork = smartphoneNetwork, let minutes = Int(smartphoneNetwork.diff) else { return }
guard let smartphoneNetwork = smartphoneNetwork else { return }
let formattedTime = EQNUtility.formattedString(forTimeDifference: minutes)
let formattedTime = EQNUtility.formattedString(forTimeDifference: smartphoneNetwork.lastSubscriptionDiff)
lastSubscriptionLabel.text = String(format: NSLocalizedString("inapp_adv", comment: ""), formattedTime)
}
}
@@ -28,7 +28,7 @@ class AlertsSmartphoneNetworkTableViewCell: EQNBaseTableViewCell {
private func updateUI() {
guard let smartphoneNetwork = smartphoneNetwork else { return }
smartphoneCounterLabel.text = smartphoneNetwork.green.stringValue
smartphoneCounterLabel.text = "\(smartphoneNetwork.counterSmartphones)"
}
// MARK: - Actions
@@ -7,7 +7,6 @@
//
#import "EQNBaseViewController.h"
#import "EQNUtility.h"
@import GoogleMobileAds;
@interface EQNBaseViewController ()
@@ -10,10 +10,7 @@
#import "AppDelegate.h"
#import "EQNBaseViewController.h"
#import "SettingsBaseViewController.h"
#import "EQNUtility.h"
#import "EQNManager.h"
#import "EQNGeneratoreURLServer.h"
#import "ServerRequest.h"
@interface EQNMainTabBarController () <UITabBarControllerDelegate>
@@ -79,6 +79,10 @@ class SubscriptionsViewController: UITableViewController {
NotificationCenter.default.addObserver(self, selector: #selector(fail(_:)),
name: .IAPHelperPurchaseNotificationFail,
object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleNoTransactionsNotification(_:)),
name: .IAPHelperPurchaseNoTransactions,
object: nil)
}
private func configureUI() {
@@ -173,8 +177,14 @@ class SubscriptionsViewController: UITableViewController {
if isRestorePurchase {
isRestorePurchase = false
var product: String = "unknown"
if let productIdentifier = notification.object as? String, let productName = resourceNameForProductIdentifier(productIdentifier) {
product = productName
}
let message = "\(NSLocalizedString("purchase_pro_restore_alert_message", comment: ""))\n\n(\(product))"
let alert = UIAlertController(title: NSLocalizedString("purchase_pro_restore_alert_title", comment: ""),
message: NSLocalizedString("purchase_pro_restore_alert_message", comment: ""), preferredStyle: .alert)
message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}
@@ -182,6 +192,13 @@ class SubscriptionsViewController: UITableViewController {
VersioneProProducts.store.loadPurchase()
loadData()
}
@objc func handleNoTransactionsNotification(_ notification: Notification) {
let alert = UIAlertController(title: NSLocalizedString("Attenzione", comment: ""),
message: NSLocalizedString("purchase_pro_no_subscriptions_alert_message", comment: ""), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}
// MARK: - Table view data source
@@ -87,13 +87,13 @@ static NSString * const SegueIdentifierMap = @"ShowMap";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Last24HCell" forIndexPath:indexPath];
UILabel *verdeLabel = (UILabel *)[cell viewWithTag:1];
verdeLabel.text = [NSString stringWithFormat:@"%@", reteSmartPhone.g_man];
verdeLabel.text = [NSString stringWithFormat:@"%ld", (long)reteSmartPhone.manualGreen];
UILabel *giallaLabel = (UILabel *)[cell viewWithTag:2];
giallaLabel.text = [NSString stringWithFormat:@"%@", reteSmartPhone.y_man];
giallaLabel.text = [NSString stringWithFormat:@"%ld", (long)reteSmartPhone.manualYellow];
UILabel *rossaLabel = (UILabel *)[cell viewWithTag:3];
rossaLabel.text = [NSString stringWithFormat:@"%@", reteSmartPhone.r_man];
rossaLabel.text = [NSString stringWithFormat:@"%ld", (long)reteSmartPhone.manualRed];
return cell;
}
@@ -8,7 +8,6 @@
#import "SettingsUserReportAlertsViewController.h"
#import "EQNNotificheSegnalazioniUtente.h"
#import "EQNUtility.h"
@interface SettingsUserReportAlertsViewController ()
+8 -4
View File
@@ -35,6 +35,8 @@ static NSString * const EQNServerUrlDownloadRetiSismiche = @"https://srv.earthqu
static NSString * const EQNServerUrlOfferTimeRemaining = @"https://srv.earthquakenetwork.it/distquake_download_offer_time_remaining.php";
/// Recupera il numero di sottoscrizioni ancora disponibili per ogni prodotto
static NSString * const EQNServerUrlAvailableSubscriptionsCounter = @"https://srv.earthquakenetwork.it/distquake_count_top_redis.php";
/// Registra l'abbonamento acquistato dall'utente
static NSString * const EQNServerUrlRegisterSubscription = @"https://srv.earthquakenetwork.it/distquake_upload_subscription.php";
/// Carica le impostazioni delle notifiche definite dall'utente
static NSString * const EQNServerUrlUploadSettings = @"https://srv.earthquakenetwork.it/distquake_upload_settings_ios.php";
// URL EQNTipoChiamataRegistrazione server
@@ -132,6 +134,7 @@ typedef NS_ENUM(NSInteger, EQNTipoChiamata) {
EQNTipoChiamataCommentoTerremoto,
EQNTipoChiamataImpostazioniNotifiche,
EQNTipoChiamataOfferTimeRemaining,
EQNTipoChiamataRegisterSubscription,
EQNTipoChiamataAlertPushTest,
EQNTipoChiamataAlertSimulator
};
@@ -153,12 +156,13 @@ typedef NS_ENUM(NSInteger, EQNTipoChiamata) {
#define SECONDI_RILIEVO 3
// Soglia deviazione standard se superata lo stato del rilievo è positivo altrimenti negativo
#define SOGLIA_DEVIAZIONE_RILIEVO 1.8
// stato rilievo
// il parametro viene inviato al server e_t1
typedef enum : NSInteger {
negativo = 0,
positivo
} EQNRilevamentoSoglia;
typedef NS_ENUM(NSInteger, EQNRilevamentoSoglia) {
EQNRilevamentoSogliaNegativo = 0,
EQNRilevamentoSogliaPositivo
};
//////////////////////////////////////// CALIBRAZIONE ////////////////////////////////////////
// secondi durata calibrazione
@@ -1,28 +0,0 @@
//
// EQNReteSmartphone.h
// Earthquake Network
//
// Created by Luca Beretta on 09/10/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface EQNReteSmartphone : NSObject
@property (nonatomic, strong) NSString *eq;
@property (nonatomic, strong) NSString *eq_p;
@property (nonatomic, strong) NSNumber *green;
@property (nonatomic, strong) NSNumber *g_man;
@property (nonatomic, strong) NSNumber *y_man;
@property (nonatomic, strong) NSNumber *r_man;
@property (nonatomic, strong) NSString *diff;
@property (nonatomic) BOOL subscriptionsDiscounted;
- (instancetype)initWithInfo:(NSArray *)list;
@end
NS_ASSUME_NONNULL_END
@@ -1,82 +0,0 @@
//
// EQNReteSmartphone.m
// Earthquake Network
//
// Created by Luca Beretta on 09/10/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import "EQNReteSmartphone.h"
@implementation EQNReteSmartphone
#pragma mark - Init
- (instancetype)initWithInfo:(NSArray *)list
{
self = [super init];
if (self) {
for ( int i = 0; i < list.count; i++) {
NSDictionary *dict = list[i];
switch (i) {
case 0:
_eq = dict[@"eq"];
break;
case 1:
_eq_p = dict[@"eq_p"];
break;
case 2:
_green = dict[@"green"];
break;
case 3:
_g_man = dict[@"g_man"];
break;
case 4:
_y_man = dict[@"y_man"];
break;
case 5:
_r_man = dict[@"r_man"];
break;
case 6:
_diff = dict[@"diff"];
break;
case 7:
self.subscriptionsDiscounted = [dict[@"st"] boolValue];
break;
default:
break;
}
}
}
return self;
}
#pragma mark - NSCoding
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:self.eq forKey:@"eq"];
[encoder encodeObject:self.eq_p forKey:@"eq_p"];
[encoder encodeObject:self.green forKey:@"green"];
[encoder encodeObject:self.g_man forKey:@"g_man"];
[encoder encodeObject:self.y_man forKey:@"y_man"];
[encoder encodeObject:self.r_man forKey:@"r_man"];
[encoder encodeObject:self.diff forKey:@"diff"];
}
- (instancetype)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if (self) {
self.eq = [decoder decodeObjectForKey:@"eq"];
self.eq_p = [decoder decodeObjectForKey:@"eq_p"];
self.green = [decoder decodeObjectForKey:@"green"];
self.g_man = [decoder decodeObjectForKey:@"g_man"];
self.y_man = [decoder decodeObjectForKey:@"y_man"];
self.r_man = [decoder decodeObjectForKey:@"r_man"];
self.diff = [decoder decodeObjectForKey:@"diff"];
}
return self;
}
@end
@@ -0,0 +1,57 @@
//
// EQNReteSmartphone.swift
// Earthquake Network
//
// Created by Busi Andrea on 08/12/2020.
// Copyright © 2020 Earthquake Network. All rights reserved.
//
import Foundation
@objc
class EQNReteSmartphone: NSObject {
@objc let counterLastDayAlerts: Int
@objc let counterTotalAlerts: Int
@objc let counterSmartphones: Int
@objc let manualGreen: Int
@objc let manualYellow: Int
@objc let manualRed: Int
@objc let lastSubscriptionDiff: Int
@objc let subscriptionsDiscounted: Bool
// MARK: - Init
@objc 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 })
}
self.counterLastDayAlerts = Self.getValue(from: allValues, for: "eq")
self.counterTotalAlerts = Self.getValue(from: allValues, for: "eq_p")
self.counterSmartphones = Self.getValue(from: allValues, for: "green")
self.manualGreen = Self.getValue(from: allValues, for: "g_man")
self.manualYellow = Self.getValue(from: allValues, for: "y_man")
self.manualRed = Self.getValue(from: allValues, for: "r_man")
self.lastSubscriptionDiff = Self.getValue(from: allValues, for: "diff")
let subscriptionsDiscounted = Self.getValue(from: allValues, for: "st")
self.subscriptionsDiscounted = subscriptionsDiscounted == 1
super.init()
}
// MARK: - Private
/// This method helps to extract an int value from the received values (where data are both strings and integers).
/// If convertion is not possible, it will return zero.
private static func getValue(from values: [String: Any], for key: String) -> Int {
if let intValue = values[key] as? Int {
return intValue
}
if let stringValue = values[key] as? String, let intValue = Int(stringValue) {
return intValue
}
return 0
}
}
+6 -6
View File
@@ -8,7 +8,7 @@
#import "EQNUser.h"
#import "Costanti.h"
#import "EQMAccelerometroManager.h"
#import "EQNAccelerometroManager.h"
#import "ServerRequest.h"
#import "EQNGeneratoreURLServer.h"
#import "EQNUtility.h"
@@ -49,12 +49,12 @@
self.registrato = YES;
}
[[EQMAccelerometroManager sharedInstance] addObserver:(id)self
[[EQNAccelerometroManager sharedInstance] addObserver:(id)self
forKeyPath:@"currentLocation"
options:NSKeyValueObservingOptionNew
context:nil];
[[EQMAccelerometroManager sharedInstance] startUpdatingLocationBackground];
[[EQNAccelerometroManager sharedInstance] startUpdatingLocationBackground];
}
return self;
}
@@ -83,13 +83,13 @@
if ([keyPath isEqualToString:@"currentLocation"]) {
// do some stuff
if (self.lastPosition) {
self.distanza = [self.lastPosition distanceFromLocation:[EQMAccelerometroManager sharedInstance].currentLocation];
self.distanza = [self.lastPosition distanceFromLocation:[EQNAccelerometroManager sharedInstance].currentLocation];
}
self.lastPosition = [EQMAccelerometroManager sharedInstance].currentLocation;
self.lastPosition = [EQNAccelerometroManager sharedInstance].currentLocation;
[self verificaRegistrazione];
if (![EQNManager defaultManager].isBackground)
[[EQMAccelerometroManager sharedInstance] stopUpdatingLocation];
[[EQNAccelerometroManager sharedInstance] stopUpdatingLocation];
}
}
@@ -34,6 +34,8 @@ public typealias ProductsRequestCompletionHandler = (_ success: Bool, _ products
extension Notification.Name {
static let IAPHelperPurchaseNotification = Notification.Name("IAPHelperPurchaseNotification")
static let IAPHelperPurchaseNotificationFail = Notification.Name("IAPHelperPurchaseNotificationFail")
/// No available transactions to restore
static let IAPHelperPurchaseNoTransactions = Notification.Name("IAPHelperPurchaseNoTransactions")
}
@@ -83,11 +85,9 @@ extension IAPHelper {
}
public func buyProduct(_ product: SKProduct) {
print("Buying \(product.productIdentifier)...")
print("[IAPHelper] Buying product \(product.productIdentifier)...")
let payment = SKPayment(product: product)
SKPaymentQueue.default().add(payment)
}
public func isProductPurchased(_ productIdentifier: ProductIdentifier) -> Bool {
@@ -108,23 +108,17 @@ extension IAPHelper {
extension IAPHelper: SKProductsRequestDelegate {
public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("[IAPHelper] Loaded list of products...")
let products = response.products
products.forEach { (p) in
print("[IAPHelper] Found product: \(p.productIdentifier) \(p.localizedTitle) \(p.price.floatValue)")
}
print("[IAPHelper] Products loaded (count: \(response.products.count))")
// this protocol method is not guaranteed to be dispatched on main thread
DispatchQueue.main.async {
self.productsRequestCompletionHandler?(true, products)
self.productsRequestCompletionHandler?(true, response.products)
self.clearRequestAndHandler()
}
}
public func request(_ request: SKRequest, didFailWithError error: Error) {
print("[IAPHelper] Failed to load list of products.")
print("[IAPHelper] Error: \(error.localizedDescription)")
print("[IAPHelper] Failed to load list of products (error: \(error.localizedDescription))")
// this protocol method is not guaranteed to be dispatched on main thread
DispatchQueue.main.async {
@@ -143,18 +137,29 @@ extension IAPHelper: SKProductsRequestDelegate {
extension IAPHelper: SKPaymentTransactionObserver {
public func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
print("[IAPHelper] Restore transaction completed")
if queue.transactions.count == 0 {
NotificationCenter.default.post(name: .IAPHelperPurchaseNoTransactions, object: nil)
}
}
public func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) {
print("[IAPHelper] Restore transaction failed (error : \(error.localizedDescription))")
NotificationCenter.default.post(name: .IAPHelperPurchaseNotificationFail, object: nil)
}
public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("[IAPHelper] Updated transactions (count: \(transactions.count))")
for transaction in transactions {
switch (transaction.transactionState) {
case .purchased:
complete(transaction: transaction)
break
handlePurchased(transaction: transaction)
case .failed:
fail(transaction: transaction)
break
handleFailed(transaction: transaction)
case .restored:
restore(transaction: transaction)
break
handleRestored(transaction: transaction)
case .deferred:
break
case .purchasing:
@@ -165,31 +170,37 @@ extension IAPHelper: SKPaymentTransactionObserver {
}
}
private func complete(transaction: SKPaymentTransaction) {
print("complete...")
private func handlePurchased(transaction: SKPaymentTransaction) {
print("[IAPHelper] Handle purchased transaction (product: \(transaction.payment.productIdentifier))")
deliverPurchaseNotificationFor(identifier: transaction.payment.productIdentifier)
SKPaymentQueue.default().finishTransaction(transaction)
// register subscription
serverPurchaseRegistration(for: transaction.payment.productIdentifier, transactionId:transaction.transactionIdentifier)
}
private func restore(transaction: SKPaymentTransaction) {
guard let productIdentifier = transaction.original?.payment.productIdentifier else { return }
private func handleRestored(transaction: SKPaymentTransaction) {
guard let productIdentifier = transaction.original?.payment.productIdentifier else {
print("[IAPHelper] Handle restored transaction falied, cannot retrieve productIdentifier")
return
}
print("restore... \(productIdentifier)")
print("[IAPHelper] Handle restored transaction (product: \(productIdentifier))")
deliverPurchaseNotificationFor(identifier: productIdentifier)
SKPaymentQueue.default().finishTransaction(transaction)
// register subscription
serverPurchaseRegistration(for: productIdentifier, transactionId: transaction.transactionIdentifier)
}
private func fail(transaction: SKPaymentTransaction) {
print("fail...")
private func handleFailed(transaction: SKPaymentTransaction) {
print("[IAPHelper] Handle failed transaction (product: \(transaction.payment.productIdentifier))")
if let transactionError = transaction.error as NSError?,
let localizedDescription = transaction.error?.localizedDescription,
transactionError.code != SKError.paymentCancelled.rawValue {
print("Transaction Error: \(localizedDescription)")
print("[IAPHelper] Handle failed transaction error: \(localizedDescription)")
}
NotificationCenter.default.post(name: .IAPHelperPurchaseNotificationFail, object: nil)
SKPaymentQueue.default().finishTransaction(transaction)
}
@@ -202,5 +213,16 @@ extension IAPHelper: SKPaymentTransactionObserver {
NotificationCenter.default.post(name: .IAPHelperPurchaseNotification, object: identifier)
}
private func serverPurchaseRegistration(for productId: String, transactionId: String?) {
let idTransaction = transactionId ?? "NOT_AVAILABLE"
let url = EQNGeneratoreURLServer.urlRegisterSubscription(forProductId: productId, transactionId: idTransaction)
ServerRequest.default().inviaInformazioniAlServer(with: url, richiesta: .registerSubscription) { (response) in
// nope
print("[IAPHelper] Subscription registered with server")
} failure: { (error) in
// nope
print("[IAPHelper] Error when registering subscription (error: \(String(describing: error?.localizedDescription))")
}
}
}
@@ -1,5 +1,5 @@
//
// EQMAccelerometroManager.h
// EQNAccelerometroManager.h
// Earthquake Network
//
// Created by Luca Beretta on 19/09/18.
@@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface EQMAccelerometroManager : NSObject
@interface EQNAccelerometroManager : NSObject
@property (strong, nonatomic) CLLocationManager *locationManager;
@property (strong, nonatomic, nullable) CLLocation *currentLocation;
@@ -1,29 +1,29 @@
//
// EQMAccelerometroManager.m
// EQNAccelerometroManager.m
// Earthquake Network
//
// Created by Luca Beretta on 19/09/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import "EQMAccelerometroManager.h"
#import "EQNAccelerometroManager.h"
#import <CoreMotion/CoreMotion.h>
#import "Costanti.h"
#import "EQNMath.h"
#import "EQNUser.h"
#import "EQNManager.h"
@interface EQMAccelerometroManager () <CLLocationManagerDelegate>
@interface EQNAccelerometroManager () <CLLocationManagerDelegate>
@property (nonatomic, assign) BOOL posizioneRilevata;
@end
@implementation EQMAccelerometroManager
@implementation EQNAccelerometroManager
#pragma mark - Singleton
+ (instancetype)sharedInstance
{
static EQMAccelerometroManager *instance = nil;
static EQNAccelerometroManager *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc]init];
@@ -36,7 +36,7 @@
- (instancetype)init
{
self = [super init];
if(self) {
if (self) {
self.locationManager = [[CLLocationManager alloc] init];
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]){
[self.locationManager requestAlwaysAuthorization];
@@ -9,7 +9,9 @@
#import <Foundation/Foundation.h>
#import "Costanti.h"
@interface EQNCalibrazione : NSObject <NSCopying>
NS_ASSUME_NONNULL_BEGIN
@interface EQNCalibrazione : NSObject <NSCopying>
@property (nonatomic, assign) float media;
@property (nonatomic, assign) float deviazione;
@@ -17,8 +19,8 @@
@property (nonatomic, assign) EQNStatoCal stato;
+(void)startCalibrazione:(void(^)(EQNCalibrazione *cal))cal;
//-(NSString *)serverMessage;
+ (void)startCalibrazione:(void(^)(EQNCalibrazione *cal))cal;
@end
NS_ASSUME_NONNULL_END
@@ -8,14 +8,27 @@
#import "EQNCalibrazione.h"
#import "EQNMath.h"
#import "EQMAccelerometroManager.h"
#import "EQNAccelerometroManager.h"
@implementation EQNCalibrazione
+(void)startCalibrazione:(void(^)(EQNCalibrazione *cal))cal{
#pragma mark - NSCopying
[EQMAccelerometroManager avviaLetturaAccellerometroIsCalibrazione:YES withCompletion:^(NSArray *dati) {
// [[EQMAccelerometroManager sharedInstance] startUpdatingLocation];
- (id)copyWithZone:(NSZone *)zone
{
EQNCalibrazione *model = [[[self class] allocWithZone:zone] init];
model.media = self.media;
model.deviazione = self.deviazione;
model.r3 = self.r3;
model.stato = self.stato;
return model;
}
#pragma mark - Public
+ (void)startCalibrazione:(void(^)(EQNCalibrazione *cal))cal
{
[EQNAccelerometroManager avviaLetturaAccellerometroIsCalibrazione:YES withCompletion:^(NSArray *dati) {
EQNCalibrazione *calibrazione = [[EQNCalibrazione alloc] init];
calibrazione.media = [[EQNMath meanOf:dati] floatValue];
calibrazione.deviazione = [[EQNMath standardDeviationOf:dati] floatValue];
@@ -23,29 +36,15 @@
float max = [rDic[rMax] floatValue] - calibrazione.media;
float min = [rDic[rMin] floatValue] - calibrazione.media;
calibrazione.r3 = max;
if ( max != min){
if (max != min){
if (min > SOGLIAMIN && max < SOGLIAMAX){
calibrazione.stato = calibrato;
}else
} else {
calibrazione.stato = nonCalibrato;
}
}
cal(calibrazione);
}];
}
-(id)copyWithZone:(NSZone *)zone {
EQNCalibrazione *model = [[[self class] allocWithZone:zone] init];
model.media = self.media;
model.deviazione = self.deviazione;
model.r3 = self.r3;
model.stato = self.stato;
return model;
}
@end
@@ -9,15 +9,22 @@
#import <Foundation/Foundation.h>
#import <CoreMotion/CoreMotion.h>
NS_ASSUME_NONNULL_BEGIN
@interface EQNMath : NSObject
// calcola la somma dei quadrati delle assi/G ottenute dall'accelerometro
/// Calcola la somma dei quadrati delle assi/G ottenute dall'accelerometro
+ (float)powSum:(CMAccelerometerData *)accelerometerData;
// calcola la media dei valori contenuta nell'array passato
/// Calcola la media dei valori contenuta nell'array passato
+ (NSNumber *)meanOf:(NSArray *)array;
// calcola la deviazione standard dei valori contenuti nell'array passato
+ (NSNumber *)standardDeviationOf:(NSArray *)array;
// restituisce valore massimo e valore minimo contenuto nellarray
/// Calcola la deviazione standard dei valori contenuti nell'array passato
+ (nullable NSNumber *)standardDeviationOf:(NSArray *)array;
// Restituisce valore massimo e valore minimo contenuto nellarray
+ (NSDictionary *)rLimiti:(NSArray *)array;
@end
NS_ASSUME_NONNULL_END
@@ -7,12 +7,14 @@
//
#import "EQNMath.h"
#include <math.h>
#import "Costanti.h"
#include <math.h>
@implementation EQNMath
#pragma mark - Public
+ (float)powSum:(CMAccelerometerData *)accelerometerData {
return sqrt(pow(accelerometerData.acceleration.x, 2.0)+pow(accelerometerData.acceleration.y, 2.0)+pow(accelerometerData.acceleration.z, 2.0));
@@ -21,7 +23,7 @@
+ (NSNumber *)meanOf:(NSArray *)array
{
double runningTotal = 0.0;
for(NSNumber *number in array)
for (NSNumber *number in array)
{
runningTotal += [number doubleValue];
}
@@ -31,10 +33,12 @@
+ (NSNumber *)standardDeviationOf:(NSArray *)array
{
if(![array count]) return nil;
if (![array count]) {
return nil;
}
double mean = [[self meanOf:array] doubleValue];
double sumOfSquaredDifferences = 0.0;
for(NSNumber *number in array)
for (NSNumber *number in array)
{
double valueOfNumber = [number doubleValue];
double difference = valueOfNumber - mean;
@@ -43,8 +47,9 @@
return [NSNumber numberWithDouble:sqrt(sumOfSquaredDifferences / [array count])];
}
+ (NSDictionary *)rLimiti:(NSArray *)array{
+ (NSDictionary *)rLimiti:(NSArray *)array
{
float xmax = -MAXFLOAT;
float xmin = MAXFLOAT;
@@ -56,4 +61,5 @@
return @{rMax : @(xmax), rMin : @(xmin)};
}
@end
@@ -10,6 +10,13 @@
#import "EQNCalibrazione.h"
#import "Costanti.h"
NS_ASSUME_NONNULL_BEGIN
@class EQNRilevamento;
typedef void (^calibrationCompletion)(EQNRilevamento * _Nullable rilevamento);
@interface EQNRilevamento : NSObject
@property (nonatomic, assign) float media;
@@ -18,7 +25,11 @@
@property (nonatomic, assign) EQNRilevamentoSoglia rilievo;
@property (nonatomic, strong) NSDate *timestamp;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithMedia:(float)media deviazione:(float)deviazione maxAssoluto:(float)maxAssoluto rilievo:(EQNRilevamentoSoglia)rilievo timestamp:(NSDate *)timestamp;
+(void)startRilevamentoWithCalibrazione:(EQNCalibrazione *)cal result:(void(^)(EQNRilevamento *ril))rilevamento;
+ (void)startRilevamentoWithCalibrazione:(EQNCalibrazione *)cal result:(calibrationCompletion)rilevamento;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,57 @@
//
// EQNRilevamento.m
// Earthquake Network
//
// Created by Luca Beretta on 19/09/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import "EQNRilevamento.h"
#import <CoreMotion/CoreMotion.h>
#import "EQNMath.h"
#import "EQNAccelerometroManager.h"
@implementation EQNRilevamento
#pragma mark - Init
- (instancetype)initWithMedia:(float)media deviazione:(float)deviazione maxAssoluto:(float)maxAssoluto rilievo:(EQNRilevamentoSoglia)rilievo timestamp:(NSDate *)timestamp
{
self = [super init];
if (self) {
self.media = media;
self.deviazione = deviazione;
self.maxAssoluto = maxAssoluto;
self.rilievo = rilievo;
self.timestamp = timestamp;
}
return self;
}
#pragma mark - Public
+ (void)startRilevamentoWithCalibrazione:(EQNCalibrazione *)cal result:(calibrationCompletion)rilevamento
{
if (!cal) {
rilevamento(nil);
return;
}
[EQNAccelerometroManager avviaLetturaAccellerometroIsCalibrazione:NO withCompletion:^(NSArray *dati) {
float media = [[EQNMath meanOf:dati] floatValue];
float deviazione = [[EQNMath standardDeviationOf:dati] floatValue];
NSDictionary *rDic = [EQNMath rLimiti:dati];
float max = [rDic[rMax] floatValue] - cal.media;
float maxAssoluto = fabsf(max);
EQNRilevamentoSoglia rilievo = (deviazione > SOGLIA_DEVIAZIONE_RILIEVO*cal.deviazione) ? EQNRilevamentoSogliaPositivo : EQNRilevamentoSogliaNegativo;
EQNRilevamento *aRilievo = [[EQNRilevamento alloc] initWithMedia:media
deviazione:deviazione
maxAssoluto:maxAssoluto
rilievo:rilievo
timestamp:[NSDate date]];
rilevamento(aRilievo);
}];
}
@end
@@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSURL *)urlInvioCommentoTerremoto:(NSString *)commento codeMessage:(NSString *)code;
+ (NSURL *)urlInvioImpostazioniNotifiche;
+ (NSURL *)urlDownloadOfferTimeRemaining;
+ (NSURL *)urlRegisterSubscriptionForProductId:(NSString *)productId transactionId:(NSString *)transactionId;
+ (NSURL *)urlAlertPushTest;
+ (NSURL *)urlAlertSimulator;
@@ -48,7 +48,7 @@
NSString *e_t = @"0";
NSString *a_max = @"0";
if (rilevamento.rilievo == positivo){
if (rilevamento.rilievo == EQNRilevamentoSogliaPositivo){
e_t = @"1";
a_max =[NSString stringWithFormat:@"%f",rilevamento.maxAssoluto];
}
@@ -243,6 +243,13 @@
return [NSURL URLWithString:stringUrl];
}
+ (NSURL *)urlRegisterSubscriptionForProductId:(NSString *)productId transactionId:(NSString *)transactionId
{
NSString *walletSub = @""; // codice associato all'acquisto che conosce anche l'utente (se esiste)
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&token_sub=%@&wallet_sub=%@&sku=%@&ios=1", EQNServerUrlRegisterSubscription, [EQNUser defaultUser].user_ID, transactionId, walletSub, productId];
return [NSURL URLWithString:stringUrl];
}
+ (NSURL *)urlAlertPushTest
{
EQNGenericValue *radius = [EQNData raggioSismaFor:[EQNAllertaSismica sharedInstance].raggioSismiLievi];
@@ -7,7 +7,6 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "Costanti.h"
NS_ASSUME_NONNULL_BEGIN
@@ -140,6 +140,7 @@
case EQNTipoChiamataCalibrazione:
case EQNTipoChiamataImpostazioniNotifiche:
case EQNTipoChiamataAlertSimulator:
case EQNTipoChiamataRegisterSubscription:
onSuccess(newStr);
default:
// don't call the callback
@@ -8,7 +8,7 @@
#import "LogViewController.h"
#import "EQNManager.h"
#import "EQMAccelerometroManager.h"
#import "EQNAccelerometroManager.h"
#import "EQNUser.h"
@interface LogViewController ()
@@ -27,7 +27,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aggiornaLog:) name:@"AGGIORNA_LOG" object:nil];
[[EQNManager defaultManager] avviaManager];
[[EQMAccelerometroManager sharedInstance] startUpdatingLocationBackground];
[[EQNAccelerometroManager sharedInstance] startUpdatingLocationBackground];
self.testo = [NSString stringWithFormat:@" LOG ID UTENTE %@\n\nTOKEN FIREBASE:\n%@\n\n", [EQNUser defaultUser].user_ID, [EQNUser defaultUser].tokenUser];
@@ -42,7 +42,7 @@
[[EQNManager defaultManager] stopManager];
[[EQMAccelerometroManager sharedInstance] stopUpdatingLocation];
[[EQNAccelerometroManager sharedInstance] stopUpdatingLocation];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self dismissViewControllerAnimated:YES completion:nil];
@@ -244,6 +244,7 @@
"purchase_pro_restore" = "Restore";
"purchase_pro_restore_alert_title" = "Restore completed";
"purchase_pro_restore_alert_message" = "You have restored the product you purchased";
"purchase_pro_no_subscriptions_alert_message" = "No purchase was found to restore. Make sure you are logged into the account the purchase was made with.";
"inapp_available_10k" = "Top 10K: %lu subscriptions still available to be alerted in less than 1 second since the detection of the quake";
"inapp_available_100k" = "Top 100K: %lu subscriptions still available to be alerted in less than 1 second since the detection of the quake";
@@ -244,6 +244,7 @@
"purchase_pro_restore" = "Reiniciar";
"purchase_pro_restore_alert_title" = "Restauración completada";
"purchase_pro_restore_alert_message" = "Has restaurado el producto que compraste";
"purchase_pro_no_subscriptions_alert_message" = "No se encontró ninguna compra para restaurar. Asegúrese de haber iniciado sesión en la cuenta con la que realizó la compra.";
"inapp_available_10k" = "Top 10K: %d suscripciones aún disponibles para recibir la alerta en menos de 1 segundo a partir de la detección del sismo";
"inapp_available_100k" = "Top 100K: %d suscripciones aún disponibles para recibir la alerta en menos de 1 segundo a partir de la detección del sismo";
@@ -244,6 +244,7 @@
"purchase_pro_restore" = "Ripristina";
"purchase_pro_restore_alert_title" = "Ripristino effettuato";
"purchase_pro_restore_alert_message" = "Hai ripristinato il prodotto da te acquistato";
"purchase_pro_no_subscriptions_alert_message" = "Attenzione, non è stato trovato alcun acquisto da ripristinare. Assicurati di essere collegato con l'account con il quale era stato effettuato l'acquisto.";
"inapp_available_10k" = "Top 10K: %lu sottoscrizioni ancora disponibili per essere allertato in meno di 1 secondo dal rilevamento del sisma";
"inapp_available_100k" = "Top 100K: %lu sottoscrizioni ancora disponibili per essere allertato in meno di 5 secondi dal rilevamento del sisma";
@@ -7,10 +7,10 @@
//
#import <Foundation/Foundation.h>
#import "EQNReteSmartphone.h"
#import "EQNAreaCheck.h"
@class EQNSisma;
@class EQNReteSmartphone;
@interface EQNManager : NSObject
@@ -7,14 +7,12 @@
//
#import "EQNManager.h"
#import <UIKit/UIKit.h>
#import "EQNCalibrazione.h"
#import "EQNRilevamento.h"
#import "EQNUser.h"
#import "Costanti.h"
#import "ServerRequest.h"
#import "EQNGeneratoreURLServer.h"
#import "EQNReteSmartphone.h"
#import "EQNPastquakes.h"
#import "EQNSegnalazione.h"
#import "EQNSisma.h"
@@ -314,7 +312,7 @@
}
switch (ril.rilievo) {
case positivo:{
case EQNRilevamentoSogliaPositivo:{
[self performSelectorOnMainThread:@selector(iniviaMessaggioAlServer:)
withObject:ril
waitUntilDone:YES];
@@ -322,7 +320,7 @@
self.calibrazione = nil;
}
break;
case negativo:
case EQNRilevamentoSogliaNegativo:
/* [self performSelectorOnMainThread:@selector(riavviaRilevamento)
withObject:nil
waitUntilDone:YES];*/
@@ -347,7 +345,7 @@
{
EQNTipoChiamata tipo = EQNTipoChiamataCalibrazione;
EQNCalibrazione *anCalibrazione = [self.calibrazione copy];
if (anRilevamento.rilievo == positivo){
if (anRilevamento.rilievo == EQNRilevamentoSogliaPositivo){
tipo = EQNTipoChiamataRilevamento;
[self annullaCalibrazione];
}
@@ -1,39 +0,0 @@
//
// EQNRilevamento.m
// Earthquake Network
//
// Created by Luca Beretta on 19/09/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import "EQNRilevamento.h"
#import <CoreMotion/CoreMotion.h>
#import "EQNMath.h"
#import "EQMAccelerometroManager.h"
@implementation EQNRilevamento
+(void)startRilevamentoWithCalibrazione:(EQNCalibrazione *)cal result:(void(^)(EQNRilevamento *ril))rilevamento{
if (!cal)
rilevamento(NULL);
[EQMAccelerometroManager avviaLetturaAccellerometroIsCalibrazione:NO withCompletion:^(NSArray *dati) {
EQNRilevamento *anRilievo = [[EQNRilevamento alloc] init];
anRilievo.media = [[EQNMath meanOf:dati] floatValue];
anRilievo.deviazione = [[EQNMath standardDeviationOf:dati] floatValue];
NSDictionary *rDic = [EQNMath rLimiti:dati];
float max = [rDic[rMax] floatValue] - cal.media;
anRilievo.maxAssoluto = fabsf(max);
if (anRilievo.deviazione > SOGLIA_DEVIAZIONE_RILIEVO*cal.deviazione)
anRilievo.rilievo = positivo;
else
anRilievo.rilievo = negativo;
anRilievo.timestamp = [NSDate date];
rilevamento(anRilievo);
}];
}
@end
+39 -39
View File
@@ -1,61 +1,61 @@
PODS:
- DZNEmptyDataSet (1.8.1)
- Firebase/Core (7.1.0):
- Firebase/Core (7.2.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 7.1.0)
- Firebase/CoreOnly (7.1.0):
- FirebaseCore (= 7.1.0)
- Firebase/Crashlytics (7.1.0):
- FirebaseAnalytics (= 7.2.0)
- Firebase/CoreOnly (7.2.0):
- FirebaseCore (= 7.2.0)
- Firebase/Crashlytics (7.2.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 7.1.0)
- Firebase/Messaging (7.1.0):
- FirebaseCrashlytics (~> 7.2.0)
- Firebase/Messaging (7.2.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 7.1.0)
- FirebaseAnalytics (7.1.0):
- FirebaseMessaging (~> 7.2.0)
- FirebaseAnalytics (7.2.0):
- FirebaseCore (~> 7.0)
- FirebaseInstallations (~> 7.0)
- GoogleAppMeasurement (= 7.1.0)
- GoogleAppMeasurement (= 7.2.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.0)
- GoogleUtilities/MethodSwizzler (~> 7.0)
- GoogleUtilities/Network (~> 7.0)
- "GoogleUtilities/NSData+zlib (~> 7.0)"
- nanopb (~> 2.30906.0)
- FirebaseCore (7.1.0):
- FirebaseCore (7.2.0):
- FirebaseCoreDiagnostics (~> 7.0)
- GoogleUtilities/Environment (~> 7.0)
- GoogleUtilities/Logger (~> 7.0)
- FirebaseCoreDiagnostics (7.1.0):
- FirebaseCoreDiagnostics (7.2.0):
- GoogleDataTransport (~> 8.0)
- GoogleUtilities/Environment (~> 7.0)
- GoogleUtilities/Logger (~> 7.0)
- nanopb (~> 2.30906.0)
- FirebaseCrashlytics (7.1.0):
- FirebaseCrashlytics (7.2.0):
- FirebaseCore (~> 7.0)
- FirebaseInstallations (~> 7.0)
- GoogleDataTransport (~> 8.0)
- nanopb (~> 2.30906.0)
- PromisesObjC (~> 1.2)
- FirebaseInstallations (7.1.0):
- FirebaseInstallations (7.2.0):
- FirebaseCore (~> 7.0)
- GoogleUtilities/Environment (~> 7.0)
- GoogleUtilities/UserDefaults (~> 7.0)
- PromisesObjC (~> 1.2)
- FirebaseInstanceID (7.1.0):
- FirebaseInstanceID (7.2.0):
- FirebaseCore (~> 7.0)
- FirebaseInstallations (~> 7.0)
- GoogleUtilities/Environment (~> 7.0)
- GoogleUtilities/UserDefaults (~> 7.0)
- FirebaseMessaging (7.1.0):
- FirebaseMessaging (7.2.0):
- FirebaseCore (~> 7.0)
- FirebaseInstanceID (~> 7.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.0)
- GoogleUtilities/Environment (~> 7.0)
- GoogleUtilities/Reachability (~> 7.0)
- GoogleUtilities/UserDefaults (~> 7.0)
- Google-Mobile-Ads-SDK (7.68.0):
- Google-Mobile-Ads-SDK (7.69.0):
- GoogleAppMeasurement (~> 7.0)
- GoogleUserMessagingPlatform (~> 1.1)
- GoogleAppMeasurement (7.1.0):
- GoogleAppMeasurement (7.2.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.0)
- GoogleUtilities/MethodSwizzler (~> 7.0)
- GoogleUtilities/Network (~> 7.0)
@@ -63,25 +63,25 @@ PODS:
- nanopb (~> 2.30906.0)
- GoogleDataTransport (8.0.1):
- nanopb (~> 2.30906.0)
- GoogleUserMessagingPlatform (1.3.0)
- GoogleUtilities/AppDelegateSwizzler (7.1.0):
- GoogleUserMessagingPlatform (1.4.0)
- GoogleUtilities/AppDelegateSwizzler (7.1.1):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.1.0):
- GoogleUtilities/Environment (7.1.1):
- PromisesObjC (~> 1.2)
- GoogleUtilities/Logger (7.1.0):
- GoogleUtilities/Logger (7.1.1):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.1.0):
- GoogleUtilities/MethodSwizzler (7.1.1):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.1.0):
- GoogleUtilities/Network (7.1.1):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.1.0)"
- GoogleUtilities/Reachability (7.1.0):
- "GoogleUtilities/NSData+zlib (7.1.1)"
- GoogleUtilities/Reachability (7.1.1):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.1.0):
- GoogleUtilities/UserDefaults (7.1.1):
- GoogleUtilities/Logger
- nanopb (2.30906.0):
- nanopb/decode (= 2.30906.0)
@@ -121,19 +121,19 @@ SPEC REPOS:
SPEC CHECKSUMS:
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
Firebase: 78e8dd2e39d653de6270432ad84fe8b59f7bf4e8
FirebaseAnalytics: 7f165a56dea86ddd5b8ce02af3bee982c683405c
FirebaseCore: 20046127eef0fcb8fa25df7fc12f7b97d4e48611
FirebaseCoreDiagnostics: 872cdb9b749b23346dddd5c1014d1babd2257de3
FirebaseCrashlytics: c722e4ca283272eb90eb5bc245fdc6588e2f22c2
FirebaseInstallations: 3de38553e86171b5f81d83cdeef63473d37bfdb0
FirebaseInstanceID: 61e8d10a4192a582c6239378169d10e504ca8d91
FirebaseMessaging: 076054895c9260f82c7304cc7709dbf19b8f3e4a
Google-Mobile-Ads-SDK: 29bbdb182d69ff606cc0301da1590b40be8d2205
GoogleAppMeasurement: 89e1a64593f968713b0506ba1b53b38a154bf9a5
Firebase: 456eeacc158d8c58586b7871619a81bb9f27d4ae
FirebaseAnalytics: 2673264e482b428df13786b59165ebf420881d7a
FirebaseCore: c959e8a598f83125c01c1700d9161b236ab3833c
FirebaseCoreDiagnostics: 2d508e12e77e9691ca67d1669b91ee80f0985b29
FirebaseCrashlytics: 8afbf6e9c3731adee0e721870c9e7b40b0e8fd44
FirebaseInstallations: 9ab3a9a6522e687f59ff9bcfd92949ac85073f3c
FirebaseInstanceID: 68d2fa458c0c6adfde0007ffe35b51a37b163dec
FirebaseMessaging: 7091222bfac24ca89c569c3c59e58390311e487f
Google-Mobile-Ads-SDK: 2f288748a42920d1c744946a460896a95b0e9110
GoogleAppMeasurement: 57a0df93dc2feb5176b1bac06012dbd725191ba5
GoogleDataTransport: e4085e6762f36a6141738f46b0153473ce57fb18
GoogleUserMessagingPlatform: 1d4b6946710d18cec34742054092e2c2bddae61f
GoogleUtilities: f734da554aade8cc7928a31c2f3311897933a1bd
GoogleUserMessagingPlatform: b168e8c46cd8f92aa3e34b584c4ca78a411ce367
GoogleUtilities: 3dc4ff0d5e4840e2fa8eef0889620e8c33d4218c
nanopb: 1bf24dd71191072e120b83dd02d08f3da0d65e53
PromisesObjC: 8c196f5a328c2cba3e74624585467a557dcb482f
Solar: 2dc6e7cc39186cb0c8228fa08df76fb50c7d8f24