diff --git a/Example/SendIntentExample/android/capacitor.settings.gradle b/Example/SendIntentExample/android/capacitor.settings.gradle index 4b71878..0937f36 100644 --- a/Example/SendIntentExample/android/capacitor.settings.gradle +++ b/Example/SendIntentExample/android/capacitor.settings.gradle @@ -18,4 +18,4 @@ include ':capacitor-status-bar' project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android') include ':send-intent' -project(':send-intent').projectDir = new File('../node_modules/send-intent/android') +project(':send-intent').projectDir = new File('../../../android') diff --git a/Example/SendIntentExample/ios/App/App.xcodeproj/project.pbxproj b/Example/SendIntentExample/ios/App/App.xcodeproj/project.pbxproj index 966f559..2d66ac0 100644 --- a/Example/SendIntentExample/ios/App/App.xcodeproj/project.pbxproj +++ b/Example/SendIntentExample/ios/App/App.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; 503C1E0C29F85EE90059E6C4 /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; - 503C1E0D29F85EE90059E6C4 /* Pods_App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 503C1E1929F860480059E6C4 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503C1E1829F860480059E6C4 /* ShareViewController.swift */; }; 503C1E1C29F860480059E6C4 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 503C1E1A29F860480059E6C4 /* MainInterface.storyboard */; }; 503C1E2029F860480059E6C4 /* Share.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 503C1E1629F860480059E6C4 /* Share.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -43,17 +42,6 @@ name = "Embed Foundation Extensions"; runOnlyForDeploymentPostprocessing = 0; }; - 503C1E0E29F85EE90059E6C4 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 503C1E0D29F85EE90059E6C4 /* Pods_App.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -192,7 +180,6 @@ 504EC3021FED79650016851F /* Resources */, 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */, 502AF82729F80FC700316C15 /* Embed Foundation Extensions */, - 503C1E0E29F85EE90059E6C4 /* Embed Frameworks */, ); buildRules = ( ); @@ -369,7 +356,7 @@ CODE_SIGN_ENTITLEMENTS = Share/Share.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = W26J2734R6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Share/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Share; @@ -379,7 +366,8 @@ MARKETING_VERSION = 1.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter.Share; + "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--generate-entitlement-der"; + PRODUCT_BUNDLE_IDENTIFIER = carstenklaffke.io.ionic.starter.Share; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -399,7 +387,7 @@ CODE_SIGN_ENTITLEMENTS = Share/Share.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = W26J2734R6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Share/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Share; @@ -408,7 +396,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter.Share; + "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--generate-entitlement-der"; + PRODUCT_BUNDLE_IDENTIFIER = carstenklaffke.io.ionic.starter.Share; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -531,16 +520,19 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = W26J2734R6; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.0; + "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--generate-entitlement-der"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; - PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter; + PRODUCT_BUNDLE_IDENTIFIER = carstenklaffke.io.ionic.starter; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -554,15 +546,18 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = W26J2734R6; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter; + "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--generate-entitlement-der"; + PRODUCT_BUNDLE_IDENTIFIER = carstenklaffke.io.ionic.starter; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/Example/SendIntentExample/ios/App/Podfile b/Example/SendIntentExample/ios/App/Podfile index 98c890a..4cbd268 100644 --- a/Example/SendIntentExample/ios/App/Podfile +++ b/Example/SendIntentExample/ios/App/Podfile @@ -16,7 +16,7 @@ def capacitor_pods pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics' pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard' pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' - pod 'SendIntent', :path => '../../node_modules/send-intent' + pod 'SendIntent', :path => '../../../..' end target 'App' do diff --git a/Example/SendIntentExample/ios/App/Share/Info.plist b/Example/SendIntentExample/ios/App/Share/Info.plist index e17a70f..ecc43f3 100644 --- a/Example/SendIntentExample/ios/App/Share/Info.plist +++ b/Example/SendIntentExample/ios/App/Share/Info.plist @@ -15,21 +15,21 @@ com.apple.share-services NSExtensionActivationRule - - NSExtensionActivationSupportsFileWithMaxCount - 5 - NSExtensionActivationSupportsImageWithMaxCount - 5 - NSExtensionActivationSupportsMovieWithMaxCount - 5 - NSExtensionActivationSupportsText - - NSExtensionActivationSupportsWebPageWithMaxCount - 1 - NSExtensionActivationSupportsWebURLWithMaxCount - 1 - NSExtensionActivationUsesStrictMatching - - + + NSExtensionActivationSupportsFileWithMaxCount + 5 + NSExtensionActivationSupportsImageWithMaxCount + 5 + NSExtensionActivationSupportsMovieWithMaxCount + 5 + NSExtensionActivationSupportsText + + NSExtensionActivationSupportsWebPageWithMaxCount + 1 + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + NSExtensionActivationUsesStrictMatching + + diff --git a/Example/SendIntentExample/ios/App/Share/ShareViewController.swift b/Example/SendIntentExample/ios/App/Share/ShareViewController.swift index d0270e4..0b0a79e 100644 --- a/Example/SendIntentExample/ios/App/Share/ShareViewController.swift +++ b/Example/SendIntentExample/ios/App/Share/ShareViewController.swift @@ -73,21 +73,45 @@ class ShareViewController: UIViewController { } } + func loadUrl(from attachment: NSItemProvider) async throws -> URL? { + return try await withCheckedThrowingContinuation { continuation in + // Hier der Typ URL (NSURL in Objective-C) + attachment.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil) { (urlData, error) in + if let error = error { + continuation.resume(throwing: error) + } else if let url = urlData as? URL { + continuation.resume(returning: url) + } else if let url = urlData as? NSURL { + continuation.resume(returning: url as URL) + } else { + continuation.resume(returning: nil) + } + } + } + } + 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) + if let results = try await loadUrl(from: attachment) { + + + let url = results as! URL? + + + 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" + } } else { - shareItem.title = url!.absoluteString - shareItem.url = url!.absoluteString - shareItem.type = "text/plain" + print("Keine URL gefunden") } return shareItem diff --git a/Example/SendIntentExample/package.json b/Example/SendIntentExample/package.json index 9a6fa9b..c7e2961 100644 --- a/Example/SendIntentExample/package.json +++ b/Example/SendIntentExample/package.json @@ -3,16 +3,16 @@ "version": "0.0.1", "private": true, "dependencies": { - "@capacitor/android": "5.0.0", - "@capacitor/app": "5.0.0", - "@capacitor/core": "5.0.0", - "@capacitor/filesystem": "5.0.0", - "@capacitor/haptics": "5.0.0", - "@capacitor/ios": "5.0.0", - "@capacitor/keyboard": "5.0.0", - "@capacitor/status-bar": "5.0.0", - "@ionic/react": "^7.0.0", - "@ionic/react-router": "^7.0.0", + "@capacitor/android": "6.0.0", + "@capacitor/app": "6.0.0", + "@capacitor/core": "6.0.0", + "@capacitor/filesystem": "6.0.0", + "@capacitor/haptics": "6.0.0", + "@capacitor/ios": "6.0.0", + "@capacitor/keyboard": "6.0.0", + "@capacitor/status-bar": "6.0.0", + "@ionic/react": "^8.2.7", + "@ionic/react-router": "^8.2.7", "@testing-library/jest-dom": "^5.11.9", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^12.6.3", @@ -29,7 +29,7 @@ "react-router": "^5.2.0", "react-router-dom": "^5.2.0", "react-scripts": "^5.0.0", - "send-intent": "^5.0.0", + "send-intent": "6.0.2", "typescript": "^4.1.3", "web-vitals": "^0.2.4", "workbox-background-sync": "^5.1.4", @@ -66,7 +66,7 @@ "iOS >=14" ], "devDependencies": { - "@capacitor/cli": "5.0.0" + "@capacitor/cli": "^6.1.2" }, "description": "An Ionic project" -} \ No newline at end of file +} diff --git a/Example/SendIntentExample/src/pages/Tab1.tsx b/Example/SendIntentExample/src/pages/Tab1.tsx index afe46bb..f1415f9 100644 --- a/Example/SendIntentExample/src/pages/Tab1.tsx +++ b/Example/SendIntentExample/src/pages/Tab1.tsx @@ -12,7 +12,10 @@ const Tab1: React.FC = ({history, location, match}) => { const [result, setResult] = useState(''); async function checkIntent() { + console.log("check intent") return SendIntent.checkSendIntentReceived().then(async (result: any) => { + console.log("checked") + console.log(result) if (result) { console.log('SendIntent received'); let res = JSON.stringify(result); @@ -28,6 +31,7 @@ const Tab1: React.FC = ({history, location, match}) => { checkIntent(); useEffect(() => { + console.log("adding listener") //Check-Intent: Es werden beide Varianten benötigt, mit und ohne Listener. Denn je nachdem wie das share //angesteuert wird lädt die App neu (normaler Aufruf) oder nicht (Listener) window.addEventListener("sendIntentReceived", () => { diff --git a/ios/Sources/SendIntentPlugin/SendIntentPlugin.swift b/ios/Sources/SendIntentPlugin/SendIntentPlugin.swift index 5ff4c0b..12cf421 100644 --- a/ios/Sources/SendIntentPlugin/SendIntentPlugin.swift +++ b/ios/Sources/SendIntentPlugin/SendIntentPlugin.swift @@ -10,7 +10,7 @@ public class SendIntentPlugin: CAPPlugin, CAPBridgedPlugin { public let identifier = "SendIntentPlugin" public let jsName = "SendIntent" public let pluginMethods: [CAPPluginMethod] = [ - CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise) + CAPPluginMethod(name: "checkSendIntentReceived", returnType: CAPPluginReturnPromise) ] private let implementation = SendIntent()