From 796ab52b829e884ad82b82d01e40505ca58b54b6 Mon Sep 17 00:00:00 2001 From: Niklas Merz Date: Thu, 23 Aug 2018 17:19:56 +0200 Subject: [PATCH] Remove post dialog and start app directly --- src/ios/OpenWithPlugin.m | 7 ++-- .../ShareExtension/MainInterface.storyboard | 36 ------------------- .../ShareExtension/ShareExtension-Info.plist | 4 +-- src/ios/ShareExtension/ShareViewController.m | 14 +++++--- 4 files changed, 14 insertions(+), 47 deletions(-) delete mode 100644 src/ios/ShareExtension/MainInterface.storyboard diff --git a/src/ios/OpenWithPlugin.m b/src/ios/OpenWithPlugin.m index bd1ef93..21ccd8e 100644 --- a/src/ios/OpenWithPlugin.m +++ b/src/ios/OpenWithPlugin.m @@ -228,11 +228,10 @@ - (void) checkForFileToShare { } NSDictionary *dict = (NSDictionary*)object; NSData *data = dict[@"data"]; - NSString *text = dict[@"text"]; NSString *name = dict[@"name"]; self.backURL = dict[@"backURL"]; NSString *type = [self mimeTypeFromUti:dict[@"uti"]]; - if (![data isKindOfClass:NSData.class] || ![text isKindOfClass:NSString.class]) { + if (![data isKindOfClass:NSData.class]) { [self debug:@"[checkForFileToShare] Data content is invalid"]; return; } @@ -246,8 +245,7 @@ - (void) checkForFileToShare { // Send to javascript [self debug:[NSString stringWithFormat: - @"[checkForFileToShare] Sharing text \"%@\" and a %d bytes image", - text, data.length]]; + @"[checkForFileToShare] Sharing a %lu bytes image", (unsigned long)data.length]]; NSString *uri = [NSString stringWithFormat: @"shareextension://index=0,name=%@,type=%@", name, type]; @@ -255,7 +253,6 @@ - (void) checkForFileToShare { @"action": @"SEND", @"exit": @YES, @"items": @[@{ - @"text" : text, @"base64": [data convertToBase64], @"type": type, @"utis": utis, diff --git a/src/ios/ShareExtension/MainInterface.storyboard b/src/ios/ShareExtension/MainInterface.storyboard deleted file mode 100644 index 0fe2910..0000000 --- a/src/ios/ShareExtension/MainInterface.storyboard +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ios/ShareExtension/ShareExtension-Info.plist b/src/ios/ShareExtension/ShareExtension-Info.plist index ee828fe..639c935 100644 --- a/src/ios/ShareExtension/ShareExtension-Info.plist +++ b/src/ios/ShareExtension/ShareExtension-Info.plist @@ -22,6 +22,8 @@ __BUNDLE_VERSION__ NSExtension + NSExtensionPrincipalClass + ShareViewController NSExtensionAttributes NSExtensionActivationRule @@ -39,8 +41,6 @@ NSExtensionActivationDictionaryVersion 2 - NSExtensionMainStoryboard - MainInterface NSExtensionPointIdentifier com.apple.share-services diff --git a/src/ios/ShareExtension/ShareViewController.m b/src/ios/ShareExtension/ShareViewController.m index 409a0f3..a1e489f 100644 --- a/src/ios/ShareExtension/ShareViewController.m +++ b/src/ios/ShareExtension/ShareViewController.m @@ -31,7 +31,7 @@ #import #import "ShareViewController.h" -@interface ShareViewController : SLComposeServiceViewController { +@interface ShareViewController : UIViewController { int _verbosityLevel; NSUserDefaults *_userDefaults; NSString *_backURL; @@ -66,6 +66,13 @@ - (void) info:(NSString*)message { [self log:VERBOSITY_INFO message:message]; } - (void) warn:(NSString*)message { [self log:VERBOSITY_WARN message:message]; } - (void) error:(NSString*)message { [self log:VERBOSITY_ERROR message:message]; } +-(void) viewDidLoad { + [super viewDidLoad]; + printf("did load"); + [self debug:@"[viewDidLoad]"]; + [self submit]; +} + - (void) setup { self.userDefaults = [[NSUserDefaults alloc] initWithSuiteName:SHAREEXT_GROUP_IDENTIFIER]; self.verbosityLevel = [self.userDefaults integerForKey:@"verbosityLevel"]; @@ -104,10 +111,10 @@ - (void) openURL:(nonnull NSURL *)url { } } -- (void) didSelectPost { +- (void) submit { [self setup]; - [self debug:@"[didSelectPost]"]; + [self debug:@"[submit]"]; // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. for (NSItemProvider* itemProvider in ((NSExtensionItem*)self.extensionContext.inputItems[0]).attachments) { @@ -140,7 +147,6 @@ - (void) didSelectPost { uti = SHAREEXT_UNIFORM_TYPE_IDENTIFIER; } NSDictionary *dict = @{ - @"text": self.contentText, @"backURL": self.backURL, @"data" : data, @"uti": uti,