Skip to content

Commit

Permalink
Remove post dialog and start app directly
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasMerz committed Aug 13, 2019
1 parent ce53001 commit 796ab52
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 47 deletions.
7 changes: 2 additions & 5 deletions src/ios/OpenWithPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -246,16 +245,14 @@ - (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];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{
@"action": @"SEND",
@"exit": @YES,
@"items": @[@{
@"text" : text,
@"base64": [data convertToBase64],
@"type": type,
@"utis": utis,
Expand Down
36 changes: 0 additions & 36 deletions src/ios/ShareExtension/MainInterface.storyboard

This file was deleted.

4 changes: 2 additions & 2 deletions src/ios/ShareExtension/ShareExtension-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string>__BUNDLE_VERSION__</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPrincipalClass</key>
<string>ShareViewController</string>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
Expand All @@ -39,8 +41,6 @@
<key>NSExtensionActivationDictionaryVersion</key>
<integer>2</integer>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
Expand Down
14 changes: 10 additions & 4 deletions src/ios/ShareExtension/ShareViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#import <Social/Social.h>
#import "ShareViewController.h"

@interface ShareViewController : SLComposeServiceViewController {
@interface ShareViewController : UIViewController {
int _verbosityLevel;
NSUserDefaults *_userDefaults;
NSString *_backURL;
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -140,7 +147,6 @@ - (void) didSelectPost {
uti = SHAREEXT_UNIFORM_TYPE_IDENTIFIER;
}
NSDictionary *dict = @{
@"text": self.contentText,
@"backURL": self.backURL,
@"data" : data,
@"uti": uti,
Expand Down

0 comments on commit 796ab52

Please sign in to comment.