diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 581569877..d7c1bdcec 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -16,8 +16,35 @@ 50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; }; A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; DAD1AB3F2ACF3A7F001D9958 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DAD1AB3D2ACF39DE001D9958 /* GoogleService-Info.plist */; }; + DAD98CE32B73A46D002F1EA9 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD98CE22B73A46D002F1EA9 /* ShareViewController.swift */; }; + DAD98CE62B73A46D002F1EA9 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DAD98CE42B73A46D002F1EA9 /* MainInterface.storyboard */; }; + DAD98CEA2B73A46D002F1EA9 /* MyShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = DAD98CE02B73A46D002F1EA9 /* MyShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + DAD98CE82B73A46D002F1EA9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 504EC2FC1FED79650016851F /* Project object */; + proxyType = 1; + remoteGlobalIDString = DAD98CDF2B73A46D002F1EA9; + remoteInfo = MyShareExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + DAD98CEB2B73A46D002F1EA9 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + DAD98CEA2B73A46D002F1EA9 /* MyShareExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; @@ -37,6 +64,11 @@ DA6FE4D82ACEF2DA006F1E0D /* FirebaseMessaging.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = FirebaseMessaging.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DA8422AF2AD03FBE00AC9118 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = ""; }; DAD1AB3D2ACF39DE001D9958 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../../Downloads/App 2023-09-14 12-28-07/GoogleService-Info.plist"; sourceTree = ""; }; + DAD98CE02B73A46D002F1EA9 /* MyShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = MyShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + DAD98CE22B73A46D002F1EA9 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; + DAD98CE52B73A46D002F1EA9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + DAD98CE72B73A46D002F1EA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DAD98CEF2B73A5CB002F1EA9 /* MyShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MyShareExtension.entitlements; sourceTree = ""; }; FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -49,6 +81,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DAD98CDD2B73A46D002F1EA9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -69,6 +108,7 @@ isa = PBXGroup; children = ( 504EC3061FED79650016851F /* App */, + DAD98CE12B73A46D002F1EA9 /* MyShareExtension */, 504EC3051FED79650016851F /* Products */, 7F8756D8B27F46E3366F6CEA /* Pods */, 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */, @@ -79,6 +119,7 @@ isa = PBXGroup; children = ( 504EC3041FED79650016851F /* App.app */, + DAD98CE02B73A46D002F1EA9 /* MyShareExtension.appex */, ); name = Products; sourceTree = ""; @@ -109,6 +150,17 @@ name = Pods; sourceTree = ""; }; + DAD98CE12B73A46D002F1EA9 /* MyShareExtension */ = { + isa = PBXGroup; + children = ( + DAD98CEF2B73A5CB002F1EA9 /* MyShareExtension.entitlements */, + DAD98CE22B73A46D002F1EA9 /* ShareViewController.swift */, + DAD98CE42B73A46D002F1EA9 /* MainInterface.storyboard */, + DAD98CE72B73A46D002F1EA9 /* Info.plist */, + ); + path = MyShareExtension; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -122,23 +174,42 @@ 504EC3021FED79650016851F /* Resources */, 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */, 5B7AACB22ECDCEAA343DC840 /* [CP] Copy Pods Resources */, + DAD98CEB2B73A46D002F1EA9 /* Embed Foundation Extensions */, ); buildRules = ( ); dependencies = ( + DAD98CE92B73A46D002F1EA9 /* PBXTargetDependency */, ); name = App; productName = App; productReference = 504EC3041FED79650016851F /* App.app */; productType = "com.apple.product-type.application"; }; + DAD98CDF2B73A46D002F1EA9 /* MyShareExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = DAD98CEE2B73A46D002F1EA9 /* Build configuration list for PBXNativeTarget "MyShareExtension" */; + buildPhases = ( + DAD98CDC2B73A46D002F1EA9 /* Sources */, + DAD98CDD2B73A46D002F1EA9 /* Frameworks */, + DAD98CDE2B73A46D002F1EA9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MyShareExtension; + productName = MyShareExtension; + productReference = DAD98CE02B73A46D002F1EA9 /* MyShareExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 504EC2FC1FED79650016851F /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0920; + LastSwiftUpdateCheck = 1420; LastUpgradeCheck = 1420; TargetAttributes = { 504EC3031FED79650016851F = { @@ -146,6 +217,9 @@ LastSwiftMigration = 1100; ProvisioningStyle = Manual; }; + DAD98CDF2B73A46D002F1EA9 = { + CreatedOnToolsVersion = 14.2; + }; }; }; buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */; @@ -165,6 +239,7 @@ projectRoot = ""; targets = ( 504EC3031FED79650016851F /* App */, + DAD98CDF2B73A46D002F1EA9 /* MyShareExtension */, ); }; /* End PBXProject section */ @@ -184,6 +259,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DAD98CDE2B73A46D002F1EA9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DAD98CE62B73A46D002F1EA9 /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -246,8 +329,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DAD98CDC2B73A46D002F1EA9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DAD98CE32B73A46D002F1EA9 /* ShareViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + DAD98CE92B73A46D002F1EA9 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DAD98CDF2B73A46D002F1EA9 /* MyShareExtension */; + targetProxy = DAD98CE82B73A46D002F1EA9 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 504EC30B1FED79650016851F /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -265,6 +364,14 @@ name = LaunchScreen.storyboard; sourceTree = ""; }; + DAD98CE42B73A46D002F1EA9 /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + DAD98CE52B73A46D002F1EA9 /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -386,11 +493,12 @@ isa = XCBuildConfiguration; baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 68; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 94BRNM2LSS; INFOPLIST_FILE = App/Info.plist; @@ -404,7 +512,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.gpr.gabinetedigital.teste; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = GabineteProfile; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = GabineteDigitalProfile; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -415,11 +523,12 @@ isa = XCBuildConfiguration; baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 68; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 94BRNM2LSS; INFOPLIST_FILE = App/Info.plist; @@ -432,13 +541,74 @@ PRODUCT_BUNDLE_IDENTIFIER = com.gpr.gabinetedigital.teste; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = GabineteProfile; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = GabineteDigitalProfile; SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; + DAD98CEC2B73A46D002F1EA9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_ENTITLEMENTS = MyShareExtension/MyShareExtension.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 94BRNM2LSS; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = MyShareExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = MyShareExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.gpr.gabinetedigital.teste.MyShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + DAD98CED2B73A46D002F1EA9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_ENTITLEMENTS = MyShareExtension/MyShareExtension.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 94BRNM2LSS; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = MyShareExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = MyShareExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.gpr.gabinetedigital.teste.MyShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -460,6 +630,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + DAD98CEE2B73A46D002F1EA9 /* Build configuration list for PBXNativeTarget "MyShareExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DAD98CEC2B73A46D002F1EA9 /* Debug */, + DAD98CED2B73A46D002F1EA9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ diff --git a/ios/App/App/App.entitlements b/ios/App/App/App.entitlements index 903def2af..df026f3ab 100644 --- a/ios/App/App/App.entitlements +++ b/ios/App/App/App.entitlements @@ -4,5 +4,9 @@ aps-environment development + com.apple.security.application-groups + + group.gabinete + diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index c23f90d39..a50f5ebd0 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -2,10 +2,15 @@ import UIKit import Capacitor import FirebaseCore import Firebase +import SendIntent @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { + // share intent + + let store = ShareStore.store + var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { @@ -53,11 +58,41 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { - // Called when the app was launched with a url. Feel free to add additional processing here, - // but if you want the App API to support tracking app url opens, make sure to keep this call - return ApplicationDelegateProxy.shared.application(app, open: url, options: options) - } + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + + var success = true + if CAPBridge.handleOpenUrl(url, options) { + success = ApplicationDelegateProxy.shared.application(app, open: url, options: options) + } + + guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true), + let params = components.queryItems else { + return false + } + let titles = params.filter { $0.name == "title" } + let descriptions = params.filter { $0.name == "description" } + let types = params.filter { $0.name == "type" } + let urls = params.filter { $0.name == "url" } + + store.shareItems.removeAll() + + if(titles.count > 0){ + for index in 0...titles.count-1 { + var shareItem: JSObject = JSObject() + shareItem["title"] = titles[index].value! + shareItem["description"] = descriptions[index].value! + shareItem["type"] = types[index].value! + shareItem["url"] = urls[index].value! + store.shareItems.append(shareItem) + } + } + + store.processed = false + let nc = NotificationCenter.default + nc.post(name: Notification.Name("triggerSendIntent"), object: nil ) + + return success + } func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { // Called when the app was launched with an activity, including Universal Links. diff --git a/ios/App/App/Info.plist b/ios/App/App/Info.plist index 92fdaa230..f0b51d9da 100644 --- a/ios/App/App/Info.plist +++ b/ios/App/App/Info.plist @@ -2,74 +2,88 @@ - FirebaseAppDelegateProxyEnabled - - UNUserNotificationCenterDelegate - YourApp.NotificationDelegate - UIBackgroundModes - - remote-notification - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - Gabinete Digital - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(MARKETING_VERSION) - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - LSRequiresIPhoneOS - - NSCameraUsageDescription - Used to demonstrate image picker plugin - NSFaceIDUsageDescription - $FACEID_USAGE_DESCRIPTION - NSLocationAlwaysAndWhenInUseUsageDescription - some string - NSLocationAlwaysUsageDescription - some string - NSLocationUsageDescription - Need location access for updating nearby friends - NSLocationWhenInUseUsageDescription - This app needs your location to test the location feature of the Google Maps plugin. - NSMicrophoneUsageDescription - Used to capture audio for image picker plugin - NSPhotoLibraryAddUsageDescription - Privacy - Photo Library Additions Usage Description - NSPhotoLibraryUsageDescription - Used to demonstrate image picker plugin - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Gabinete Digital + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + com.gpr.gabinetedigital.teste + CFBundleURLSchemes + + gabineteDigital + + + + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + FirebaseAppDelegateProxyEnabled + + LSRequiresIPhoneOS + + NSCameraUsageDescription + Used to demonstrate image picker plugin + + NSFaceIDUsageDescription + $FACEID_USAGE_DESCRIPTION + NSLocationAlwaysAndWhenInUseUsageDescription + some string + NSLocationAlwaysUsageDescription + some string + NSLocationUsageDescription + Need location access for updating nearby friends + NSLocationWhenInUseUsageDescription + This app needs your location to test the location feature of the Google Maps plugin. + NSMicrophoneUsageDescription + Used to capture audio for image picker plugin + NSPhotoLibraryAddUsageDescription + Privacy - Photo Library Additions Usage Description + NSPhotoLibraryUsageDescription + Used to demonstrate image picker plugin + UIBackgroundModes + + remote-notification + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + UNUserNotificationCenterDelegate + YourApp.NotificationDelegate diff --git a/ios/App/MyShareExtension/Base.lproj/MainInterface.storyboard b/ios/App/MyShareExtension/Base.lproj/MainInterface.storyboard new file mode 100644 index 000000000..286a50894 --- /dev/null +++ b/ios/App/MyShareExtension/Base.lproj/MainInterface.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/App/MyShareExtension/Info.plist b/ios/App/MyShareExtension/Info.plist new file mode 100644 index 000000000..50854eb99 --- /dev/null +++ b/ios/App/MyShareExtension/Info.plist @@ -0,0 +1,48 @@ + + + + + CFBundleURLTypes + + + CFBundleURLName + + + + CFBundleURLName + com.capacitorjs.app.testapp + + + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + TRUEPREDICATE + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.share-services + + NSExtensionActivationRule + + + NSExtensionActivationSupportsFileWithMaxCount + 5 + NSExtensionActivationSupportsImageWithMaxCount + 5 + NSExtensionActivationSupportsMovieWithMaxCount + 5 + NSExtensionActivationSupportsText + + NSExtensionActivationSupportsWebPageWithMaxCount + 1 + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + NSExtensionActivationUsesStrictMatching + + + + + diff --git a/ios/App/MyShareExtension/MyShareExtension.entitlements b/ios/App/MyShareExtension/MyShareExtension.entitlements new file mode 100644 index 000000000..8904126b0 --- /dev/null +++ b/ios/App/MyShareExtension/MyShareExtension.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.application-groups + + group.share + + keychain-access-groups + + + diff --git a/ios/App/MyShareExtension/ShareViewController.swift b/ios/App/MyShareExtension/ShareViewController.swift new file mode 100644 index 000000000..d8736c2cb --- /dev/null +++ b/ios/App/MyShareExtension/ShareViewController.swift @@ -0,0 +1,193 @@ +// +// ShareViewController.swift +// mindlib +// +// Created by Carsten Klaffke on 05.07.20. +// + +import MobileCoreServices +import Social +import UIKit + +class ShareItem { + + public var title: String? + public var type: String? + public var url: String? +} + +class ShareViewController: UIViewController { + + private var shareItems: [ShareItem] = [] + + override public func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + private func sendData() { + let queryItems = shareItems.map { + [ + URLQueryItem( + name: "title", + value: $0.title?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? ""), + URLQueryItem(name: "description", value: ""), + URLQueryItem( + name: "type", + value: $0.type?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? ""), + URLQueryItem( + name: "url", + value: $0.url?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? ""), + ] + }.flatMap({ $0 }) + var urlComps = URLComponents(string: "gabineteDigital://")! + urlComps.queryItems = queryItems + openURL(urlComps.url!) + } + + fileprivate func createSharedFileUrl(_ url: URL?) -> String { + let fileManager = FileManager.default + + let copyFileUrl = + fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.gabinete")! + .absoluteString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! + url! + .lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! + try? Data(contentsOf: url!).write(to: URL(string: copyFileUrl)!) + + return copyFileUrl + } + + func saveScreenshot(_ image: UIImage, _ index: Int) -> String { + let fileManager = FileManager.default + + let copyFileUrl = + fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.SendIntentExample")! + .absoluteString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! + + "/screenshot_\(index).png" + do { + try image.pngData()?.write(to: URL(string: copyFileUrl)!) + return copyFileUrl + } catch { + print(error.localizedDescription) + return "" + } + } + + fileprivate func handleTypeUrl(_ attachment: NSItemProvider) + async throws -> ShareItem + { + let results = try await attachment.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil) + let url = results as! URL? + let shareItem: ShareItem = ShareItem() + + if url!.isFileURL { + shareItem.title = url!.lastPathComponent + shareItem.type = "application/" + url!.pathExtension.lowercased() + shareItem.url = createSharedFileUrl(url) + } else { + shareItem.title = url!.absoluteString + shareItem.url = url!.absoluteString + shareItem.type = "text/plain" + } + + return shareItem + } + + fileprivate func handleTypeText(_ attachment: NSItemProvider) + async throws -> ShareItem + { + let results = try await attachment.loadItem(forTypeIdentifier: kUTTypeText as String, options: nil) + let shareItem: ShareItem = ShareItem() + let text = results as! String + shareItem.title = text + shareItem.type = "text/plain" + return shareItem + } + + fileprivate func handleTypeMovie(_ attachment: NSItemProvider) + async throws -> ShareItem + { + let results = try await attachment.loadItem(forTypeIdentifier: kUTTypeMovie as String, options: nil) + let shareItem: ShareItem = ShareItem() + + let url = results as! URL? + shareItem.title = url!.lastPathComponent + shareItem.type = "video/" + url!.pathExtension.lowercased() + shareItem.url = createSharedFileUrl(url) + return shareItem + } + + fileprivate func handleTypeImage(_ attachment: NSItemProvider, _ index: Int) + async throws -> ShareItem + { + let data = try await attachment.loadItem(forTypeIdentifier: kUTTypeImage as String, options: nil) + + let shareItem: ShareItem = ShareItem() + switch data { + case let image as UIImage: + shareItem.title = "screenshot_\(index)" + shareItem.type = "image/png" + shareItem.url = self.saveScreenshot(image, index) + case let url as URL: + shareItem.title = url.lastPathComponent + shareItem.type = "image/" + url.pathExtension.lowercased() + shareItem.url = self.createSharedFileUrl(url) + default: + print("Unexpected image data:", type(of: data)) + } + return shareItem + } + + override public func viewDidLoad() { + super.viewDidLoad() + + shareItems.removeAll() + + let extensionItem = extensionContext?.inputItems[0] as! NSExtensionItem + Task { + try await withThrowingTaskGroup( + of: ShareItem.self, + body: { taskGroup in + + for (index, attachment) in extensionItem.attachments!.enumerated() { + if attachment.hasItemConformingToTypeIdentifier(kUTTypeURL as String) { + taskGroup.addTask { + return try await self.handleTypeUrl(attachment) + } + } else if attachment.hasItemConformingToTypeIdentifier(kUTTypeText as String) { + taskGroup.addTask { + return try await self.handleTypeText(attachment) + } + } else if attachment.hasItemConformingToTypeIdentifier(kUTTypeMovie as String) { + taskGroup.addTask { + return try await self.handleTypeMovie(attachment) + } + } else if attachment.hasItemConformingToTypeIdentifier(kUTTypeImage as String) { + taskGroup.addTask { + return try await self.handleTypeImage(attachment, index) + } + } + } + + for try await item in taskGroup { + self.shareItems.append(item) + } + }) + + self.sendData() + + } + } + + @objc 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/package.json b/package.json index 713d488b3..0dc96b0fc 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,6 @@ "ci": "^2.1.1", "cordova": "^11.0.0", "cordova-plugin-crop": "^0.4.0", - "cordova-plugin-dbcopy": "git+https://github.com/an-rahulpandey/cordova-plugin-dbcopy.git", "cordova-plugin-document-viewer": "^1.0.0", "cordova-plugin-file": "^6.0.2", "cordova-plugin-file-opener2": "^3.0.5", @@ -307,4 +306,4 @@ "url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git" }, "license": "ISC" -} +} \ No newline at end of file