From 3670f88acf23ac2b4533068fcb70ba3c4285f98f Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Mon, 27 Aug 2018 14:36:44 -0700 Subject: [PATCH] iOS: tweaked #755 (sharing extension) Just needed a tweak to the request URL. Seems to be working now. --- clients/ios/NewsBlur.xcodeproj/project.pbxproj | 4 +--- clients/ios/Share Extension/ShareViewController.m | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clients/ios/NewsBlur.xcodeproj/project.pbxproj b/clients/ios/NewsBlur.xcodeproj/project.pbxproj index 31e24ad24..b5c470309 100755 --- a/clients/ios/NewsBlur.xcodeproj/project.pbxproj +++ b/clients/ios/NewsBlur.xcodeproj/project.pbxproj @@ -2669,7 +2669,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = NewsBlur; TargetAttributes = { 1749390F1C251BFE003D98AA = { @@ -3574,7 +3574,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ENABLE_MODULES = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -3620,7 +3619,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ENABLE_MODULES = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; diff --git a/clients/ios/Share Extension/ShareViewController.m b/clients/ios/Share Extension/ShareViewController.m index 9dec5885d..ac70a7197 100644 --- a/clients/ios/Share Extension/ShareViewController.m +++ b/clients/ios/Share Extension/ShareViewController.m @@ -28,6 +28,8 @@ - (void)didSelectPost { NSItemProvider *itemProvider = [self providerWithURL]; + NSLog(@"ShareExt: didSelectPost"); + if (itemProvider) { [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *item, NSError * _Null_unspecified error) { if (item) { @@ -76,7 +78,7 @@ - (void)sendURL:(NSURL *)url orText:(NSString *)text { NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.newsblur.NewsBlur-Group"]; NSString *host = [defaults objectForKey:@"share:host"]; -// NSString *token = [defaults objectForKey:@"share:token"]; + NSString *token = [defaults objectForKey:@"share:token"]; NSString *comments = self.contentText; if (text && [comments isEqualToString:text]) { @@ -91,13 +93,15 @@ 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/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]; request.HTTPMethod = @"POST"; NSString *postBody = [NSString stringWithFormat:@"story_url=%@&title=&content=%@&comments=%@", encodedURL, encodedContent, encodedComments]; request.HTTPBody = [postBody dataUsingEncoding:NSUTF8StringEncoding]; NSURLSessionTask *myTask = [mySession dataTaskWithRequest:request]; [myTask resume]; + + NSLog(@"ShareExt: sendURL %@ or text %@ to %@ with body %@", url, text, requestURL, postBody); } - (NSURLSession *)configureMySession { @@ -115,7 +119,7 @@ //} - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(nullable NSError *)error { - + NSLog(@"URLSession completed with error: %@", error); // log } - (NSArray *)configurationItems {