From 77cd2d89c49285f02efabb42c46a4f81e61d5e6f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 16 Sep 2020 17:39:47 +0300 Subject: NotificationService rewritten in Swift, added dummy test target --- Juick.xcodeproj/project.pbxproj | 207 ++++++++++++++++++++++++++++++++-- JuickPush/Info.plist | 2 +- JuickPush/JuickPush-Bridging-Header.h | 4 + JuickPush/NotificationService.h | 13 --- JuickPush/NotificationService.m | 46 -------- JuickPush/NotificationService.swift | 48 ++++++++ JuickTests/Info.plist | 22 ++++ JuickTests/JuickTests.swift | 43 +++++++ 8 files changed, 313 insertions(+), 72 deletions(-) create mode 100644 JuickPush/JuickPush-Bridging-Header.h delete mode 100644 JuickPush/NotificationService.h delete mode 100644 JuickPush/NotificationService.m create mode 100644 JuickPush/NotificationService.swift create mode 100644 JuickTests/Info.plist create mode 100644 JuickTests/JuickTests.swift diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 657e2e6..1599a41 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 770C86E325117D78009B6404 /* UIView+Shimmer.m in Sources */ = {isa = PBXBuildFile; fileRef = 770C86E125117D78009B6404 /* UIView+Shimmer.m */; }; + 770C86F0251211B6009B6404 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 770C86EF251211B6009B6404 /* NotificationService.swift */; }; 772B4E6C2199811E0029706E /* Entity.m in Sources */ = {isa = PBXBuildFile; fileRef = 772B4E6B2199811E0029706E /* Entity.m */; }; 77317BAC181BBE8500D60005 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAB181BBE8500D60005 /* Foundation.framework */; }; 77317BAE181BBE8500D60005 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAD181BBE8500D60005 /* CoreGraphics.framework */; }; @@ -36,7 +37,6 @@ 774746B6239F872A0001C7F9 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 774746B5239F872A0001C7F9 /* CoreServices.framework */; }; 7761133821766A3000D350CD /* ContentLoadingCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7761133621766A3000D350CD /* ContentLoadingCell.m */; }; 7761133921766A3000D350CD /* ContentLoadingCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7761133721766A3000D350CD /* ContentLoadingCell.xib */; }; - 7761135921790B0300D350CD /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = 7761135821790B0300D350CD /* NotificationService.m */; }; 7761135D21790B0300D350CD /* JuickPush.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 7761135521790B0200D350CD /* JuickPush.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 776C41BD1FD3EF180063B82E /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41BB1FD3EF180063B82E /* MessageCell.m */; }; 776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 776C41BC1FD3EF180063B82E /* MessageCell.xib */; }; @@ -62,6 +62,7 @@ 77E35A82189A5B5A00B2D216 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E35A81189A5B5A00B2D216 /* LoginViewController.m */; }; 77E61A5B1FD467FC00B4E304 /* QuoteView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77E61A5A1FD467FC00B4E304 /* QuoteView.xib */; }; 77E61A5E1FD4682B00B4E304 /* QuoteView.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E61A5D1FD4682B00B4E304 /* QuoteView.m */; }; + 77F2B6A2251249F300E42F6F /* JuickTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F2B6A1251249F300E42F6F /* JuickTests.swift */; }; 77FCADDF1D6A50DA00CBA649 /* API.m in Sources */ = {isa = PBXBuildFile; fileRef = 77FCADDE1D6A50DA00CBA649 /* API.m */; }; /* End PBXBuildFile section */ @@ -73,6 +74,13 @@ remoteGlobalIDString = 7761135421790B0200D350CD; remoteInfo = JuickPush; }; + 77F2B6A4251249F300E42F6F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 77317BA0181BBE8500D60005 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 77317BA7181BBE8500D60005; + remoteInfo = Juick; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -93,6 +101,8 @@ 770A428F1E8881CB000B206A /* DeviceRegistration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceRegistration.h; sourceTree = ""; }; 770C86E125117D78009B6404 /* UIView+Shimmer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+Shimmer.m"; path = "Vendor/UIView-Shimmer/Classes/UIView+Shimmer.m"; sourceTree = ""; }; 770C86E225117D78009B6404 /* UIView+Shimmer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+Shimmer.h"; path = "Vendor/UIView-Shimmer/Classes/UIView+Shimmer.h"; sourceTree = ""; }; + 770C86EE251211B6009B6404 /* JuickPush-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JuickPush-Bridging-Header.h"; sourceTree = ""; }; + 770C86EF251211B6009B6404 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = ""; }; 772B4E6A2199811E0029706E /* Entity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = ""; }; 772B4E6B2199811E0029706E /* Entity.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Entity.m; sourceTree = ""; }; 77317BA8181BBE8500D60005 /* Juick.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Juick.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -140,8 +150,6 @@ 7761133621766A3000D350CD /* ContentLoadingCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContentLoadingCell.m; sourceTree = ""; }; 7761133721766A3000D350CD /* ContentLoadingCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ContentLoadingCell.xib; sourceTree = ""; }; 7761135521790B0200D350CD /* JuickPush.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = JuickPush.appex; sourceTree = BUILT_PRODUCTS_DIR; }; - 7761135721790B0300D350CD /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = ""; }; - 7761135821790B0300D350CD /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = ""; }; 7761135A21790B0300D350CD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 7761136821790C2D00D350CD /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; }; 776C41BA1FD3EF180063B82E /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = ""; }; @@ -187,6 +195,9 @@ 77E61A5A1FD467FC00B4E304 /* QuoteView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QuoteView.xib; sourceTree = ""; }; 77E61A5C1FD4682B00B4E304 /* QuoteView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QuoteView.h; sourceTree = ""; }; 77E61A5D1FD4682B00B4E304 /* QuoteView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QuoteView.m; sourceTree = ""; }; + 77F2B69F251249F300E42F6F /* JuickTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JuickTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 77F2B6A1251249F300E42F6F /* JuickTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JuickTests.swift; sourceTree = ""; }; + 77F2B6A3251249F300E42F6F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 77FCADDE1D6A50DA00CBA649 /* API.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = API.m; sourceTree = ""; }; 77FCADE01D6A50EC00CBA649 /* API.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = API.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -214,6 +225,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 77F2B69C251249F300E42F6F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -222,6 +240,7 @@ children = ( 774746B1239F85920001C7F9 /* Vendor */, 7761135621790B0300D350CD /* JuickPush */, + 77F2B6A0251249F300E42F6F /* JuickTests */, 77317BAA181BBE8500D60005 /* Frameworks */, 77317BB1181BBE8500D60005 /* Juick */, 77317BA9181BBE8500D60005 /* Products */, @@ -233,6 +252,7 @@ children = ( 77317BA8181BBE8500D60005 /* Juick.app */, 7761135521790B0200D350CD /* JuickPush.appex */, + 77F2B69F251249F300E42F6F /* JuickTests.xctest */, ); name = Products; sourceTree = ""; @@ -370,13 +390,22 @@ isa = PBXGroup; children = ( 774746B4239F86EA0001C7F9 /* JuickPush.entitlements */, - 7761135721790B0300D350CD /* NotificationService.h */, - 7761135821790B0300D350CD /* NotificationService.m */, 7761135A21790B0300D350CD /* Info.plist */, + 770C86EF251211B6009B6404 /* NotificationService.swift */, + 770C86EE251211B6009B6404 /* JuickPush-Bridging-Header.h */, ); path = JuickPush; sourceTree = ""; }; + 77F2B6A0251249F300E42F6F /* JuickTests */ = { + isa = PBXGroup; + children = ( + 77F2B6A1251249F300E42F6F /* JuickTests.swift */, + 77F2B6A3251249F300E42F6F /* Info.plist */, + ); + path = JuickTests; + sourceTree = ""; + }; 77FFC0151D5FD13C003BD81A /* Views */ = { isa = PBXGroup; children = ( @@ -441,12 +470,31 @@ productReference = 7761135521790B0200D350CD /* JuickPush.appex */; productType = "com.apple.product-type.app-extension"; }; + 77F2B69E251249F300E42F6F /* JuickTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 77F2B6A9251249F300E42F6F /* Build configuration list for PBXNativeTarget "JuickTests" */; + buildPhases = ( + 77F2B69B251249F300E42F6F /* Sources */, + 77F2B69C251249F300E42F6F /* Frameworks */, + 77F2B69D251249F300E42F6F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 77F2B6A5251249F300E42F6F /* PBXTargetDependency */, + ); + name = JuickTests; + productName = JuickTests; + productReference = 77F2B69F251249F300E42F6F /* JuickTests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 77317BA0181BBE8500D60005 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 1200; LastUpgradeCheck = 1200; ORGANIZATIONNAME = com.juick; TargetAttributes = { @@ -467,7 +515,14 @@ 7761135421790B0200D350CD = { CreatedOnToolsVersion = 10.0; DevelopmentTeam = KH4MX79ZK7; + LastSwiftMigration = 1200; + ProvisioningStyle = Automatic; + }; + 77F2B69E251249F300E42F6F = { + CreatedOnToolsVersion = 12.0; + DevelopmentTeam = KH4MX79ZK7; ProvisioningStyle = Automatic; + TestTargetID = 77317BA7181BBE8500D60005; }; }; }; @@ -486,6 +541,7 @@ targets = ( 77317BA7181BBE8500D60005 /* Juick */, 7761135421790B0200D350CD /* JuickPush */, + 77F2B69E251249F300E42F6F /* JuickTests */, ); }; /* End PBXProject section */ @@ -520,6 +576,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 77F2B69D251249F300E42F6F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -565,7 +628,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 7761135921790B0300D350CD /* NotificationService.m in Sources */, + 770C86F0251211B6009B6404 /* NotificationService.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 77F2B69B251249F300E42F6F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 77F2B6A2251249F300E42F6F /* JuickTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -577,6 +648,11 @@ target = 7761135421790B0200D350CD /* JuickPush */; targetProxy = 7761135B21790B0300D350CD /* PBXContainerItemProxy */; }; + 77F2B6A5251249F300E42F6F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 77317BA7181BBE8500D60005 /* Juick */; + targetProxy = 77F2B6A4251249F300E42F6F /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -702,11 +778,12 @@ 77317BDE181BBE8500D60005 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 146; + CURRENT_PROJECT_VERSION = 147; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -724,10 +801,11 @@ 77317BDF181BBE8500D60005 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 146; + CURRENT_PROJECT_VERSION = 147; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Juick/Supporting Files/Juick-Prefix.pch"; @@ -747,6 +825,7 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; @@ -754,7 +833,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 146; + CURRENT_PROJECT_VERSION = 147; DEBUG_INFORMATION_FORMAT = dwarf; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; @@ -768,6 +847,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; + SWIFT_OBJC_BRIDGING_HEADER = "JuickPush/JuickPush-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -778,13 +860,14 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = JuickPush/JuickPush.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 146; + CURRENT_PROJECT_VERSION = 147; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -797,6 +880,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; + SWIFT_OBJC_BRIDGING_HEADER = "JuickPush/JuickPush-Bridging-Header.h"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -861,11 +946,12 @@ 77D40ABD218B70570074E14F /* Debug (local) */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 146; + CURRENT_PROJECT_VERSION = 147; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -886,6 +972,7 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; @@ -893,7 +980,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 146; + CURRENT_PROJECT_VERSION = 147; DEBUG_INFORMATION_FORMAT = dwarf; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; @@ -907,10 +994,96 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; + SWIFT_OBJC_BRIDGING_HEADER = "JuickPush/JuickPush-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Debug (local)"; + }; + 77F2B6A6251249F300E42F6F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = JuickTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.juick.JuickTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Juick; + }; + name = Debug; + }; + 77F2B6A7251249F300E42F6F /* Debug (local) */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = JuickTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.juick.JuickTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Juick; }; name = "Debug (local)"; }; + 77F2B6A8251249F300E42F6F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = JuickTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.juick.JuickTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Juick; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -944,6 +1117,16 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 77F2B6A9251249F300E42F6F /* Build configuration list for PBXNativeTarget "JuickTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 77F2B6A6251249F300E42F6F /* Debug */, + 77F2B6A7251249F300E42F6F /* Debug (local) */, + 77F2B6A8251249F300E42F6F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 77317BA0181BBE8500D60005 /* Project object */; diff --git a/JuickPush/Info.plist b/JuickPush/Info.plist index 9aeee3f..721973c 100644 --- a/JuickPush/Info.plist +++ b/JuickPush/Info.plist @@ -25,7 +25,7 @@ NSExtensionPointIdentifier com.apple.usernotifications.service NSExtensionPrincipalClass - NotificationService + $(PRODUCT_MODULE_NAME).NotificationService diff --git a/JuickPush/JuickPush-Bridging-Header.h b/JuickPush/JuickPush-Bridging-Header.h new file mode 100644 index 0000000..1b2cb5d --- /dev/null +++ b/JuickPush/JuickPush-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/JuickPush/NotificationService.h b/JuickPush/NotificationService.h deleted file mode 100644 index 91ca27a..0000000 --- a/JuickPush/NotificationService.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// NotificationService.h -// JuickPush -// -// Created by Vitaly Takmazov on 18/10/2018. -// Copyright © 2018 com.juick. All rights reserved. -// - -#import - -@interface NotificationService : UNNotificationServiceExtension - -@end diff --git a/JuickPush/NotificationService.m b/JuickPush/NotificationService.m deleted file mode 100644 index 82dead8..0000000 --- a/JuickPush/NotificationService.m +++ /dev/null @@ -1,46 +0,0 @@ -// -// NotificationService.m -// JuickPush -// -// Created by Vitaly Takmazov on 18/10/2018. -// Copyright © 2018 com.juick. All rights reserved. -// - -#import "NotificationService.h" - -@interface NotificationService () - -@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); -@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent; - -@end - -@implementation NotificationService - -- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { - self.contentHandler = contentHandler; - self.bestAttemptContent = [request.content mutableCopy]; - - NSURL *avatarURL = [NSURL URLWithString:request.content.userInfo[@"avatarUrl"]]; - - NSURLSession * downloadSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; - - [[downloadSession downloadTaskWithURL:avatarURL completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { - if (!error) { - NSError *err = nil; - NSString *temporaryDirectory = [NSTemporaryDirectory() stringByAppendingPathComponent:[response suggestedFilename]]; - [[NSFileManager defaultManager] moveItemAtPath:location.path toPath:temporaryDirectory error:&err]; - UNNotificationAttachment *avatarAttachment = [UNNotificationAttachment attachmentWithIdentifier:avatarURL.lastPathComponent URL:[NSURL fileURLWithPath:temporaryDirectory] options:nil error:&err]; - self.bestAttemptContent.attachments = @[avatarAttachment]; - self.contentHandler(self.bestAttemptContent); - } - }] resume]; -} - -- (void)serviceExtensionTimeWillExpire { - // Called just before the extension will be terminated by the system. - // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. - self.contentHandler(self.bestAttemptContent); -} - -@end diff --git a/JuickPush/NotificationService.swift b/JuickPush/NotificationService.swift new file mode 100644 index 0000000..380d2b0 --- /dev/null +++ b/JuickPush/NotificationService.swift @@ -0,0 +1,48 @@ +// +// NotificationService.swift +// JuickPush +// +// Created by Vitaly Takmazov on 16.09.2020. +// Copyright © 2020 com.juick. All rights reserved. +// + +import Foundation +import UserNotifications + +class NotificationService : UNNotificationServiceExtension { + var contentHandler: ((UNNotificationContent) -> Void)? + var bestAttemptContent: UNMutableNotificationContent? + override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { + self.contentHandler = contentHandler; + self.bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent + if let bestAttemptContent = self.bestAttemptContent { + if let avatarURL = URL(string: (request.content.userInfo["avatarUrl"] as? String)!) { + let task = URLSession.shared.downloadTask(with: avatarURL) { + (location, response, error) in + if error == nil { + if let suggestedName = response?.suggestedFilename { + let temporaryDirectory = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(suggestedName) + if let currentPath = location?.path { + do { + try FileManager.default.moveItem(atPath: currentPath, toPath: temporaryDirectory.path) + if let avatarAttachment = try? UNNotificationAttachment(identifier: avatarURL.lastPathComponent, url: temporaryDirectory, options: nil) { + bestAttemptContent.attachments = [avatarAttachment] + self.contentHandler?(bestAttemptContent) + } + } catch { + self.contentHandler?(bestAttemptContent) + } + } + } + } + } + task.resume() + } + } + } + override func serviceExtensionTimeWillExpire() { + if let bestAttemptContent = bestAttemptContent, let contentHandler = contentHandler { + contentHandler(bestAttemptContent) + } + } +} diff --git a/JuickTests/Info.plist b/JuickTests/Info.plist new file mode 100644 index 0000000..64d65ca --- /dev/null +++ b/JuickTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/JuickTests/JuickTests.swift b/JuickTests/JuickTests.swift new file mode 100644 index 0000000..db40885 --- /dev/null +++ b/JuickTests/JuickTests.swift @@ -0,0 +1,43 @@ +// +// JuickTests.swift +// JuickTests +// +// Created by Vitaly Takmazov on 16.09.2020. +// Copyright © 2020 com.juick. All rights reserved. +// + +import XCTest + +class JuickTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testLaunchPerformance() throws { + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { + // This measures how long it takes to launch your application. + measure(metrics: [XCTApplicationLaunchMetric()]) { + XCUIApplication().launch() + } + } + } +} -- cgit v1.2.3