iOS: tweaked #755 (sharing extension)

Just needed a tweak to the request URL.  Seems to be working now.
This commit is contained in:
David Sinclair 2018-08-27 14:36:44 -07:00
parent 4a9d604293
commit 3670f88acf
2 changed files with 8 additions and 6 deletions

View file

@ -2669,7 +2669,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = { 29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0910; LastUpgradeCheck = 0940;
ORGANIZATIONNAME = NewsBlur; ORGANIZATIONNAME = NewsBlur;
TargetAttributes = { TargetAttributes = {
1749390F1C251BFE003D98AA = { 1749390F1C251BFE003D98AA = {
@ -3574,7 +3574,6 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
@ -3620,7 +3619,6 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;

View file

@ -28,6 +28,8 @@
- (void)didSelectPost { - (void)didSelectPost {
NSItemProvider *itemProvider = [self providerWithURL]; NSItemProvider *itemProvider = [self providerWithURL];
NSLog(@"ShareExt: didSelectPost");
if (itemProvider) { if (itemProvider) {
[itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *item, NSError * _Null_unspecified error) { [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *item, NSError * _Null_unspecified error) {
if (item) { if (item) {
@ -76,7 +78,7 @@
- (void)sendURL:(NSURL *)url orText:(NSString *)text { - (void)sendURL:(NSURL *)url orText:(NSString *)text {
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.newsblur.NewsBlur-Group"]; NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.newsblur.NewsBlur-Group"];
NSString *host = [defaults objectForKey:@"share:host"]; NSString *host = [defaults objectForKey:@"share:host"];
// NSString *token = [defaults objectForKey:@"share:token"]; NSString *token = [defaults objectForKey:@"share:token"];
NSString *comments = self.contentText; NSString *comments = self.contentText;
if (text && [comments isEqualToString:text]) { if (text && [comments isEqualToString:text]) {
@ -91,13 +93,15 @@
NSURLSession *mySession = [self configureMySession]; NSURLSession *mySession = [self configureMySession];
// NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@/api/add_site_load_script/%@/?url=%@&time=%@&comments=%@", host, token, encodedURL, @(time), encodedComments]]; // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@/api/add_site_load_script/%@/?url=%@&time=%@&comments=%@", host, token, encodedURL, @(time), encodedComments]];
// NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@/api/share_story/%@", host, token]]; // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@/api/share_story/%@", host, token]];
NSURL *requestURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@/api/share_story", host]]; NSURL *requestURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/api/share_story/%@", host, token]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
request.HTTPMethod = @"POST"; request.HTTPMethod = @"POST";
NSString *postBody = [NSString stringWithFormat:@"story_url=%@&title=&content=%@&comments=%@", encodedURL, encodedContent, encodedComments]; NSString *postBody = [NSString stringWithFormat:@"story_url=%@&title=&content=%@&comments=%@", encodedURL, encodedContent, encodedComments];
request.HTTPBody = [postBody dataUsingEncoding:NSUTF8StringEncoding]; request.HTTPBody = [postBody dataUsingEncoding:NSUTF8StringEncoding];
NSURLSessionTask *myTask = [mySession dataTaskWithRequest:request]; NSURLSessionTask *myTask = [mySession dataTaskWithRequest:request];
[myTask resume]; [myTask resume];
NSLog(@"ShareExt: sendURL %@ or text %@ to %@ with body %@", url, text, requestURL, postBody);
} }
- (NSURLSession *)configureMySession { - (NSURLSession *)configureMySession {
@ -115,7 +119,7 @@
//} //}
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(nullable NSError *)error { - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(nullable NSError *)error {
NSLog(@"URLSession completed with error: %@", error); // log
} }
- (NSArray *)configurationItems { - (NSArray *)configurationItems {