From 2f1203c18f5e50d2a4699f93aadb9218e3c7df1c Mon Sep 17 00:00:00 2001 From: liuyang1520 Date: Mon, 18 Jul 2022 15:53:49 -0700 Subject: [PATCH] fix: deprecation fix (#404) * fix: deprecation fix * remove AMPURLConnection.m file * refactor to save a bool var --- Amplitude.xcodeproj/project.pbxproj | 40 ----- Sources/Amplitude/AMPURLConnection.h | 34 ---- Sources/Amplitude/AMPURLConnection.m | 168 ------------------ Sources/Amplitude/AMPUtils.m | 8 +- Sources/Amplitude/Amplitude.m | 1 - Sources/Amplitude/ISPCertificatePinning.m | 24 ++- .../ISPPinnedNSURLConnectionDelegate.h | 27 --- .../ISPPinnedNSURLConnectionDelegate.m | 49 ----- .../Amplitude/ISPPinnedNSURLSessionDelegate.m | 20 ++- 9 files changed, 36 insertions(+), 335 deletions(-) delete mode 100644 Sources/Amplitude/AMPURLConnection.h delete mode 100644 Sources/Amplitude/AMPURLConnection.m delete mode 100644 Sources/Amplitude/ISPPinnedNSURLConnectionDelegate.h delete mode 100644 Sources/Amplitude/ISPPinnedNSURLConnectionDelegate.m diff --git a/Amplitude.xcodeproj/project.pbxproj b/Amplitude.xcodeproj/project.pbxproj index bcf5b529..c466625c 100644 --- a/Amplitude.xcodeproj/project.pbxproj +++ b/Amplitude.xcodeproj/project.pbxproj @@ -25,10 +25,8 @@ 1279F8FD25244E8D003DCE07 /* AMPIdentify.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D625244D78003DCE07 /* AMPIdentify.m */; }; 1279F8FE25244E8D003DCE07 /* AMPRevenue.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8C725244D78003DCE07 /* AMPRevenue.m */; }; 1279F8FF25244E8D003DCE07 /* AMPTrackingOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D025244D78003DCE07 /* AMPTrackingOptions.m */; }; - 1279F90025244E8D003DCE07 /* AMPURLConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C025244D78003DCE07 /* AMPURLConnection.h */; }; 1279F90125244E8D003DCE07 /* AMPURLSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D125244D78003DCE07 /* AMPURLSession.m */; }; 1279F90225244E8D003DCE07 /* AMPDatabaseHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C325244D78003DCE07 /* AMPDatabaseHelper.h */; }; - 1279F90325244E8D003DCE07 /* AMPURLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D725244D78003DCE07 /* AMPURLConnection.m */; }; 1279F90425244E8D003DCE07 /* Amplitude.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8EA25244D78003DCE07 /* Amplitude.m */; }; 1279F90525244E8D003DCE07 /* AMPRevenue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8DA25244D78003DCE07 /* AMPRevenue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1279F90625244E8D003DCE07 /* AMPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8E625244D78003DCE07 /* AMPConstants.m */; }; @@ -49,10 +47,8 @@ 1279F91B25244E8E003DCE07 /* AMPIdentify.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D625244D78003DCE07 /* AMPIdentify.m */; }; 1279F91C25244E8E003DCE07 /* AMPRevenue.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8C725244D78003DCE07 /* AMPRevenue.m */; }; 1279F91D25244E8E003DCE07 /* AMPTrackingOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D025244D78003DCE07 /* AMPTrackingOptions.m */; }; - 1279F91E25244E8E003DCE07 /* AMPURLConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C025244D78003DCE07 /* AMPURLConnection.h */; }; 1279F91F25244E8E003DCE07 /* AMPURLSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D125244D78003DCE07 /* AMPURLSession.m */; }; 1279F92025244E8E003DCE07 /* AMPDatabaseHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C325244D78003DCE07 /* AMPDatabaseHelper.h */; }; - 1279F92125244E8E003DCE07 /* AMPURLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D725244D78003DCE07 /* AMPURLConnection.m */; }; 1279F92225244E8E003DCE07 /* Amplitude.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8EA25244D78003DCE07 /* Amplitude.m */; }; 1279F92325244E8E003DCE07 /* AMPRevenue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8DA25244D78003DCE07 /* AMPRevenue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1279F92425244E8E003DCE07 /* AMPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8E625244D78003DCE07 /* AMPConstants.m */; }; @@ -73,10 +69,8 @@ 1279F93925244E8F003DCE07 /* AMPIdentify.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D625244D78003DCE07 /* AMPIdentify.m */; }; 1279F93A25244E8F003DCE07 /* AMPRevenue.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8C725244D78003DCE07 /* AMPRevenue.m */; }; 1279F93B25244E8F003DCE07 /* AMPTrackingOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D025244D78003DCE07 /* AMPTrackingOptions.m */; }; - 1279F93C25244E8F003DCE07 /* AMPURLConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C025244D78003DCE07 /* AMPURLConnection.h */; }; 1279F93D25244E8F003DCE07 /* AMPURLSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D125244D78003DCE07 /* AMPURLSession.m */; }; 1279F93E25244E8F003DCE07 /* AMPDatabaseHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C325244D78003DCE07 /* AMPDatabaseHelper.h */; }; - 1279F93F25244E8F003DCE07 /* AMPURLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D725244D78003DCE07 /* AMPURLConnection.m */; }; 1279F94025244E8F003DCE07 /* Amplitude.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8EA25244D78003DCE07 /* Amplitude.m */; }; 1279F94125244E8F003DCE07 /* AMPRevenue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8DA25244D78003DCE07 /* AMPRevenue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1279F94225244E8F003DCE07 /* AMPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8E625244D78003DCE07 /* AMPConstants.m */; }; @@ -85,12 +79,6 @@ 1279FA6E2525949D003DCE07 /* ISPCertificatePinning.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA682525949D003DCE07 /* ISPCertificatePinning.m */; }; 1279FA6F2525949D003DCE07 /* ISPCertificatePinning.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA682525949D003DCE07 /* ISPCertificatePinning.m */; }; 1279FA702525949D003DCE07 /* ISPCertificatePinning.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA682525949D003DCE07 /* ISPCertificatePinning.m */; }; - 1279FA712525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA692525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m */; }; - 1279FA722525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA692525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m */; }; - 1279FA732525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA692525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m */; }; - 1279FA742525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279FA6A2525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h */; }; - 1279FA752525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279FA6A2525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h */; }; - 1279FA762525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279FA6A2525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h */; }; 1279FA772525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA6B2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m */; }; 1279FA782525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA6B2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m */; }; 1279FA792525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA6B2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m */; }; @@ -203,11 +191,9 @@ 759E939525FBF3DC00BF7C3D /* Amplitude.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8EA25244D78003DCE07 /* Amplitude.m */; }; 759E939625FBF3DC00BF7C3D /* AMPRevenue.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8C725244D78003DCE07 /* AMPRevenue.m */; }; 759E939725FBF3DC00BF7C3D /* AMPTrackingOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D025244D78003DCE07 /* AMPTrackingOptions.m */; }; - 759E939825FBF3DC00BF7C3D /* AMPURLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D725244D78003DCE07 /* AMPURLConnection.m */; }; 759E939925FBF3DC00BF7C3D /* AMPURLSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8D125244D78003DCE07 /* AMPURLSession.m */; }; 759E939A25FBF3DC00BF7C3D /* AMPUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279F8C425244D78003DCE07 /* AMPUtils.m */; }; 759E939B25FBF3DC00BF7C3D /* ISPCertificatePinning.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA682525949D003DCE07 /* ISPCertificatePinning.m */; }; - 759E939C25FBF3DC00BF7C3D /* ISPPinnedNSURLConnectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA692525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m */; }; 759E939D25FBF3DC00BF7C3D /* ISPPinnedNSURLSessionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1279FA6B2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m */; }; 759E93A525FBF44500BF7C3D /* AMPConfigManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8E525244D78003DCE07 /* AMPConfigManager.h */; }; 759E93A625FBF44500BF7C3D /* AMPConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C625244D78003DCE07 /* AMPConstants.h */; }; @@ -219,11 +205,9 @@ 759E93AC25FBF44500BF7C3D /* AmplitudePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8D825244D78003DCE07 /* AmplitudePrivate.h */; }; 759E93AD25FBF44500BF7C3D /* AMPRevenue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8DA25244D78003DCE07 /* AMPRevenue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 759E93AE25FBF44500BF7C3D /* AMPTrackingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8E925244D78003DCE07 /* AMPTrackingOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 759E93AF25FBF44500BF7C3D /* AMPURLConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8C025244D78003DCE07 /* AMPURLConnection.h */; }; 759E93B025FBF44500BF7C3D /* AMPURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8E825244D78003DCE07 /* AMPURLSession.h */; }; 759E93B125FBF44500BF7C3D /* AMPUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279F8E725244D78003DCE07 /* AMPUtils.h */; }; 759E93B225FBF44500BF7C3D /* ISPCertificatePinning.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279FA6D2525949D003DCE07 /* ISPCertificatePinning.h */; }; - 759E93B325FBF44500BF7C3D /* ISPPinnedNSURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279FA6A2525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h */; }; 759E93B425FBF44500BF7C3D /* ISPPinnedNSURLSessionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1279FA6C2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.h */; }; 759E93BC25FBF4B600BF7C3D /* AmplitudeFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 1213D89824176E4700300E98 /* AmplitudeFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 759E93DC25FBF6F700BF7C3D /* AMPBackgroundNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 759E93DA25FBF6F700BF7C3D /* AMPBackgroundNotifier.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -276,7 +260,6 @@ 124CDD7923EFD2C5004C7B27 /* Podfile.lock */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile.lock; sourceTree = ""; }; 124CDD7A23EFD2C5004C7B27 /* Podfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 124CDD7B23EFD2D4004C7B27 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; - 1279F8C025244D78003DCE07 /* AMPURLConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMPURLConnection.h; sourceTree = ""; }; 1279F8C125244D78003DCE07 /* AMPIdentify.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMPIdentify.h; sourceTree = ""; }; 1279F8C225244D78003DCE07 /* AMPDeviceInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMPDeviceInfo.h; sourceTree = ""; }; 1279F8C325244D78003DCE07 /* AMPDatabaseHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMPDatabaseHelper.h; sourceTree = ""; }; @@ -290,7 +273,6 @@ 1279F8D425244D78003DCE07 /* AMPDatabaseHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMPDatabaseHelper.m; sourceTree = ""; }; 1279F8D525244D78003DCE07 /* AMPDeviceInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMPDeviceInfo.m; sourceTree = ""; }; 1279F8D625244D78003DCE07 /* AMPIdentify.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMPIdentify.m; sourceTree = ""; }; - 1279F8D725244D78003DCE07 /* AMPURLConnection.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMPURLConnection.m; sourceTree = ""; }; 1279F8D825244D78003DCE07 /* AmplitudePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AmplitudePrivate.h; sourceTree = ""; }; 1279F8D925244D78003DCE07 /* Amplitude+SSLPinning.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Amplitude+SSLPinning.h"; sourceTree = ""; }; 1279F8DA25244D78003DCE07 /* AMPRevenue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMPRevenue.h; sourceTree = ""; }; @@ -301,8 +283,6 @@ 1279F8E925244D78003DCE07 /* AMPTrackingOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMPTrackingOptions.h; sourceTree = ""; }; 1279F8EA25244D78003DCE07 /* Amplitude.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Amplitude.m; sourceTree = ""; }; 1279FA682525949D003DCE07 /* ISPCertificatePinning.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ISPCertificatePinning.m; sourceTree = ""; }; - 1279FA692525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ISPPinnedNSURLConnectionDelegate.m; sourceTree = ""; }; - 1279FA6A2525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISPPinnedNSURLConnectionDelegate.h; sourceTree = ""; }; 1279FA6B2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ISPPinnedNSURLSessionDelegate.m; sourceTree = ""; }; 1279FA6C2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISPPinnedNSURLSessionDelegate.h; sourceTree = ""; }; 1279FA6D2525949D003DCE07 /* ISPCertificatePinning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISPCertificatePinning.h; sourceTree = ""; }; @@ -494,16 +474,12 @@ 1279F8D825244D78003DCE07 /* AmplitudePrivate.h */, 1279F8C725244D78003DCE07 /* AMPRevenue.m */, 1279F8D025244D78003DCE07 /* AMPTrackingOptions.m */, - 1279F8C025244D78003DCE07 /* AMPURLConnection.h */, - 1279F8D725244D78003DCE07 /* AMPURLConnection.m */, 1279F8E825244D78003DCE07 /* AMPURLSession.h */, 1279F8D125244D78003DCE07 /* AMPURLSession.m */, 1279F8E725244D78003DCE07 /* AMPUtils.h */, 1279F8C425244D78003DCE07 /* AMPUtils.m */, 1279FA6D2525949D003DCE07 /* ISPCertificatePinning.h */, 1279FA682525949D003DCE07 /* ISPCertificatePinning.m */, - 1279FA6A2525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h */, - 1279FA692525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m */, 1279FA6C2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.h */, 1279FA6B2525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m */, 3EF608D22720F52400133703 /* AMPServerZoneUtil.h */, @@ -641,7 +617,6 @@ 1279F91525244E8E003DCE07 /* AMPConstants.h in Headers */, 3EF608EB2726244300133703 /* AMPMiddlewareRunner.h in Headers */, 1279F91925244E8E003DCE07 /* AMPTrackingOptions.h in Headers */, - 1279FA752525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h in Headers */, 1279F91425244E8E003DCE07 /* AmplitudePrivate.h in Headers */, 3EF608D42720F52400133703 /* AMPServerZoneUtil.h in Headers */, 1279F92325244E8E003DCE07 /* AMPRevenue.h in Headers */, @@ -649,7 +624,6 @@ 1279F91025244E8E003DCE07 /* AMPDeviceInfo.h in Headers */, 1279F91125244E8E003DCE07 /* AMPIdentify.h in Headers */, 1279F92025244E8E003DCE07 /* AMPDatabaseHelper.h in Headers */, - 1279F91E25244E8E003DCE07 /* AMPURLConnection.h in Headers */, 1279F91725244E8E003DCE07 /* AMPConfigManager.h in Headers */, 1279F91625244E8E003DCE07 /* AMPUtils.h in Headers */, ); @@ -671,7 +645,6 @@ 1279F8F725244E8D003DCE07 /* AMPConstants.h in Headers */, 3EF608EA2726244300133703 /* AMPMiddlewareRunner.h in Headers */, 1279F8FB25244E8D003DCE07 /* AMPTrackingOptions.h in Headers */, - 1279FA742525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h in Headers */, 1279F8F625244E8D003DCE07 /* AmplitudePrivate.h in Headers */, 3EF608D32720F52400133703 /* AMPServerZoneUtil.h in Headers */, 1279F90525244E8D003DCE07 /* AMPRevenue.h in Headers */, @@ -679,7 +652,6 @@ 1279F8F225244E8D003DCE07 /* AMPDeviceInfo.h in Headers */, 1279F8F325244E8D003DCE07 /* AMPIdentify.h in Headers */, 1279F90225244E8D003DCE07 /* AMPDatabaseHelper.h in Headers */, - 1279F90025244E8D003DCE07 /* AMPURLConnection.h in Headers */, 1279F8F925244E8D003DCE07 /* AMPConfigManager.h in Headers */, 1279F8F825244E8D003DCE07 /* AMPUtils.h in Headers */, ); @@ -700,7 +672,6 @@ 1279F93325244E8F003DCE07 /* AMPConstants.h in Headers */, 1279F93725244E8F003DCE07 /* AMPTrackingOptions.h in Headers */, 3EF608EC2726244300133703 /* AMPMiddlewareRunner.h in Headers */, - 1279FA762525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.h in Headers */, 1279F93225244E8F003DCE07 /* AmplitudePrivate.h in Headers */, 759E943125FBFEA200BF7C3D /* AMPBackgroundNotifier.h in Headers */, 3EF608D52720F52400133703 /* AMPServerZoneUtil.h in Headers */, @@ -709,7 +680,6 @@ 1279F92E25244E8F003DCE07 /* AMPDeviceInfo.h in Headers */, 1279F92F25244E8F003DCE07 /* AMPIdentify.h in Headers */, 1279F93E25244E8F003DCE07 /* AMPDatabaseHelper.h in Headers */, - 1279F93C25244E8F003DCE07 /* AMPURLConnection.h in Headers */, 1279F93525244E8F003DCE07 /* AMPConfigManager.h in Headers */, 1279F93425244E8F003DCE07 /* AMPUtils.h in Headers */, ); @@ -734,12 +704,10 @@ 759E93A625FBF44500BF7C3D /* AMPConstants.h in Headers */, 759E93DC25FBF6F700BF7C3D /* AMPBackgroundNotifier.h in Headers */, 3EF608D62720F52400133703 /* AMPServerZoneUtil.h in Headers */, - 759E93B325FBF44500BF7C3D /* ISPPinnedNSURLConnectionDelegate.h in Headers */, 759E93AC25FBF44500BF7C3D /* AmplitudePrivate.h in Headers */, 759E93B025FBF44500BF7C3D /* AMPURLSession.h in Headers */, 759E93A825FBF44500BF7C3D /* AMPDeviceInfo.h in Headers */, 759E93A725FBF44500BF7C3D /* AMPDatabaseHelper.h in Headers */, - 759E93AF25FBF44500BF7C3D /* AMPURLConnection.h in Headers */, 759E93A525FBF44500BF7C3D /* AMPConfigManager.h in Headers */, 759E93B125FBF44500BF7C3D /* AMPUtils.h in Headers */, ); @@ -1088,8 +1056,6 @@ 1279FA6F2525949D003DCE07 /* ISPCertificatePinning.m in Sources */, 3EF608F02726256800133703 /* AMPMiddlewareRunner.m in Sources */, 1279F91A25244E8E003DCE07 /* AMPUtils.m in Sources */, - 1279F92125244E8E003DCE07 /* AMPURLConnection.m in Sources */, - 1279FA722525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m in Sources */, 3EF6090327267C9800133703 /* AMPMiddleware.m in Sources */, 1279F92625244E8E003DCE07 /* AMPDatabaseHelper.m in Sources */, 1279F92425244E8E003DCE07 /* AMPConstants.m in Sources */, @@ -1144,10 +1110,8 @@ 1279F90125244E8D003DCE07 /* AMPURLSession.m in Sources */, 1279F8FF25244E8D003DCE07 /* AMPTrackingOptions.m in Sources */, 1279F90625244E8D003DCE07 /* AMPConstants.m in Sources */, - 1279FA712525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m in Sources */, 1279FA772525949D003DCE07 /* ISPPinnedNSURLSessionDelegate.m in Sources */, 1279FA6E2525949D003DCE07 /* ISPCertificatePinning.m in Sources */, - 1279F90325244E8D003DCE07 /* AMPURLConnection.m in Sources */, 3EF6090227267C9800133703 /* AMPMiddleware.m in Sources */, 1279F90725244E8D003DCE07 /* AMPDeviceInfo.m in Sources */, 1279F90425244E8D003DCE07 /* Amplitude.m in Sources */, @@ -1186,8 +1150,6 @@ 1279FA702525949D003DCE07 /* ISPCertificatePinning.m in Sources */, 3EF608F12726256800133703 /* AMPMiddlewareRunner.m in Sources */, 1279F93825244E8F003DCE07 /* AMPUtils.m in Sources */, - 1279F93F25244E8F003DCE07 /* AMPURLConnection.m in Sources */, - 1279FA732525949D003DCE07 /* ISPPinnedNSURLConnectionDelegate.m in Sources */, 3EF6090427267C9800133703 /* AMPMiddleware.m in Sources */, 1279F94425244E8F003DCE07 /* AMPDatabaseHelper.m in Sources */, 1279F94225244E8F003DCE07 /* AMPConstants.m in Sources */, @@ -1241,13 +1203,11 @@ 759E939525FBF3DC00BF7C3D /* Amplitude.m in Sources */, 759E939625FBF3DC00BF7C3D /* AMPRevenue.m in Sources */, 759E939725FBF3DC00BF7C3D /* AMPTrackingOptions.m in Sources */, - 759E939825FBF3DC00BF7C3D /* AMPURLConnection.m in Sources */, 759E939925FBF3DC00BF7C3D /* AMPURLSession.m in Sources */, 759E939A25FBF3DC00BF7C3D /* AMPUtils.m in Sources */, 759E939B25FBF3DC00BF7C3D /* ISPCertificatePinning.m in Sources */, 3E2411EF26F9A46500793829 /* AMPPlan.m in Sources */, 3EF608DB2720F64500133703 /* AMPServerZoneUtil.m in Sources */, - 759E939C25FBF3DC00BF7C3D /* ISPPinnedNSURLConnectionDelegate.m in Sources */, 759E939D25FBF3DC00BF7C3D /* ISPPinnedNSURLSessionDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Sources/Amplitude/AMPURLConnection.h b/Sources/Amplitude/AMPURLConnection.h deleted file mode 100644 index b7b6fb0b..00000000 --- a/Sources/Amplitude/AMPURLConnection.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// AMPURLConnection.h -// Copyright (c) 2013 Amplitude Inc. (https://amplitude.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#if AMPLITUDE_SSL_PINNING - -#import -#import "ISPPinnedNSURLConnectionDelegate.h" - -@interface AMPURLConnection : ISPPinnedNSURLConnectionDelegate - -+ (void)sendAsynchronousRequest:(NSURLRequest *)request queue:(NSOperationQueue *)queue completionHandler:(void (^)(NSURLResponse *response, NSData *data, NSError *connectionError))handler; - -@end -#endif diff --git a/Sources/Amplitude/AMPURLConnection.m b/Sources/Amplitude/AMPURLConnection.m deleted file mode 100644 index a32b77c1..00000000 --- a/Sources/Amplitude/AMPURLConnection.m +++ /dev/null @@ -1,168 +0,0 @@ -// -// AMPURLConnection.m -// Copyright (c) 2013 Amplitude Inc. (https://amplitude.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#if AMPLITUDE_SSL_PINNING - -#ifndef AMPLITUDE_DEBUG -#define AMPLITUDE_DEBUG 0 -#endif - -#ifndef AMPLITUDE_LOG -#if AMPLITUDE_DEBUG -# define AMPLITUDE_LOG(fmt, ...) NSLog(fmt, ##__VA_ARGS__) -#else -# define AMPLITUDE_LOG(...) -#endif -#endif - -#import "AMPURLConnection.h" -#import "AMPConstants.h" -#import "ISPCertificatePinning.h" -#import "ISPPinnedNSURLConnectionDelegate.h" - -@interface AMPURLConnection () - -@property (nonatomic, copy) void (^completionHandler)(NSURLResponse *, NSData *, NSError *); -@property (nonatomic, retain) NSURLConnection *connection; -@property (nonatomic, retain) NSMutableData *data; -@property (nonatomic, retain) NSURLResponse *response; -@property (nonatomic, retain) AMPURLConnection *delegate; - -@end - -@implementation AMPURLConnection - -+ (void)initialize { - if (self == [AMPURLConnection class]) { - // ComodoRsaDomainValidationCA is for US endpoint, AmazonRootCA1 is for EU endpoint - NSDictionary *domainCertFilenamesMap = @{ - kAMPEventLogDomain: @[ - @"ComodoRsaDomainValidationCA.der", - @"Amplitude_Amplitude.bundle/ComodoRsaDomainValidationCA.der" - ], - kAMPEventLogEuDomain: @[ - @"AmazonRootCA1.cer", - @"Amplitude_Amplitude.bundle/AmazonRootCA1.cer" - ] - }; - [AMPURLConnection pinSSLCertificate:domainCertFilenamesMap]; - } -} - -+ (void)pinSSLCertificate:(NSDictionary *)domainCertFilenamesMap { - // We pin the anchor/CA certificates - NSMutableDictionary *pins = [[NSMutableDictionary alloc] init]; - for (id domain in domainCertFilenamesMap) { - NSMutableArray *certs = [NSMutableArray array]; - NSArray *certFilenames = [domainCertFilenamesMap objectForKey:domain]; - for (NSString *certFilename in certFilenames) { - NSString *certPath = [[NSBundle bundleForClass:[self class]] pathForResource:certFilename ofType:nil]; - NSData *certData = [[NSData alloc] initWithContentsOfFile:certPath]; - if (certData == nil) { - AMPLITUDE_LOG([NSString stringWithFormat:@"Failed to load certificate: %@", certFilename]); - continue; - } - [certs addObject:certData]; - } - [pins setObject:certs forKey:domain]; - } - - if (pins == nil) { - AMPLITUDE_LOG(@"Failed to pin a certificate"); - return; - } - - // Save the SSL pins so that our connection delegates automatically use them - if ([ISPCertificatePinning setupSSLPinsUsingDictionnary:pins] != YES) { - AMPLITUDE_LOG(@"Failed to pin the certificates"); - return; - } -} - -/** - * Instantiate a connection to run the request and handle the response. - * - * Emulates the +sendAsynchronous:queue:completionHandler method in NSURLConnection. - * In order to have optional SSL pinning, a ISPPinnedNSURLConnectionDelegate was needed, so - * the async method with callback wasn't sufficient. - */ -+ (void)sendAsynchronousRequest:(NSURLRequest *)request - queue:(NSOperationQueue *)queue - completionHandler:(void (^)(NSURLResponse *response, NSData *data, NSError *connectionError))handler { - // Ignore the return value. See note below about self retaining. - (void)[[AMPURLConnection alloc] initWithRequest:request - queue:queue - completionHandler:handler]; -} - -- (AMPURLConnection *)initWithRequest:(NSURLRequest *)request - queue:(NSOperationQueue *)queue - completionHandler:(void (^)(NSURLResponse *response, NSData *data, NSError *connectionError))handler { - - if (self = [super init]) { - self.completionHandler = handler; - self.data = nil; - self.response = nil; - - // Have to retain self so it's not deallocated after the connection - // finishes, but before the completion handler runs and self gets - // cleaned up. When instantiated by sendAsynchronousRequest, the instance - // is really it's own owner. The NSUrlConnection holds a strong reference - // to the instance as a delegate, but releases after the connection completes. - self.delegate = self; - - _connection = [[NSURLConnection alloc] initWithRequest:request - delegate:self - startImmediately:NO]; - - [self.connection setDelegateQueue:queue]; - [self.connection start]; - } - - return self; -} - -- (void)complete:(NSError *)error { - self.completionHandler(self.response, self.data, error); - self.delegate = nil; -} - -- (void)connectionDidFinishLoading:(NSURLConnection *)connection { - [self complete:nil]; -} - -- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { - [self complete:error]; -} - -- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { - [self.data appendData:data]; -} - -- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { - self.response = response; - _data = [[NSMutableData alloc] init]; -} - -@end -#endif diff --git a/Sources/Amplitude/AMPUtils.m b/Sources/Amplitude/AMPUtils.m index 35a3ffe2..cc1a3c7e 100644 --- a/Sources/Amplitude/AMPUtils.m +++ b/Sources/Amplitude/AMPUtils.m @@ -187,9 +187,11 @@ + (CGFloat)statusBarHeight { + (UIWindow *)getKeyWindow { if (@available(iOS 13.0, *)) { - for (UIWindow *window in [[AMPUtils getSharedApplication] windows]) { - if ([window isKeyWindow]) { - return window; + for (UIWindowScene *windowScene in [[AMPUtils getSharedApplication] connectedScenes]) { + for (UIWindow *window in [windowScene windows]) { + if ([window isKeyWindow]) { + return window; + } } } return nil; diff --git a/Sources/Amplitude/Amplitude.m b/Sources/Amplitude/Amplitude.m index 81baf9de..ba5a44fb 100644 --- a/Sources/Amplitude/Amplitude.m +++ b/Sources/Amplitude/Amplitude.m @@ -52,7 +52,6 @@ #import "AMPConstants.h" #import "AMPConfigManager.h" #import "AMPDeviceInfo.h" -#import "AMPURLConnection.h" #import "AMPURLSession.h" #import "AMPDatabaseHelper.h" #import "AMPUtils.h" diff --git a/Sources/Amplitude/ISPCertificatePinning.m b/Sources/Amplitude/ISPCertificatePinning.m index bb3ec8cf..d03a9445 100644 --- a/Sources/Amplitude/ISPCertificatePinning.m +++ b/Sources/Amplitude/ISPCertificatePinning.m @@ -99,9 +99,15 @@ + (BOOL)verifyPinnedCertificateForTrust:(SecTrustRef)trust andDomain:(NSString * // Unfortunately the anchor/CA certificate cannot be accessed this way CFIndex certsNb = SecTrustGetCertificateCount(trust); for(int i=0;i - -/** Convenience class to automatically perform certificate pinning for NSURLConnection. - - ISPPinnedNSURLConnectionDelegate is designed to be subclassed in order to - implement an NSURLConnectionDelegate class. The - connection:willSendRequestForAuthenticationChallenge: method it implements - will automatically validate that at least one the certificates pinned to the domain the - connection is accessing is part of the server's certificate chain. - - */ -@interface ISPPinnedNSURLConnectionDelegate : NSObject - -- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge; - -@end -#endif diff --git a/Sources/Amplitude/ISPPinnedNSURLConnectionDelegate.m b/Sources/Amplitude/ISPPinnedNSURLConnectionDelegate.m deleted file mode 100644 index 9bf11d4e..00000000 --- a/Sources/Amplitude/ISPPinnedNSURLConnectionDelegate.m +++ /dev/null @@ -1,49 +0,0 @@ -// -// ISPPinnedNSURLConnectionDelegate.m -// SSLCertificatePinning -// -// Created by Alban Diquet on 1/14/14. -// Copyright (c) 2014 iSEC Partners. All rights reserved. -// - -#if AMPLITUDE_SSL_PINNING - -#import "ISPPinnedNSURLConnectionDelegate.h" -#import "ISPCertificatePinning.h" - -@implementation ISPPinnedNSURLConnectionDelegate - -- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - - if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - - SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust]; - NSString *domain = [[challenge protectionSpace] host]; - SecTrustResultType trustResult; - - // Validate the certificate chain with the device's trust store anyway - // This *might* give use revocation checking - SecTrustEvaluate(serverTrust, &trustResult); - if (trustResult == kSecTrustResultUnspecified) { - - // Look for a pinned certificate in the server's certificate chain - if ([ISPCertificatePinning verifyPinnedCertificateForTrust:serverTrust andDomain:domain]) { - - // Found the certificate; continue connecting - [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] - forAuthenticationChallenge:challenge]; - } - else { - // The certificate wasn't found in the certificate chain; cancel the connection - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } - } - else { - // Certificate chain validation failed; cancel the connection - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } - } -} - -@end -#endif diff --git a/Sources/Amplitude/ISPPinnedNSURLSessionDelegate.m b/Sources/Amplitude/ISPPinnedNSURLSessionDelegate.m index 457c91a3..dfeafcdc 100644 --- a/Sources/Amplitude/ISPPinnedNSURLSessionDelegate.m +++ b/Sources/Amplitude/ISPPinnedNSURLSessionDelegate.m @@ -20,25 +20,29 @@ - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticat SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust]; NSString *domain = [[challenge protectionSpace] host]; - SecTrustResultType trustResult; // Validate the certificate chain with the device's trust store anyway // This *might* give use revocation checking - SecTrustEvaluate(serverTrust, &trustResult); - if (trustResult == kSecTrustResultUnspecified) { - + BOOL isTrusted = false; + if (@available(iOS 12.0, macos 10.14, *)) { + CFErrorRef error; + isTrusted = SecTrustEvaluateWithError(serverTrust, &error); + } else { + SecTrustResultType trustResult; + SecTrustEvaluate(serverTrust, &trustResult); + isTrusted = trustResult == kSecTrustResultUnspecified; + } + if (isTrusted) { // Look for a pinned certificate in the server's certificate chain if ([ISPCertificatePinning verifyPinnedCertificateForTrust:serverTrust andDomain:domain]) { // Found the certificate; continue connecting completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - } - else { + } else { // The certificate wasn't found in the certificate chain; cancel the connection completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); } - } - else { + } else { // Certificate chain validation failed; cancel the connection completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); }