From d1ff265f0d3dcf334e1c101436775544265f4577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=B0=D0=B1=D0=B8=D0=BD=20=D0=92=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=D1=80?= Date: Wed, 9 Dec 2015 14:47:17 +0500 Subject: [PATCH] Geolocation attachment for post --- library/Source/Views/VKShareDialogController.h | 4 ++++ library/Source/Views/VKShareDialogController.m | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/library/Source/Views/VKShareDialogController.h b/library/Source/Views/VKShareDialogController.h index 7d2b3553..c7db42dc 100644 --- a/library/Source/Views/VKShareDialogController.h +++ b/library/Source/Views/VKShareDialogController.h @@ -21,6 +21,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #import +#import #import "VKObject.h" #import "VKUploadImage.h" @@ -59,6 +60,9 @@ typedef NS_ENUM(NSInteger, VKShareDialogControllerResult) { /// Text to share. User can change it @property(nonatomic, copy) NSString *text; +/// Location attachment for new post +@property(nonatomic) CLLocationCoordinate2D *location; + /// Put only needed scopes into that array. By default equals @[VK_PER_WALL,VK_PER_PHOTOS] @property(nonatomic, strong) NSArray *requestedScope; diff --git a/library/Source/Views/VKShareDialogController.m b/library/Source/Views/VKShareDialogController.m index 88562ed6..cc870bdd 100644 --- a/library/Source/Views/VKShareDialogController.m +++ b/library/Source/Views/VKShareDialogController.m @@ -978,6 +978,12 @@ - (void)sendMessage:(id)sender { VKRequest *post = [[VKApi wall] post:@{VK_API_MESSAGE : textView.text ?: @"", VK_API_ATTACHMENTS : [attachStrings componentsJoinedByString:@","]}]; NSMutableArray *exports = [NSMutableArray new]; + if (self.parent.location) { + CLLocationCoordinate2D location = *(self.parent.location); + NSString *latitude = [NSString stringWithFormat:@"%f", location.latitude]; + NSString *longitude = [NSString stringWithFormat:@"%f", location.longitude]; + [post addExtraParameters:@{VK_API_LAT: latitude, VK_API_LONG: longitude}]; + } if (self.postSettings.friendsOnly.boolValue) [post addExtraParameters:@{VK_API_FRIENDS_ONLY : @1}]; if (self.postSettings.exportTwitter.boolValue) [exports addObject:@"twitter"]; if (self.postSettings.exportFacebook.boolValue) [exports addObject:@"facebook"];