diff --git a/ShareExtension/Base.lproj/MainInterface.storyboard b/ShareExtension/Base.lproj/MainInterface.storyboard new file mode 100644 index 00000000..286a5089 --- /dev/null +++ b/ShareExtension/Base.lproj/MainInterface.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShareExtension/Info.plist b/ShareExtension/Info.plist new file mode 100644 index 00000000..e144bb2c --- /dev/null +++ b/ShareExtension/Info.plist @@ -0,0 +1,33 @@ + + + + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + + NSExtensionActivationSupportsImageWithMaxCount + 1 + + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.share-services + + UIAppFonts + + Pretendard-Regular.otf + Pretendard-Medium.otf + Pretendard-SemiBold.otf + Pretendard-Bold.otf + + + diff --git a/ShareExtension/ShareExtension.entitlements b/ShareExtension/ShareExtension.entitlements new file mode 100644 index 00000000..d11cc25d --- /dev/null +++ b/ShareExtension/ShareExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.Team.pophory-iOS + + + diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift new file mode 100644 index 00000000..c61816c4 --- /dev/null +++ b/ShareExtension/ShareViewController.swift @@ -0,0 +1,51 @@ +// +// ShareViewController.swift +// ShareExtension +// +// Created by 김다예 on 2023/09/27. +// + +import UIKit +import Social +import UniformTypeIdentifiers + +final class ShareViewController: UIViewController { + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + guard let extensionItem = extensionContext?.inputItems.first as? NSExtensionItem, + let itemProvider = extensionItem.attachments?.first else { + self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil) + return + } + handleIncomingText(itemProvider: itemProvider) + } + + private func handleIncomingText(itemProvider: NSItemProvider) { + if itemProvider.canLoadObject(ofClass: UIImage.self) { // itemProvider가 불러온 이미지 값 가져올 수 있다면 실행 + + itemProvider.loadObject(ofClass: UIImage.self) { image, error in + self.extensionContext?.completeRequest(returningItems: nil) { _ in + guard let url = URL(string: "pophoryiOS://share") else { return } + + self.openURL(url) + UIPasteboard.general.image = image as? UIImage + } + } + } + } + + @objc + @discardableResult + func openURL(_ url: URL) -> Bool { + var responder: UIResponder? = self + while responder != nil { + if let application = responder as? UIApplication { + return application.perform(#selector(openURL(_:)), with: url) != nil + } + responder = responder?.next + } + return false + } +} diff --git a/pophory-iOS.xcodeproj/project.pbxproj b/pophory-iOS.xcodeproj/project.pbxproj index 961cd221..0e76603f 100644 --- a/pophory-iOS.xcodeproj/project.pbxproj +++ b/pophory-iOS.xcodeproj/project.pbxproj @@ -69,6 +69,19 @@ 3B5CDBD72A94DDDB001382C4 /* FirebaseAnalyticsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 3B5CDBD62A94DDDB001382C4 /* FirebaseAnalyticsSwift */; }; 3B5CDBD92A94DDDB001382C4 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = 3B5CDBD82A94DDDB001382C4 /* FirebaseCrashlytics */; }; 3B5CDBDB2A94DDDB001382C4 /* FirebaseDynamicLinks in Frameworks */ = {isa = PBXBuildFile; productRef = 3B5CDBDA2A94DDDB001382C4 /* FirebaseDynamicLinks */; }; + 6B05C56D2AC4277800A75C00 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B05C56C2AC4277800A75C00 /* ShareViewController.swift */; }; + 6B05C5702AC4277800A75C00 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6B05C56E2AC4277800A75C00 /* MainInterface.storyboard */; }; + 6B05C5742AC4277800A75C00 /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 6B05C56A2AC4277800A75C00 /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 6B05C5C22ACAA50E00A75C00 /* ImageLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91F3A75F2A517E9E00C06D1B /* ImageLiterals.swift */; }; + 6B05C5C32ACAA5B000A75C00 /* ColorLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DCA6AB2A4ABAE200FF8F90 /* ColorLiterals.swift */; }; + 6B05C5C42ACAA78F00A75C00 /* FontLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DCA6AD2A4ABAF300FF8F90 /* FontLiterals.swift */; }; + 6B05C5C52ACAA79D00A75C00 /* Pretendard-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 376BF64F2A548FB60007D4C3 /* Pretendard-Bold.otf */; }; + 6B05C5C62ACAA79F00A75C00 /* Pretendard-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 37DCA6B12A4AC7CC00FF8F90 /* Pretendard-Medium.otf */; }; + 6B05C5C72ACAA7A200A75C00 /* Pretendard-SemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 37DCA6B02A4AC7CC00FF8F90 /* Pretendard-SemiBold.otf */; }; + 6B05C5C82ACAA7A400A75C00 /* Pretendard-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 37DCA6B22A4AC7CD00FF8F90 /* Pretendard-Regular.otf */; }; + 6B05C5CD2ACAA8CF00A75C00 /* DateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB37C722A55EB7400E49B12 /* DateManager.swift */; }; + 6B05C5DB2ACAB37500A75C00 /* Assets.xcassets in Sources */ = {isa = PBXBuildFile; fileRef = B1631F132A1759EB0050974F /* Assets.xcassets */; }; + 6B05C5DF2ACD262C00A75C00 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 6B05C5DE2ACD262C00A75C00 /* SnapKit */; }; 6B09D2282A6808DA00DF4275 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B09D2272A6808DA00DF4275 /* ShareViewController.swift */; }; 6B09D22A2A6808EA00DF4275 /* ShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B09D2292A6808EA00DF4275 /* ShareView.swift */; }; 6B29DC592A5494A000F93EC7 /* PhotoInfoStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B29DC542A5494A000F93EC7 /* PhotoInfoStackView.swift */; }; @@ -179,6 +192,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 6B05C5722AC4277800A75C00 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B1631EFF2A1759EA0050974F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 6B05C5692AC4277800A75C00; + remoteInfo = ShareExtension; + }; B1631F1E2A1759EB0050974F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B1631EFF2A1759EA0050974F /* Project object */; @@ -195,6 +215,20 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 6B05C5752AC4277800A75C00 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 6B05C5742AC4277800A75C00 /* ShareExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 3703F0F42A6071B50017A381 /* PostIdentityTokenDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostIdentityTokenDTO.swift; sourceTree = ""; }; 3703F0F62A60A9BE0017A381 /* SignUpIndicatorCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpIndicatorCollectionViewCell.swift; sourceTree = ""; }; @@ -254,6 +288,12 @@ 3B3A09122A56A56F00C8A740 /* PhotoDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoDetailView.swift; sourceTree = ""; }; 3B3A09142A56A6C700C8A740 /* PhotoDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoDetailViewController.swift; sourceTree = ""; }; 3B3BE7182A56CC820064E716 /* PophoryNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PophoryNavigationController.swift; sourceTree = ""; }; + 6B05C56A2AC4277800A75C00 /* ShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 6B05C56C2AC4277800A75C00 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; + 6B05C56F2AC4277800A75C00 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 6B05C5712AC4277800A75C00 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6B05C5792AC4277E00A75C00 /* ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = ""; }; + 6B05C5CF2ACAAB8600A75C00 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 6B09D2272A6808DA00DF4275 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; 6B09D2292A6808EA00DF4275 /* ShareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareView.swift; sourceTree = ""; }; 6B29DC542A5494A000F93EC7 /* PhotoInfoStackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoInfoStackView.swift; sourceTree = ""; }; @@ -365,6 +405,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 6B05C5672AC4277800A75C00 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6B05C5DF2ACD262C00A75C00 /* SnapKit in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B1631F042A1759EA0050974F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -615,6 +663,25 @@ path = ViewController; sourceTree = ""; }; + 6B05C56B2AC4277800A75C00 /* ShareExtension */ = { + isa = PBXGroup; + children = ( + 6B05C5792AC4277E00A75C00 /* ShareExtension.entitlements */, + 6B05C56C2AC4277800A75C00 /* ShareViewController.swift */, + 6B05C56E2AC4277800A75C00 /* MainInterface.storyboard */, + 6B05C5712AC4277800A75C00 /* Info.plist */, + ); + path = ShareExtension; + sourceTree = ""; + }; + 6B05C5CE2ACAAB8500A75C00 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6B05C5CF2ACAAB8600A75C00 /* XCTest.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 6B09D2262A6808BF00DF4275 /* Share */ = { isa = PBXGroup; children = ( @@ -899,7 +966,9 @@ B1631F092A1759EA0050974F /* pophory-iOS */, B1631F202A1759EB0050974F /* pophory-iOSTests */, B1631F2A2A1759EB0050974F /* pophoryUITests */, + 6B05C56B2AC4277800A75C00 /* ShareExtension */, B1631F082A1759EA0050974F /* Products */, + 6B05C5CE2ACAAB8500A75C00 /* Frameworks */, ); sourceTree = ""; }; @@ -909,6 +978,7 @@ B1631F072A1759EA0050974F /* pophory-iOS.app */, B1631F1D2A1759EB0050974F /* pophoryTests.xctest */, B1631F272A1759EB0050974F /* pophoryUITests.xctest */, + 6B05C56A2AC4277800A75C00 /* ShareExtension.appex */, ); name = Products; sourceTree = ""; @@ -1111,6 +1181,26 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 6B05C5692AC4277800A75C00 /* ShareExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6B05C5782AC4277800A75C00 /* Build configuration list for PBXNativeTarget "ShareExtension" */; + buildPhases = ( + 6B05C5662AC4277800A75C00 /* Sources */, + 6B05C5672AC4277800A75C00 /* Frameworks */, + 6B05C5682AC4277800A75C00 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ShareExtension; + packageProductDependencies = ( + 6B05C5DE2ACD262C00A75C00 /* SnapKit */, + ); + productName = ShareExtension; + productReference = 6B05C56A2AC4277800A75C00 /* ShareExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; B1631F062A1759EA0050974F /* pophory-iOS */ = { isa = PBXNativeTarget; buildConfigurationList = B1631F312A1759EB0050974F /* Build configuration list for PBXNativeTarget "pophory-iOS" */; @@ -1119,10 +1209,12 @@ B1631F042A1759EA0050974F /* Frameworks */, B1631F052A1759EA0050974F /* Resources */, 3B5CDBC32A94CEA9001382C4 /* Run Script */, + 6B05C5752AC4277800A75C00 /* Embed Foundation Extensions */, ); buildRules = ( ); dependencies = ( + 6B05C5732AC4277800A75C00 /* PBXTargetDependency */, ); name = "pophory-iOS"; packageProductDependencies = ( @@ -1187,6 +1279,9 @@ LastSwiftUpdateCheck = 1430; LastUpgradeCheck = 1430; TargetAttributes = { + 6B05C5692AC4277800A75C00 = { + CreatedOnToolsVersion = 14.3.1; + }; B1631F062A1759EA0050974F = { CreatedOnToolsVersion = 14.3; }; @@ -1226,11 +1321,24 @@ B1631F062A1759EA0050974F /* pophory-iOS */, B1631F1C2A1759EB0050974F /* pophoryTests */, B1631F262A1759EB0050974F /* pophoryUITests */, + 6B05C5692AC4277800A75C00 /* ShareExtension */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 6B05C5682AC4277800A75C00 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6B05C5702AC4277800A75C00 /* MainInterface.storyboard in Resources */, + 6B05C5C52ACAA79D00A75C00 /* Pretendard-Bold.otf in Resources */, + 6B05C5C82ACAA7A400A75C00 /* Pretendard-Regular.otf in Resources */, + 6B05C5C62ACAA79F00A75C00 /* Pretendard-Medium.otf in Resources */, + 6B05C5C72ACAA7A200A75C00 /* Pretendard-SemiBold.otf in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B1631F052A1759EA0050974F /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -1289,6 +1397,19 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 6B05C5662AC4277800A75C00 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6B05C5DB2ACAB37500A75C00 /* Assets.xcassets in Sources */, + 6B05C5CD2ACAA8CF00A75C00 /* DateManager.swift in Sources */, + 6B05C5C42ACAA78F00A75C00 /* FontLiterals.swift in Sources */, + 6B05C5C32ACAA5B000A75C00 /* ColorLiterals.swift in Sources */, + 6B05C5C22ACAA50E00A75C00 /* ImageLiterals.swift in Sources */, + 6B05C56D2AC4277800A75C00 /* ShareViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B1631F032A1759EA0050974F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1464,6 +1585,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 6B05C5732AC4277800A75C00 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 6B05C5692AC4277800A75C00 /* ShareExtension */; + targetProxy = 6B05C5722AC4277800A75C00 /* PBXContainerItemProxy */; + }; B1631F1F2A1759EB0050974F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B1631F062A1759EA0050974F /* pophory-iOS */; @@ -1477,6 +1603,14 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ + 6B05C56E2AC4277800A75C00 /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6B05C56F2AC4277800A75C00 /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; B1631F152A1759EB0050974F /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -1488,6 +1622,64 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 6B05C5762AC4277800A75C00 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = CQJ9UKUU35; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ShareExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = ShareExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "Team.pophory-iOS.ShareExtension.ownCloud-Share-Extension"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 6B05C5772AC4277800A75C00 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = CQJ9UKUU35; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ShareExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = ShareExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "Team.pophory-iOS.ShareExtension.ownCloud-Share-Extension"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; B1631F2F2A1759EB0050974F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1608,6 +1800,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 37A271662AA71D40001FFC38 /* Debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "pophory-iOS/pophory-iOS.entitlements"; @@ -1649,6 +1842,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 37A271672AA71D9E001FFC38 /* Release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "pophory-iOS/pophory-iOSRelease.entitlements"; @@ -1771,6 +1965,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 6B05C5782AC4277800A75C00 /* Build configuration list for PBXNativeTarget "ShareExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6B05C5762AC4277800A75C00 /* Debug */, + 6B05C5772AC4277800A75C00 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; B1631F022A1759EA0050974F /* Build configuration list for PBXProject "pophory-iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -1904,6 +2107,11 @@ package = 3B5CDBD32A94DDDB001382C4 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; productName = FirebaseDynamicLinks; }; + 6B05C5DE2ACD262C00A75C00 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 37DCA6842A4A97CA00FF8F90 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; 9161CADE2A5460AA002B8B77 /* Kingfisher */ = { isa = XCSwiftPackageProductDependency; package = 9161CADD2A5460AA002B8B77 /* XCRemoteSwiftPackageReference "Kingfisher" */; diff --git a/pophory-iOS/Global/Resources/SceneDelegate.swift b/pophory-iOS/Global/Resources/SceneDelegate.swift index a30c2bd1..78293e39 100644 --- a/pophory-iOS/Global/Resources/SceneDelegate.swift +++ b/pophory-iOS/Global/Resources/SceneDelegate.swift @@ -8,6 +8,7 @@ import UIKit import FirebaseDynamicLinks +import UniformTypeIdentifiers class SceneDelegate: UIResponder, UIWindowSceneDelegate { @@ -57,7 +58,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { let rootVC = ShareViewController() rootVC.setupShareID(forShareID: shareID) rootVC.rootView.shareButton.addTarget(self, action: #selector(self.setupRoot), for: .touchUpInside) - + window.rootViewController = rootVC window.makeKeyAndVisible() self.window = window @@ -67,6 +68,33 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } } + func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { + guard let url = URLContexts.first?.url else { return } + + // shareExtension 받았을 때 + if let range = url.absoluteString.range(of: "//") { + let substring = url.absoluteString[range.upperBound...] + + if substring == "share" { + + self.isAlbumFull { isAlbumFull in + + let isLoggedIn = UserDefaults.standard.bool(forKey: "isLoggedIn") + + if isLoggedIn { + if isAlbumFull { + self.setupAlbumFullViewController() + } else { + self.setupAddphotoViewcontroller() + } + } else { + self.setupRootViewController() + } + } + } + } + } + func sceneDidDisconnect(_ scene: UIScene) { // Called as the scene is being released by the system. // This occurs shortly after the scene enters the background, or when its session is discarded. @@ -98,7 +126,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { @objc func setupRoot() { let isLoggedIn = UserDefaults.standard.bool(forKey: "isLoggedIn") var rootViewController: UIViewController - + if isLoggedIn { rootViewController = TabBarController() } else { @@ -109,12 +137,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { rootViewController = rootVC } let navigationController = PophoryNavigationController(rootViewController: rootViewController) - + window?.rootViewController = navigationController window?.makeKeyAndVisible() } - - func setRootViewController() { + + func setupRootViewController() { let isLoggedIn = UserDefaults.standard.bool(forKey: "isLoggedIn") var rootViewController: UIViewController @@ -144,6 +172,67 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } return nil } + + private func isAlbumFull(completion: @escaping (Bool) -> ()) { + let isLoggedIn = UserDefaults.standard.bool(forKey: "isLoggedIn") + + if isLoggedIn { + var maxPhotoCount: Int? + var maxPhotoLimit: Int? + var albumList: FetchAlbumListResponseDTO? { + didSet { + if let albums = albumList?.albums { + if albums.count != 0 { + maxPhotoCount = albums[0].photoCount + maxPhotoLimit = albums[0].photoLimit + } + } + } + } + + NetworkService.shared.albumRepository.fetchAlbumList() { result in + switch result { + case .success(let response): + albumList = response + if let maxCount = maxPhotoCount, let maxLimit = maxPhotoLimit { + if maxCount >= maxLimit { completion(true) } + else { completion(false) } + } + else { completion(false) } + default: completion(false) + } + } + } + } + + private func setupAlbumFullViewController() { + let tabBarController = TabBarController() + self.window?.rootViewController = PophoryNavigationController(rootViewController: tabBarController) + self.window?.rootViewController?.showPopup(popupType: .simple, + image: ImageLiterals.img_albumfull, + primaryText: "포포리 앨범이 가득찼어요", + secondaryText: "아쉽지만,\n다음 업데이트에서 만나요!") + self.window?.makeKeyAndVisible() + + } + + private func setupAddphotoViewcontroller() { + let addPhotoViewController = AddPhotoViewController() + + var imageType: PhotoCellType = .vertical + guard let image = UIPasteboard.general.image else { return } + if image.size.width > image.size.height { + imageType = .horizontal + } else { + imageType = .vertical + } + + addPhotoViewController.setupRootViewImage(forImage: image , forType: imageType) + + self.window?.rootViewController = PophoryNavigationController(rootViewController: addPhotoViewController) + self.window?.makeKeyAndVisible() + + } } // MARK: network diff --git a/pophory-iOS/Global/Supporting Files/Info.plist b/pophory-iOS/Global/Supporting Files/Info.plist index 3b332ef7..a3586a87 100644 --- a/pophory-iOS/Global/Supporting Files/Info.plist +++ b/pophory-iOS/Global/Supporting Files/Info.plist @@ -4,15 +4,24 @@ BASE_URL $(BASE_URL) - PHPhotoLibraryPreventAutomaticLimitedAccessAlert - - NSPhotoLibraryUsageDescription - 포포리에 네컷사진을 업로드하기 위해 사진 라이브러리에 엑세스를 허용해 주세요. + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + pophoryiOS + + + NSAppTransportSecurity NSAllowsArbitraryLoads + PHPhotoLibraryPreventAutomaticLimitedAccessAlert + UIAppFonts Pretendard-Bold.otf diff --git a/pophory-iOS/Screen/AddPhoto/ViewController/AddPhotoViewController.swift b/pophory-iOS/Screen/AddPhoto/ViewController/AddPhotoViewController.swift index 9c5e96c3..1859aa78 100644 --- a/pophory-iOS/Screen/AddPhoto/ViewController/AddPhotoViewController.swift +++ b/pophory-iOS/Screen/AddPhoto/ViewController/AddPhotoViewController.swift @@ -139,7 +139,8 @@ extension AddPhotoViewController { private func goToHome() { dismiss(animated: false) - navigationController?.popToRootViewController(animated: true) + let tabBarViewController = TabBarController() + self.navigationController?.pushViewController(tabBarViewController, animated: true) } // MARK: - Methods diff --git a/pophory-iOS/pophory-iOS.entitlements b/pophory-iOS/pophory-iOS.entitlements index adde977c..34bf6c18 100644 --- a/pophory-iOS/pophory-iOS.entitlements +++ b/pophory-iOS/pophory-iOS.entitlements @@ -10,5 +10,9 @@ applinks:pophory.page.link + com.apple.security.application-groups + + group.Team.pophory-iOS + diff --git a/pophory-iOS/pophory-iOSRelease.entitlements b/pophory-iOS/pophory-iOSRelease.entitlements index adde977c..34bf6c18 100644 --- a/pophory-iOS/pophory-iOSRelease.entitlements +++ b/pophory-iOS/pophory-iOSRelease.entitlements @@ -10,5 +10,9 @@ applinks:pophory.page.link + com.apple.security.application-groups + + group.Team.pophory-iOS +