From 634229108cc6ca85b4b825589f87279ef5779fd2 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Fri, 5 Apr 2019 18:00:30 +0200 Subject: [PATCH 01/15] :construction: Add share extension --- .../Base.lproj/MainInterface.storyboard | 24 ++ ios/OpenbookShareExtension/Info.plist | 36 +++ .../ShareViewController.h | 14 + .../ShareViewController.m | 34 +++ ios/Runner.xcodeproj/project.pbxproj | 267 ++++++++++++++++++ 5 files changed, 375 insertions(+) create mode 100644 ios/OpenbookShareExtension/Base.lproj/MainInterface.storyboard create mode 100644 ios/OpenbookShareExtension/Info.plist create mode 100644 ios/OpenbookShareExtension/ShareViewController.h create mode 100644 ios/OpenbookShareExtension/ShareViewController.m diff --git a/ios/OpenbookShareExtension/Base.lproj/MainInterface.storyboard b/ios/OpenbookShareExtension/Base.lproj/MainInterface.storyboard new file mode 100644 index 000000000..589bdd9e7 --- /dev/null +++ b/ios/OpenbookShareExtension/Base.lproj/MainInterface.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/OpenbookShareExtension/Info.plist b/ios/OpenbookShareExtension/Info.plist new file mode 100644 index 000000000..cf8d7559d --- /dev/null +++ b/ios/OpenbookShareExtension/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Openbook + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 0.0.29 + CFBundleVersion + 29 + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + TRUEPREDICATE + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.share-services + + + diff --git a/ios/OpenbookShareExtension/ShareViewController.h b/ios/OpenbookShareExtension/ShareViewController.h new file mode 100644 index 000000000..e5cabfae2 --- /dev/null +++ b/ios/OpenbookShareExtension/ShareViewController.h @@ -0,0 +1,14 @@ +// +// ShareViewController.h +// OpenbookShareExtension +// +// Created by Openbook on 05.04.19. +// Copyright © 2019 Openbook B.V. All rights reserved. +// + +#import +#import + +@interface ShareViewController : SLComposeServiceViewController + +@end diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m new file mode 100644 index 000000000..e87ef2367 --- /dev/null +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -0,0 +1,34 @@ +// +// ShareViewController.m +// OpenbookShareExtension +// +// Created by Openbook on 05.04.19. +// Copyright © 2019 Openbook B.V. All rights reserved. +// + +#import "ShareViewController.h" + +@interface ShareViewController () + +@end + +@implementation ShareViewController + +- (BOOL)isContentValid { + // Do validation of contentText and/or NSExtensionContext attachments here + return YES; +} + +- (void)didSelectPost { + // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. + + // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. + [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil]; +} + +- (NSArray *)configurationItems { + // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. + return @[]; +} + +@end diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index af421a92a..6da9f7b66 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -40,6 +40,9 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + A647F8112257B18C00A31CF1 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A647F8102257B18C00A31CF1 /* ShareViewController.m */; }; + A647F8142257B18C00A31CF1 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A647F8122257B18C00A31CF1 /* MainInterface.storyboard */; }; + A647F8182257B18C00A31CF1 /* OpenbookShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -169,6 +172,13 @@ remoteGlobalIDString = 1CE8375F5D12E4C085E8D4CF09BCD280; remoteInfo = flutter_exif_rotation; }; + A647F8162257B18C00A31CF1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = A647F80C2257B18C00A31CF1; + remoteInfo = OpenbookShareExtension; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -179,6 +189,7 @@ dstSubfolderSpec = 13; files = ( 89ABAE562203425900049DFB /* OneSignalNotificationServiceExtension.appex in Embed App Extensions */, + A647F8182257B18C00A31CF1 /* OpenbookShareExtension.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; @@ -233,6 +244,11 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OpenbookShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + A647F80F2257B18C00A31CF1 /* ShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareViewController.h; sourceTree = ""; }; + A647F8102257B18C00A31CF1 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = ""; }; + A647F8132257B18C00A31CF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + A647F8152257B18C00A31CF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A6C34D3821BE816E00882F1E /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; AAF4B8238CF43C30122544EF /* Pods-OneSignalNotificationServiceExtension.release-production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; sourceTree = ""; }; B23196F4E53E7786037AC8B5 /* Pods-OneSignalNotificationServiceExtension.release-development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; sourceTree = ""; }; @@ -278,6 +294,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A647F80A2257B18C00A31CF1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -373,6 +396,7 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 89ABAE4F2203425900049DFB /* OneSignalNotificationServiceExtension */, + A647F80E2257B18C00A31CF1 /* OpenbookShareExtension */, 97C146EF1CF9000F007C117D /* Products */, 0532A0D3A2BF06AB149735E4 /* Pods */, 5ABC6138995F2182C962F35D /* Frameworks */, @@ -384,6 +408,7 @@ children = ( 97C146EE1CF9000F007C117D /* Runner.app */, 89ABAE4E2203425900049DFB /* OneSignalNotificationServiceExtension.appex */, + A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */, ); name = Products; sourceTree = ""; @@ -415,6 +440,17 @@ name = "Supporting Files"; sourceTree = ""; }; + A647F80E2257B18C00A31CF1 /* OpenbookShareExtension */ = { + isa = PBXGroup; + children = ( + A647F80F2257B18C00A31CF1 /* ShareViewController.h */, + A647F8102257B18C00A31CF1 /* ShareViewController.m */, + A647F8122257B18C00A31CF1 /* MainInterface.storyboard */, + A647F8152257B18C00A31CF1 /* Info.plist */, + ); + path = OpenbookShareExtension; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -455,12 +491,30 @@ ); dependencies = ( 89ABAE552203425900049DFB /* PBXTargetDependency */, + A647F8172257B18C00A31CF1 /* PBXTargetDependency */, ); name = Runner; productName = Runner; productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; }; + A647F80C2257B18C00A31CF1 /* OpenbookShareExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = A647F8342257B18C00A31CF1 /* Build configuration list for PBXNativeTarget "OpenbookShareExtension" */; + buildPhases = ( + A647F8092257B18C00A31CF1 /* Sources */, + A647F80A2257B18C00A31CF1 /* Frameworks */, + A647F80B2257B18C00A31CF1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = OpenbookShareExtension; + productName = OpenbookShareExtension; + productReference = A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -499,6 +553,11 @@ }; }; }; + A647F80C2257B18C00A31CF1 = { + CreatedOnToolsVersion = 10.1; + DevelopmentTeam = GAR7B57RXU; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; @@ -526,6 +585,7 @@ targets = ( 97C146ED1CF9000F007C117D /* Runner */, 89ABAE4D2203425900049DFB /* OneSignalNotificationServiceExtension */, + A647F80C2257B18C00A31CF1 /* OpenbookShareExtension */, ); }; /* End PBXProject section */ @@ -671,6 +731,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A647F80B2257B18C00A31CF1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A647F8142257B18C00A31CF1 /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -799,6 +867,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A647F8092257B18C00A31CF1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A647F8112257B18C00A31CF1 /* ShareViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -807,6 +883,11 @@ target = 89ABAE4D2203425900049DFB /* OneSignalNotificationServiceExtension */; targetProxy = 89ABAE542203425900049DFB /* PBXContainerItemProxy */; }; + A647F8172257B18C00A31CF1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A647F80C2257B18C00A31CF1 /* OpenbookShareExtension */; + targetProxy = A647F8162257B18C00A31CF1 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -826,6 +907,14 @@ name = LaunchScreen.storyboard; sourceTree = ""; }; + A647F8122257B18C00A31CF1 /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A647F8132257B18C00A31CF1 /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -1606,6 +1695,170 @@ }; name = Release; }; + A647F8192257B18C00A31CF1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A647F81A2257B18C00A31CF1 /* Debug-production */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Debug-production"; + }; + A647F81B2257B18C00A31CF1 /* Debug-development */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Debug-development"; + }; + A647F81C2257B18C00A31CF1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + A647F81D2257B18C00A31CF1 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Profile; + }; + A647F81E2257B18C00A31CF1 /* Release-production */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Release-production"; + }; + A647F81F2257B18C00A31CF1 /* Release-development */ = { + isa = XCBuildConfiguration; + buildSettings = { + 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_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = GAR7B57RXU; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = OpenbookShareExtension/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Release-development"; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1651,6 +1904,20 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A647F8342257B18C00A31CF1 /* Build configuration list for PBXNativeTarget "OpenbookShareExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A647F8192257B18C00A31CF1 /* Debug */, + A647F81A2257B18C00A31CF1 /* Debug-production */, + A647F81B2257B18C00A31CF1 /* Debug-development */, + A647F81C2257B18C00A31CF1 /* Release */, + A647F81D2257B18C00A31CF1 /* Profile */, + A647F81E2257B18C00A31CF1 /* Release-production */, + A647F81F2257B18C00A31CF1 /* Release-development */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; From 70a09f7a74f05c3bc56b71fcbbf4e740a16ca758 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Fri, 5 Apr 2019 19:45:04 +0200 Subject: [PATCH 02/15] :construction: Clean up, Change target --- .../ShareViewController.h | 8 ------ .../ShareViewController.m | 22 +++++---------- ios/Runner.xcodeproj/project.pbxproj | 28 +++++++++---------- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/ios/OpenbookShareExtension/ShareViewController.h b/ios/OpenbookShareExtension/ShareViewController.h index e5cabfae2..715dcd7c8 100644 --- a/ios/OpenbookShareExtension/ShareViewController.h +++ b/ios/OpenbookShareExtension/ShareViewController.h @@ -1,11 +1,3 @@ -// -// ShareViewController.h -// OpenbookShareExtension -// -// Created by Openbook on 05.04.19. -// Copyright © 2019 Openbook B.V. All rights reserved. -// - #import #import diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index e87ef2367..8f602ee43 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -1,11 +1,3 @@ -// -// ShareViewController.m -// OpenbookShareExtension -// -// Created by Openbook on 05.04.19. -// Copyright © 2019 Openbook B.V. All rights reserved. -// - #import "ShareViewController.h" @interface ShareViewController () @@ -15,20 +7,20 @@ @interface ShareViewController () @implementation ShareViewController - (BOOL)isContentValid { - // Do validation of contentText and/or NSExtensionContext attachments here - return YES; + // Do validation of contentText and/or NSExtensionContext attachments here + return YES; } - (void)didSelectPost { - // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. + // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. - // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. - [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil]; + // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. + [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil]; } - (NSArray *)configurationItems { - // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. - return @[]; + // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. + return @[]; } @end diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6da9f7b66..8baac7b1a 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -1708,14 +1708,14 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; @@ -1732,14 +1732,14 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = "Debug-production"; }; @@ -1756,14 +1756,14 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = "Debug-development"; }; @@ -1780,13 +1780,13 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; @@ -1803,13 +1803,13 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Profile; }; @@ -1826,13 +1826,13 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = "Release-production"; }; @@ -1849,13 +1849,13 @@ DEVELOPMENT_TEAM = GAR7B57RXU; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = "Release-development"; }; From 1392b8dbcdac19b08e7605ebb0bc70eb14749464 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Fri, 5 Apr 2019 19:46:52 +0200 Subject: [PATCH 03/15] :construction: Set up event channel for sharing --- ios/Runner.xcodeproj/project.pbxproj | 6 +++ ios/Runner/AppDelegate.m | 9 +++- ios/Runner/ReceiveShareStreamHandler.h | 6 +++ ios/Runner/ReceiveShareStreamHandler.m | 50 ++++++++++++++++++++++ lib/plugins/share/receive_share_state.dart | 10 ++--- 5 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 ios/Runner/ReceiveShareStreamHandler.h create mode 100644 ios/Runner/ReceiveShareStreamHandler.m diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8baac7b1a..0238f6fcf 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -43,6 +43,7 @@ A647F8112257B18C00A31CF1 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A647F8102257B18C00A31CF1 /* ShareViewController.m */; }; A647F8142257B18C00A31CF1 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A647F8122257B18C00A31CF1 /* MainInterface.storyboard */; }; A647F8182257B18C00A31CF1 /* OpenbookShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + A647F8362257BB7F00A31CF1 /* ReceiveShareStreamHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A647F8352257BB7F00A31CF1 /* ReceiveShareStreamHandler.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -249,6 +250,8 @@ A647F8102257B18C00A31CF1 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = ""; }; A647F8132257B18C00A31CF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; A647F8152257B18C00A31CF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A647F8352257BB7F00A31CF1 /* ReceiveShareStreamHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReceiveShareStreamHandler.m; sourceTree = ""; }; + A647F8372257BBA700A31CF1 /* ReceiveShareStreamHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReceiveShareStreamHandler.h; sourceTree = ""; }; A6C34D3821BE816E00882F1E /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; AAF4B8238CF43C30122544EF /* Pods-OneSignalNotificationServiceExtension.release-production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; sourceTree = ""; }; B23196F4E53E7786037AC8B5 /* Pods-OneSignalNotificationServiceExtension.release-development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; sourceTree = ""; }; @@ -422,6 +425,8 @@ 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 97C147021CF9000F007C117D /* Info.plist */, 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + A647F8372257BBA700A31CF1 /* ReceiveShareStreamHandler.h */, + A647F8352257BB7F00A31CF1 /* ReceiveShareStreamHandler.m */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -863,6 +868,7 @@ files = ( 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 97C146F31CF9000F007C117D /* main.m in Sources */, + A647F8362257BB7F00A31CF1 /* ReceiveShareStreamHandler.m in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index 00f589066..f5883ea0e 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -1,12 +1,19 @@ #include "AppDelegate.h" #include "GeneratedPluginRegistrant.h" +#import "ReceiveShareStreamHandler.h" #import +#import -@implementation AppDelegate +@implementation AppDelegate { + ReceiveShareStreamHandler* _receiveShareStreamHandler; +} - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GeneratedPluginRegistrant registerWithRegistry:self]; + + FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController; + _receiveShareStreamHandler = [ReceiveShareStreamHandler receiveShareStreamHandlerWithController: controller]; // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } diff --git a/ios/Runner/ReceiveShareStreamHandler.h b/ios/Runner/ReceiveShareStreamHandler.h new file mode 100644 index 000000000..95c893996 --- /dev/null +++ b/ios/Runner/ReceiveShareStreamHandler.h @@ -0,0 +1,6 @@ +#import + +@interface ReceiveShareStreamHandler : NSObject ++ (id)receiveShareStreamHandlerWithController:(FlutterViewController*)controller; +- (void)sendEventWithShare:(id)share; +@end diff --git a/ios/Runner/ReceiveShareStreamHandler.m b/ios/Runner/ReceiveShareStreamHandler.m new file mode 100644 index 000000000..4cc18922d --- /dev/null +++ b/ios/Runner/ReceiveShareStreamHandler.m @@ -0,0 +1,50 @@ +#import "ReceiveShareStreamHandler.h" +#import + +const NSString* CHANNEL_NAME = @"openbook.social/receive_share"; + +@implementation ReceiveShareStreamHandler { + FlutterEventChannel* _channel; + FlutterEventSink _eventSink; + BOOL _streamCanceled; + NSMutableArray* _shareBacklog; +} + ++ (id)receiveShareStreamHandlerWithController:(FlutterViewController *)controller { + FlutterEventChannel* sharingChannel = [FlutterEventChannel + eventChannelWithName: CHANNEL_NAME + binaryMessenger: controller]; + return [[ReceiveShareStreamHandler alloc] initWithChannel:sharingChannel]; +} + +- (id)initWithChannel:(FlutterEventChannel*)channel { + self = [super init]; + if (self) { + _channel = channel; + _shareBacklog = [NSMutableArray arrayWithCapacity:1]; + [_channel setStreamHandler:self]; + } + return self; +} + +- (FlutterError*)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)events { + _eventSink = events; + _streamCanceled = NO; + while ([_shareBacklog count] > 0) { + id share = _shareBacklog[0]; + [_shareBacklog removeObjectAtIndex:0]; + [self sendEventWithShare:share]; + } + return nil; +} + +- (FlutterError*)onCancelWithArguments:(id)arguments { + _eventSink = nil; + _streamCanceled = YES; + return nil; +} + +- (void)sendEventWithShare:(id)share { + // TODO +} +@end diff --git a/lib/plugins/share/receive_share_state.dart b/lib/plugins/share/receive_share_state.dart index f30363345..7c36a8f37 100644 --- a/lib/plugins/share/receive_share_state.dart +++ b/lib/plugins/share/receive_share_state.dart @@ -12,12 +12,10 @@ abstract class ReceiveShareState extends State { StreamSubscription shareReceiveSubscription = null; void enableSharing() { - if(Platform.isAndroid){ - if (shareReceiveSubscription == null) { - shareReceiveSubscription = - stream.receiveBroadcastStream().listen(_onReceiveShare); - debugPrint("enabled share receiving"); - } + if (shareReceiveSubscription == null) { + shareReceiveSubscription = + stream.receiveBroadcastStream().listen(_onReceiveShare); + debugPrint("enabled share receiving"); } } From 3fa0c557532ec71bfcc3b408e29ca51a05eac18c Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Fri, 5 Apr 2019 21:33:23 +0200 Subject: [PATCH 04/15] :construction: Add entitlements for app group --- .../OpenbookShareExtension.entitlements | 10 ++++++++++ ios/Runner.xcodeproj/project.pbxproj | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 ios/OpenbookShareExtension/OpenbookShareExtension.entitlements diff --git a/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements b/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements new file mode 100644 index 000000000..91e6019f4 --- /dev/null +++ b/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.social.openbook.app + + + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 0238f6fcf..857de86f1 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -252,6 +252,7 @@ A647F8152257B18C00A31CF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A647F8352257BB7F00A31CF1 /* ReceiveShareStreamHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReceiveShareStreamHandler.m; sourceTree = ""; }; A647F8372257BBA700A31CF1 /* ReceiveShareStreamHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReceiveShareStreamHandler.h; sourceTree = ""; }; + A647F8382257D37A00A31CF1 /* OpenbookShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OpenbookShareExtension.entitlements; sourceTree = ""; }; A6C34D3821BE816E00882F1E /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; AAF4B8238CF43C30122544EF /* Pods-OneSignalNotificationServiceExtension.release-production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; sourceTree = ""; }; B23196F4E53E7786037AC8B5 /* Pods-OneSignalNotificationServiceExtension.release-development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; sourceTree = ""; }; @@ -448,6 +449,7 @@ A647F80E2257B18C00A31CF1 /* OpenbookShareExtension */ = { isa = PBXGroup; children = ( + A647F8382257D37A00A31CF1 /* OpenbookShareExtension.entitlements */, A647F80F2257B18C00A31CF1 /* ShareViewController.h */, A647F8102257B18C00A31CF1 /* ShareViewController.m */, A647F8122257B18C00A31CF1 /* MainInterface.storyboard */, @@ -562,6 +564,11 @@ CreatedOnToolsVersion = 10.1; DevelopmentTeam = GAR7B57RXU; ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; + }; }; }; }; @@ -1709,6 +1716,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1733,6 +1741,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1757,6 +1766,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1781,6 +1791,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1804,6 +1815,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1827,6 +1839,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1850,6 +1863,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; From 728b3d4b9e8d5375e7ae7f2dbb8ba830a3391890 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Fri, 5 Apr 2019 22:03:40 +0200 Subject: [PATCH 05/15] :ambulance: Fix merge --- lib/plugins/share/receive_share_state.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/plugins/share/receive_share_state.dart b/lib/plugins/share/receive_share_state.dart index b35aab30e..cbc183e64 100644 --- a/lib/plugins/share/receive_share_state.dart +++ b/lib/plugins/share/receive_share_state.dart @@ -15,7 +15,6 @@ abstract class ReceiveShareState extends State { if (shareReceiveSubscription == null) { shareReceiveSubscription = stream.receiveBroadcastStream().listen(_onReceiveShare); - debugPrint("enabled share receiving") } } From 07a49912d5f7f6c61c1a4acb834424cfd77e85c5 Mon Sep 17 00:00:00 2001 From: Joel Hernandez Date: Fri, 5 Apr 2019 21:53:16 +0200 Subject: [PATCH 06/15] Revert ":construction: Add entitlements for app group" This reverts commit 3fa0c557532ec71bfcc3b408e29ca51a05eac18c. --- .../OpenbookShareExtension.entitlements | 10 ---------- ios/Runner.xcodeproj/project.pbxproj | 14 -------------- 2 files changed, 24 deletions(-) delete mode 100644 ios/OpenbookShareExtension/OpenbookShareExtension.entitlements diff --git a/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements b/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements deleted file mode 100644 index 91e6019f4..000000000 --- a/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.application-groups - - group.social.openbook.app - - - diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 42cf218d9..4129d02c9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -252,7 +252,6 @@ A647F8152257B18C00A31CF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A647F8352257BB7F00A31CF1 /* ReceiveShareStreamHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReceiveShareStreamHandler.m; sourceTree = ""; }; A647F8372257BBA700A31CF1 /* ReceiveShareStreamHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReceiveShareStreamHandler.h; sourceTree = ""; }; - A647F8382257D37A00A31CF1 /* OpenbookShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OpenbookShareExtension.entitlements; sourceTree = ""; }; A6C34D3821BE816E00882F1E /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; AAF4B8238CF43C30122544EF /* Pods-OneSignalNotificationServiceExtension.release-production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-production.xcconfig"; sourceTree = ""; }; B23196F4E53E7786037AC8B5 /* Pods-OneSignalNotificationServiceExtension.release-development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release-development.xcconfig"; sourceTree = ""; }; @@ -449,7 +448,6 @@ A647F80E2257B18C00A31CF1 /* OpenbookShareExtension */ = { isa = PBXGroup; children = ( - A647F8382257D37A00A31CF1 /* OpenbookShareExtension.entitlements */, A647F80F2257B18C00A31CF1 /* ShareViewController.h */, A647F8102257B18C00A31CF1 /* ShareViewController.m */, A647F8122257B18C00A31CF1 /* MainInterface.storyboard */, @@ -564,11 +562,6 @@ CreatedOnToolsVersion = 10.1; DevelopmentTeam = GAR7B57RXU; ProvisioningStyle = Automatic; - SystemCapabilities = { - com.apple.ApplicationGroups.iOS = { - enabled = 1; - }; - }; }; }; }; @@ -1716,7 +1709,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1741,7 +1733,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1766,7 +1757,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1791,7 +1781,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1815,7 +1804,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1839,7 +1827,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; @@ -1863,7 +1850,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; From 20c36c788c6c9677a70fc1b75f1f6e74f062f931 Mon Sep 17 00:00:00 2001 From: Joel Hernandez Date: Fri, 5 Apr 2019 22:15:07 +0200 Subject: [PATCH 07/15] :bug: update entitlements/bitcode/linked frameworks --- .../OpenbookShareExtension.entitlements | 11 ++ ios/Runner.xcodeproj/project.pbxproj | 106 +++++++++++++----- 2 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 ios/OpenbookShareExtension/OpenbookShareExtension.entitlements diff --git a/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements b/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements new file mode 100644 index 000000000..d98b46816 --- /dev/null +++ b/ios/OpenbookShareExtension/OpenbookShareExtension.entitlements @@ -0,0 +1,11 @@ + + + + + com.apple.security.application-groups + + group.social.openbook.app + group.social.openbook.app.onesignal + + + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 4129d02c9..78cfe7dac 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -17,6 +17,20 @@ 8902A1082236D5BF005F914D /* libintercom_flutter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8902A1062236D5BF005F914D /* libintercom_flutter.a */; }; 8902A1092236D5BF005F914D /* libsqflite.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8928E32022356450001DB32A /* libsqflite.a */; }; 8925094F222F0E0900455D87 /* libdevice_info.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8925094A222F0E0900455D87 /* libdevice_info.a */; }; + 89416F7A2257ECCB00896B34 /* libdevice_info.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8925094A222F0E0900455D87 /* libdevice_info.a */; }; + 89416F7B2257ECCB00896B34 /* libflutter_exif_rotation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 89CF474422419BFD001BC50D /* libflutter_exif_rotation.a */; }; + 89416F7C2257ECCB00896B34 /* libflutter_secure_storage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8980539E22047AAF00E47AD9 /* libflutter_secure_storage.a */; }; + 89416F7E2257ECCB00896B34 /* libimage_cropper.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053A022047AAF00E47AD9 /* libimage_cropper.a */; }; + 89416F7F2257ECCB00896B34 /* libimage_picker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053A222047AAF00E47AD9 /* libimage_picker.a */; }; + 89416F802257ECCB00896B34 /* libintercom_flutter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8902A1062236D5BF005F914D /* libintercom_flutter.a */; }; + 89416F812257ECCB00896B34 /* libonesignal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053A422047AAF00E47AD9 /* libonesignal.a */; }; + 89416F822257ECCB00896B34 /* libpath_provider.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053A622047AAF00E47AD9 /* libpath_provider.a */; }; + 89416F852257ECCB00896B34 /* libsqflite.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8928E32022356450001DB32A /* libsqflite.a */; }; + 89416F862257ECCB00896B34 /* libTOCropViewController.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053AE22047AAF00E47AD9 /* libTOCropViewController.a */; }; + 89416F872257ECCB00896B34 /* libuni_links.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053B222047AAF00E47AD9 /* libuni_links.a */; }; + 89416F882257ECCB00896B34 /* liburl_launcher.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053B422047AAF00E47AD9 /* liburl_launcher.a */; }; + 89416F892257ECCB00896B34 /* libvideo_player.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053B622047AAF00E47AD9 /* libvideo_player.a */; }; + 89416F9F2257EE3C00896B34 /* libFMDB.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8928E31E22356450001DB32A /* libFMDB.a */; }; 898053B722047AD000E47AD9 /* libflutter_secure_storage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8980539E22047AAF00E47AD9 /* libflutter_secure_storage.a */; }; 898053B822047AD000E47AD9 /* libimage_cropper.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053A022047AAF00E47AD9 /* libimage_cropper.a */; }; 898053B922047AD000E47AD9 /* libimage_picker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 898053A222047AAF00E47AD9 /* libimage_picker.a */; }; @@ -42,7 +56,7 @@ 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; A647F8112257B18C00A31CF1 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A647F8102257B18C00A31CF1 /* ShareViewController.m */; }; A647F8142257B18C00A31CF1 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A647F8122257B18C00A31CF1 /* MainInterface.storyboard */; }; - A647F8182257B18C00A31CF1 /* OpenbookShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + A647F8182257B18C00A31CF1 /* OpenbookSharingExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A647F80D2257B18C00A31CF1 /* OpenbookSharingExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; A647F8362257BB7F00A31CF1 /* ReceiveShareStreamHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A647F8352257BB7F00A31CF1 /* ReceiveShareStreamHandler.m */; }; /* End PBXBuildFile section */ @@ -190,7 +204,7 @@ dstSubfolderSpec = 13; files = ( 89ABAE562203425900049DFB /* OneSignalNotificationServiceExtension.appex in Embed App Extensions */, - A647F8182257B18C00A31CF1 /* OpenbookShareExtension.appex in Embed App Extensions */, + A647F8182257B18C00A31CF1 /* OpenbookSharingExtension.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; @@ -234,6 +248,7 @@ 89ABAE502203425900049DFB /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = ""; }; 89ABAE512203425900049DFB /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = ""; }; 89ABAE532203425900049DFB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 89D66D132257E9C4005EA600 /* OpenbookShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OpenbookShareExtension.entitlements; sourceTree = ""; }; 89DBC2DD2203430700F80685 /* OneSignalNotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OneSignalNotificationServiceExtension.entitlements; sourceTree = ""; }; 970D6175355421F353EA64C9 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; @@ -245,7 +260,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OpenbookShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + A647F80D2257B18C00A31CF1 /* OpenbookSharingExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OpenbookSharingExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; A647F80F2257B18C00A31CF1 /* ShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareViewController.h; sourceTree = ""; }; A647F8102257B18C00A31CF1 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = ""; }; A647F8132257B18C00A31CF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; @@ -301,6 +316,20 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 89416F9F2257EE3C00896B34 /* libFMDB.a in Frameworks */, + 89416F7A2257ECCB00896B34 /* libdevice_info.a in Frameworks */, + 89416F7B2257ECCB00896B34 /* libflutter_exif_rotation.a in Frameworks */, + 89416F7C2257ECCB00896B34 /* libflutter_secure_storage.a in Frameworks */, + 89416F7E2257ECCB00896B34 /* libimage_cropper.a in Frameworks */, + 89416F7F2257ECCB00896B34 /* libimage_picker.a in Frameworks */, + 89416F802257ECCB00896B34 /* libintercom_flutter.a in Frameworks */, + 89416F812257ECCB00896B34 /* libonesignal.a in Frameworks */, + 89416F822257ECCB00896B34 /* libpath_provider.a in Frameworks */, + 89416F852257ECCB00896B34 /* libsqflite.a in Frameworks */, + 89416F862257ECCB00896B34 /* libTOCropViewController.a in Frameworks */, + 89416F872257ECCB00896B34 /* libuni_links.a in Frameworks */, + 89416F882257ECCB00896B34 /* liburl_launcher.a in Frameworks */, + 89416F892257ECCB00896B34 /* libvideo_player.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -411,7 +440,7 @@ children = ( 97C146EE1CF9000F007C117D /* Runner.app */, 89ABAE4E2203425900049DFB /* OneSignalNotificationServiceExtension.appex */, - A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */, + A647F80D2257B18C00A31CF1 /* OpenbookSharingExtension.appex */, ); name = Products; sourceTree = ""; @@ -448,6 +477,7 @@ A647F80E2257B18C00A31CF1 /* OpenbookShareExtension */ = { isa = PBXGroup; children = ( + 89D66D132257E9C4005EA600 /* OpenbookShareExtension.entitlements */, A647F80F2257B18C00A31CF1 /* ShareViewController.h */, A647F8102257B18C00A31CF1 /* ShareViewController.m */, A647F8122257B18C00A31CF1 /* MainInterface.storyboard */, @@ -503,9 +533,9 @@ productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; }; - A647F80C2257B18C00A31CF1 /* OpenbookShareExtension */ = { + A647F80C2257B18C00A31CF1 /* OpenbookSharingExtension */ = { isa = PBXNativeTarget; - buildConfigurationList = A647F8342257B18C00A31CF1 /* Build configuration list for PBXNativeTarget "OpenbookShareExtension" */; + buildConfigurationList = A647F8342257B18C00A31CF1 /* Build configuration list for PBXNativeTarget "OpenbookSharingExtension" */; buildPhases = ( A647F8092257B18C00A31CF1 /* Sources */, A647F80A2257B18C00A31CF1 /* Frameworks */, @@ -515,9 +545,9 @@ ); dependencies = ( ); - name = OpenbookShareExtension; + name = OpenbookSharingExtension; productName = OpenbookShareExtension; - productReference = A647F80D2257B18C00A31CF1 /* OpenbookShareExtension.appex */; + productReference = A647F80D2257B18C00A31CF1 /* OpenbookSharingExtension.appex */; productType = "com.apple.product-type.app-extension"; }; /* End PBXNativeTarget section */ @@ -562,6 +592,11 @@ CreatedOnToolsVersion = 10.1; DevelopmentTeam = GAR7B57RXU; ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; + }; }; }; }; @@ -590,7 +625,7 @@ targets = ( 97C146ED1CF9000F007C117D /* Runner */, 89ABAE4D2203425900049DFB /* OneSignalNotificationServiceExtension */, - A647F80C2257B18C00A31CF1 /* OpenbookShareExtension */, + A647F80C2257B18C00A31CF1 /* OpenbookSharingExtension */, ); }; /* End PBXProject section */ @@ -891,7 +926,7 @@ }; A647F8172257B18C00A31CF1 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = A647F80C2257B18C00A31CF1 /* OpenbookShareExtension */; + target = A647F80C2257B18C00A31CF1 /* OpenbookSharingExtension */; targetProxy = A647F8162257B18C00A31CF1 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -1709,19 +1744,22 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -1733,19 +1771,22 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = "Debug-production"; }; @@ -1757,19 +1798,22 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = "Debug-development"; }; @@ -1781,18 +1825,21 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -1804,18 +1851,21 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Profile; }; @@ -1827,18 +1877,21 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = "Release-production"; }; @@ -1850,18 +1903,21 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = OpenbookShareExtension/OpenbookShareExtension.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GAR7B57RXU; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OpenbookShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookShareExtension; + PRODUCT_BUNDLE_IDENTIFIER = social.openbook.app.OpenbookSharingExtension; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = "Release-development"; }; @@ -1910,7 +1966,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - A647F8342257B18C00A31CF1 /* Build configuration list for PBXNativeTarget "OpenbookShareExtension" */ = { + A647F8342257B18C00A31CF1 /* Build configuration list for PBXNativeTarget "OpenbookSharingExtension" */ = { isa = XCConfigurationList; buildConfigurations = ( A647F8192257B18C00A31CF1 /* Debug */, From 8ef577ab358a588bfab061abd55381e697c8fad8 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sat, 6 Apr 2019 00:21:22 +0200 Subject: [PATCH 08/15] :construction: Implement shared container and URL opening --- .../ShareViewController.m | 61 ++++++++++++++++++- ios/Runner/AppDelegate.m | 1 + ios/Runner/Info.plist | 11 ++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index 8f602ee43..3af9601ae 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -1,5 +1,7 @@ #import "ShareViewController.h" +const NSString* APP_GROUP_NAME = @"group.social.openbook.app"; + @interface ShareViewController () @end @@ -11,9 +13,66 @@ - (BOOL)isContentValid { return YES; } +- (NSString*)getTempDir { + NSFileManager* manager = [NSFileManager defaultManager]; + NSString* tempDir = [[[manager containerURLForSecurityApplicationGroupIdentifier:APP_GROUP_NAME] path] stringByAppendingPathComponent:@"tmp"]; + + BOOL isDir; + NSError* error = nil; + + if (![manager fileExistsAtPath:tempDir isDirectory:&isDir]) { + if (![manager createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:&error]) { + // TODO: handle error + } + } + + return tempDir; +} + +- (NSString*) getTempFileWithExtension:(NSString*)extension { + NSString* fileName = [[NSUUID UUID] UUIDString]; + NSString* tempFile = [fileName stringByAppendingPathExtension:extension]; + + return tempFile; +} + +- (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { + NSURL* url = [[NSURL URLWithString:@"openbook://share"] URLByAppendingPathComponent:fileName]; + SEL selectorOpenURL = sel_registerName("openURL:"); + NSExtensionContext* context = self.extensionContext; + [context openURL:url completionHandler:nil]; + + UIResponder* responder = (UIResponder*)self; + while (responder != nil) { + if ([responder respondsToSelector:selectorOpenURL]) { + [responder performSelector:selectorOpenURL withObject:url]; + } + responder = responder.nextResponder; + } +} + - (void)didSelectPost { // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. - + NSFileManager* manager = [NSFileManager defaultManager]; + NSExtensionContext* context = self.extensionContext; + NSArray* images = context.inputItems; + NSString* tempPath = [self getTempDir]; + NSString* fileName = [self getTempFileWithExtension:@"jpg"]; + // TODO: write image to file + + // As we have to communicate text and an image to the app, write everything to a file instead of putting everything in an URL. + NSMutableDictionary* args = [[NSMutableDictionary alloc] init]; + args[@"text"] = self.contentText; + args[@"path"] = [tempPath stringByAppendingPathComponent:fileName]; + NSError* error; + NSData* jsonData = [NSJSONSerialization dataWithJSONObject:args options:0 error:&error]; + // TODO: handle error + NSString* jsonFile = [self getTempFileWithExtension:@"json"]; + if (![manager createFileAtPath:[tempPath stringByAppendingPathComponent:jsonFile] contents:jsonData attributes:nil]) { + // TODO: handle error + } + // call main app + [self callOpenbookAppWithSharedFileName:jsonFile]; // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil]; } diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index f5883ea0e..50564705a 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -14,6 +14,7 @@ - (BOOL)application:(UIApplication *)application FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController; _receiveShareStreamHandler = [ReceiveShareStreamHandler receiveShareStreamHandlerWithController: controller]; + // TODO: handle URL opening // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 9c3653b0c..7aba76c1b 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -22,6 +22,17 @@ ???? CFBundleVersion 29 + CFBundleURLTypes + + + CFBundleURLName + social.openbook.app.scheme.openbook + CFBundleURLSchemes + + openbook + + + ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS From 3c5ad6bbde67f374edacbc7b848bbbec78eda5ee Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sat, 6 Apr 2019 09:43:27 +0200 Subject: [PATCH 09/15] :art: Use non-deprecated method for opening URL --- .../ShareViewController.m | 21 +++++++++++++------ ios/Runner/AppDelegate.m | 9 +++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index 3af9601ae..308362705 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -38,16 +38,25 @@ - (NSString*) getTempFileWithExtension:(NSString*)extension { - (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { NSURL* url = [[NSURL URLWithString:@"openbook://share"] URLByAppendingPathComponent:fileName]; - SEL selectorOpenURL = sel_registerName("openURL:"); - NSExtensionContext* context = self.extensionContext; - [context openURL:url completionHandler:nil]; + SEL selectorOpenURL = NSSelectorFromString(@"openURL:options:completionHandler:"); UIResponder* responder = (UIResponder*)self; - while (responder != nil) { + while ((responder = [responder nextResponder]) != nil) { if ([responder respondsToSelector:selectorOpenURL]) { - [responder performSelector:selectorOpenURL withObject:url]; + NSMethodSignature* signature = [responder methodSignatureForSelector:selectorOpenURL]; + NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature]; + NSDictionary* options = [NSDictionary dictionary]; + void (^completion)(BOOL success) = ^void(BOOL success) { + NSLog(@"completion for openURL: %i", success); + }; + [invocation setTarget:responder]; + [invocation setSelector:selectorOpenURL]; + [invocation setArgument:&url atIndex:2]; + [invocation setArgument:&options atIndex:3]; + [invocation setArgument:&completion atIndex:4]; + [invocation invoke]; + break; } - responder = responder.nextResponder; } } diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index 50564705a..263a06ca9 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -14,7 +14,6 @@ - (BOOL)application:(UIApplication *)application FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController; _receiveShareStreamHandler = [ReceiveShareStreamHandler receiveShareStreamHandlerWithController: controller]; - // TODO: handle URL opening // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @@ -23,4 +22,12 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserAct return [[UniLinksPlugin sharedInstance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; } +- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { + + if ([url.scheme isEqualToString:@"openbook"]) { + NSLog(@"Handling openURL: %@", [url absoluteString]); + } + return [super application:app openURL:url options:options]; +} + @end From 21913eb04d0d275287b007e98bb42e0de4a74aa5 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sat, 6 Apr 2019 10:01:53 +0200 Subject: [PATCH 10/15] :sparkles: Implement sharing in the app --- ios/Runner/AppDelegate.m | 4 ++++ ios/Runner/ReceiveShareStreamHandler.h | 2 +- ios/Runner/ReceiveShareStreamHandler.m | 24 +++++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index 263a06ca9..be5ddcaac 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -26,6 +26,10 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction if ([url.scheme isEqualToString:@"openbook"]) { NSLog(@"Handling openURL: %@", [url absoluteString]); + if ([url.host isEqualToString:@"share"]) { + NSArray* components = [url pathComponents]; + [_receiveShareStreamHandler sendShareFromFile:components[1]]; + } } return [super application:app openURL:url options:options]; } diff --git a/ios/Runner/ReceiveShareStreamHandler.h b/ios/Runner/ReceiveShareStreamHandler.h index 95c893996..9d3da7a7c 100644 --- a/ios/Runner/ReceiveShareStreamHandler.h +++ b/ios/Runner/ReceiveShareStreamHandler.h @@ -2,5 +2,5 @@ @interface ReceiveShareStreamHandler : NSObject + (id)receiveShareStreamHandlerWithController:(FlutterViewController*)controller; -- (void)sendEventWithShare:(id)share; +- (void)sendShareFromFile:(NSString*)fileName; @end diff --git a/ios/Runner/ReceiveShareStreamHandler.m b/ios/Runner/ReceiveShareStreamHandler.m index 4cc18922d..cd2962130 100644 --- a/ios/Runner/ReceiveShareStreamHandler.m +++ b/ios/Runner/ReceiveShareStreamHandler.m @@ -2,12 +2,13 @@ #import const NSString* CHANNEL_NAME = @"openbook.social/receive_share"; +const NSString* APP_GROUP_NAME = @"group.social.openbook.app"; @implementation ReceiveShareStreamHandler { FlutterEventChannel* _channel; FlutterEventSink _eventSink; BOOL _streamCanceled; - NSMutableArray* _shareBacklog; + NSMutableArray* _shareBacklog; } + (id)receiveShareStreamHandlerWithController:(FlutterViewController *)controller { @@ -31,9 +32,9 @@ - (FlutterError*)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink _eventSink = events; _streamCanceled = NO; while ([_shareBacklog count] > 0) { - id share = _shareBacklog[0]; + NSString* shareFile = _shareBacklog[0]; [_shareBacklog removeObjectAtIndex:0]; - [self sendEventWithShare:share]; + [self sendShareFromFile:shareFile]; } return nil; } @@ -44,7 +45,20 @@ - (FlutterError*)onCancelWithArguments:(id)arguments { return nil; } -- (void)sendEventWithShare:(id)share { - // TODO +- (void)sendShareFromFile:(NSString*)fileName { + if (_eventSink == nil) { + if (!_streamCanceled && ![_shareBacklog containsObject:fileName]) { + [_shareBacklog addObject:fileName]; + } + return; + } + + NSFileManager* manager = [NSFileManager defaultManager]; + NSString* tempDir = [[[manager containerURLForSecurityApplicationGroupIdentifier:APP_GROUP_NAME] path] stringByAppendingPathComponent:@"tmp"]; + NSString* fullFileName = [tempDir stringByAppendingPathComponent:fileName]; + NSError* error; + NSDictionary* args = [NSJSONSerialization JSONObjectWithData:[manager contentsAtPath:fullFileName] options:0 error: &error]; + // TODO: handle error + _eventSink(args); } @end From 98cd1687a89e69d005859a46c159d7f85e54dc87 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sat, 6 Apr 2019 10:54:23 +0200 Subject: [PATCH 11/15] :sparkles: Finish implementation of share extension --- .../ShareViewController.m | 56 ++++++++++++++----- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index 308362705..d32cd0c2e 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -60,22 +60,12 @@ - (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { } } -- (void)didSelectPost { - // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. +- (void)callOpenbookAppWithData:(NSDictionary*)data { NSFileManager* manager = [NSFileManager defaultManager]; - NSExtensionContext* context = self.extensionContext; - NSArray* images = context.inputItems; - NSString* tempPath = [self getTempDir]; - NSString* fileName = [self getTempFileWithExtension:@"jpg"]; - // TODO: write image to file - - // As we have to communicate text and an image to the app, write everything to a file instead of putting everything in an URL. - NSMutableDictionary* args = [[NSMutableDictionary alloc] init]; - args[@"text"] = self.contentText; - args[@"path"] = [tempPath stringByAppendingPathComponent:fileName]; NSError* error; - NSData* jsonData = [NSJSONSerialization dataWithJSONObject:args options:0 error:&error]; + NSData* jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:&error]; // TODO: handle error + NSString* tempPath = [self getTempDir]; NSString* jsonFile = [self getTempFileWithExtension:@"json"]; if (![manager createFileAtPath:[tempPath stringByAppendingPathComponent:jsonFile] contents:jsonData attributes:nil]) { // TODO: handle error @@ -86,6 +76,46 @@ - (void)didSelectPost { [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil]; } +- (void)didSelectPost { + // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. + NSFileManager* manager = [NSFileManager defaultManager]; + NSExtensionContext* context = self.extensionContext; + // As we have to communicate text and an image to the app, write everything to a file instead of putting everything in an URL. + NSMutableDictionary* args = [[NSMutableDictionary alloc] init]; + args[@"text"] = self.contentText; + // Handle an image + BOOL hasCallback = NO; + NSArray* items = context.inputItems; + if ([items count] >= 1) { + NSExtensionItem* item = items[0]; + if ([item.attachments count] >= 1) { + NSItemProvider* itemProvider = item.attachments[0]; + if ([itemProvider hasItemConformingToTypeIdentifier:@"public.image"]) { + hasCallback = YES; + [itemProvider loadItemForTypeIdentifier:@"public.image" options:nil completionHandler:^void(UIImage* image, NSError* error) { + // TODO: handle error + NSData* imageData = UIImageJPEGRepresentation(image, 1.0); + if (imageData == nil){ + // TODO: handle error + } + NSString* tempPath = [self getTempDir]; + NSString* fileName = [self getTempFileWithExtension:@"jpg"]; + if (![manager createFileAtPath:[tempPath stringByAppendingPathComponent:fileName] contents:imageData attributes:nil]) { + // TODO: handle error + } + args[@"path"] = [tempPath stringByAppendingPathComponent:fileName]; + [self callOpenbookAppWithData:args]; + }]; + } + } + } + + // If we have a callback (when loading an image), do not immediately open the app, that will happen in the callback + if (!hasCallback) { + [self callOpenbookAppWithData:args]; + } +} + - (NSArray *)configurationItems { // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. return @[]; From 86e899cd5c1fe0cf65cf64cc9e29f64264d10ff8 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Mon, 8 Apr 2019 17:10:59 +0200 Subject: [PATCH 12/15] :loud_sound: Add debug logging --- ios/OpenbookShareExtension/ShareViewController.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index d32cd0c2e..bc3b21ff5 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -38,6 +38,7 @@ - (NSString*) getTempFileWithExtension:(NSString*)extension { - (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { NSURL* url = [[NSURL URLWithString:@"openbook://share"] URLByAppendingPathComponent:fileName]; + NSLog(@"Opening URL: %@", url); SEL selectorOpenURL = NSSelectorFromString(@"openURL:options:completionHandler:"); UIResponder* responder = (UIResponder*)self; @@ -58,6 +59,9 @@ - (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { break; } } + if (responder == nil) { + NSLog(@"Warning: No responder found to open URL"); + } } - (void)callOpenbookAppWithData:(NSDictionary*)data { @@ -104,8 +108,11 @@ - (void)didSelectPost { // TODO: handle error } args[@"path"] = [tempPath stringByAppendingPathComponent:fileName]; + NSLog(@"image written to %@, opening app", args[@"path"]); [self callOpenbookAppWithData:args]; }]; + } else { + NSLog(@"No UTI public.image found, ignoring attachment"); } } } From 56ca9535e782ee49d6ceb7bd03df3d40b9360878 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Thu, 11 Apr 2019 21:24:05 +0200 Subject: [PATCH 13/15] =?UTF-8?q?=F0=9F=94=96=20Update=20version=20accordi?= =?UTF-8?q?ng=20to=20Runner=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/OpenbookShareExtension/Info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/OpenbookShareExtension/Info.plist b/ios/OpenbookShareExtension/Info.plist index cf8d7559d..020e6504e 100644 --- a/ios/OpenbookShareExtension/Info.plist +++ b/ios/OpenbookShareExtension/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 0.0.29 + 0.0.34 CFBundleVersion - 29 + 34 NSExtension NSExtensionAttributes From b174ea8cb5fe637ecd70672bb001c553ebd2539e Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sat, 13 Apr 2019 15:31:35 +0200 Subject: [PATCH 14/15] :recycle: Change openURL call in share extension --- ios/OpenbookShareExtension/ShareViewController.m | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index bc3b21ff5..a9ff0b871 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -39,23 +39,13 @@ - (NSString*) getTempFileWithExtension:(NSString*)extension { - (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { NSURL* url = [[NSURL URLWithString:@"openbook://share"] URLByAppendingPathComponent:fileName]; NSLog(@"Opening URL: %@", url); - SEL selectorOpenURL = NSSelectorFromString(@"openURL:options:completionHandler:"); + SEL selectorOpenURL = NSSelectorFromString(@"openURL:"); + [self.extensionContext openURL:url completionHandler:nil]; UIResponder* responder = (UIResponder*)self; while ((responder = [responder nextResponder]) != nil) { if ([responder respondsToSelector:selectorOpenURL]) { - NSMethodSignature* signature = [responder methodSignatureForSelector:selectorOpenURL]; - NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature]; - NSDictionary* options = [NSDictionary dictionary]; - void (^completion)(BOOL success) = ^void(BOOL success) { - NSLog(@"completion for openURL: %i", success); - }; - [invocation setTarget:responder]; - [invocation setSelector:selectorOpenURL]; - [invocation setArgument:&url atIndex:2]; - [invocation setArgument:&options atIndex:3]; - [invocation setArgument:&completion atIndex:4]; - [invocation invoke]; + [responder performSelector:selectorOpenURL withObject:url]; break; } } From df052b5eeb837aceb6945e33275310130b11e156 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sat, 13 Apr 2019 17:37:06 +0200 Subject: [PATCH 15/15] :recycle: Change openURL call in share extension again --- .../ShareViewController.m | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ios/OpenbookShareExtension/ShareViewController.m b/ios/OpenbookShareExtension/ShareViewController.m index a9ff0b871..003e7ed66 100644 --- a/ios/OpenbookShareExtension/ShareViewController.m +++ b/ios/OpenbookShareExtension/ShareViewController.m @@ -36,22 +36,26 @@ - (NSString*) getTempFileWithExtension:(NSString*)extension { return tempFile; } -- (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { - NSURL* url = [[NSURL URLWithString:@"openbook://share"] URLByAppendingPathComponent:fileName]; - NSLog(@"Opening URL: %@", url); - SEL selectorOpenURL = NSSelectorFromString(@"openURL:"); - [self.extensionContext openURL:url completionHandler:nil]; - +- (UIApplication*)getUIApplication { UIResponder* responder = (UIResponder*)self; while ((responder = [responder nextResponder]) != nil) { - if ([responder respondsToSelector:selectorOpenURL]) { - [responder performSelector:selectorOpenURL withObject:url]; - break; + if ([responder isKindOfClass:[UIApplication class]]) { + return (UIApplication*)responder; } } - if (responder == nil) { - NSLog(@"Warning: No responder found to open URL"); + return nil; +} + +- (void)callOpenbookAppWithSharedFileName:(NSString*)fileName { + NSURL* url = [[NSURL URLWithString:@"openbook://share"] URLByAppendingPathComponent:fileName]; + NSLog(@"Opening URL: %@", url); + UIApplication* application = [self getUIApplication]; + if (application == nil) { + NSLog(@"Failed to get UIApplication, can't open URL!"); + return; } + + [application performSelector:@selector(openURL:) withObject:url]; } - (void)callOpenbookAppWithData:(NSDictionary*)data {