Skip to content
Browse files

Change TextMessage recipients to new standart

* fixes for SHKItem class
  • Loading branch information...
1 parent 5f18802 commit 84fc33f24406922f5700df5b3dabf513a745a201 @iKorich iKorich committed Jun 22, 2012
View
11 Classes/Example/ShareKitDemoConfigurator.m
@@ -194,6 +194,17 @@ - (NSString*)foursquareV2RedirectURI {
return @"app://foursquare";
}
+/* SHKTextMessage */
+
+//constructed during runtime from user input in shareForm by default
+- (NSString *)textMessageBody {
+ return nil;
+}
+
+//user enters them in MFMessageComposeViewController by default. Should be array of NSStrings.
+- (NSArray *)textMessageToRecipients {
+ return [NSArray arrayWithObjects:@"1111111111111", @"2222222222222", nil];
+}
/*
UI Configuration : Basic
View
3 Classes/ShareKit/Configuration/DefaultSHKConfigurator.h
@@ -106,5 +106,8 @@
//SHKFacebook
- (NSString *)facebookURLSharePictureURI;
- (NSString *)facebookURLShareDescription;
+//SHKTextMessage
+- (NSString *)textMessageBody;
+- (NSArray *)textMessageToRecipients;
@end
View
10 Classes/ShareKit/Configuration/DefaultSHKConfigurator.m
@@ -383,7 +383,17 @@ - (NSString *)facebookURLShareDescription {
return nil;
}
+/* SHKTextMessage */
+//constructed during runtime from user input in shareForm by default
+- (NSString *)textMessageBody {
+ return nil;
+}
+
+//user enters them in MFMessageComposeViewController by default. Should be array of NSStrings.
+- (NSArray *)textMessageToRecipients {
+ return nil;
+}
@end
View
15 Classes/ShareKit/Core/SHKItem.h
@@ -61,7 +61,19 @@ typedef enum
NSData *data;
NSString *mimeType;
NSString *filename;
+
+ NSString *mailBody;
+ BOOL isMailHTML;
+ NSArray *mailToRecipients;
+ CGFloat mailJPGQuality;
+ BOOL mailShareWithAppSignature;
+
+ NSString *facebookURLSharePictureURI;
+ NSString *facebookURLShareDescription;
+ NSString *textMessageBody;
+ NSArray *textMessageToRecipients;
+
@private
NSMutableDictionary *custom;
}
@@ -128,6 +140,9 @@ typedef enum
@property (nonatomic, retain) NSString *facebookURLSharePictureURI;
@property (nonatomic, retain) NSString *facebookURLShareDescription;
+/* SHKTextMessage */
+@property (nonatomic, retain) NSString *textMessageBody;
+@property (nonatomic, retain) NSArray *textMessageToRecipients;
/* if you add new sharer specific properties, make sure to add them also to dictionaryRepresentation, itemWithDictionary and description methods in SHKItem.m */
@end
View
198 Classes/ShareKit/Core/SHKItem.m
@@ -47,6 +47,7 @@ @implementation SHKItem
@synthesize printOutputType;
@synthesize mailBody, mailJPGQuality, mailToRecipients, isMailHTML, mailShareWithAppSignature;
@synthesize facebookURLSharePictureURI, facebookURLShareDescription;
+@synthesize textMessageBody, textMessageToRecipients;
- (void)dealloc
{
@@ -63,38 +64,44 @@ - (void)dealloc
[filename release];
[custom release];
-
- [mailBody release];
- [mailToRecipients release];
- [facebookURLSharePictureURI release];
- [facebookURLShareDescription release];
-
+
+ [mailBody release];
+ [mailToRecipients release];
+ [facebookURLSharePictureURI release];
+ [facebookURLShareDescription release];
+
+ if (textMessageBody) [textMessageBody release], textMessageBody = nil;
+ if (textMessageToRecipients) [textMessageToRecipients release], textMessageToRecipients = nil;
+
[super dealloc];
}
- (id)init {
- self = [super init];
-
- if (self) {
-
- [self setExtensionPropertiesDefaultValues];
- }
- return self;
+ self = [super init];
+
+ if (self) {
+
+ [self setExtensionPropertiesDefaultValues];
+ }
+ return self;
}
- (void)setExtensionPropertiesDefaultValues {
- printOutputType = [SHKCONFIG(printOutputType) intValue];
-
- mailBody = [SHKCONFIG(mailBody) retain];
- mailToRecipients = [SHKCONFIG(mailToRecipients) retain];
- mailJPGQuality = [SHKCONFIG(mailJPGQuality) floatValue];
- isMailHTML = [SHKCONFIG(isMailHTML) boolValue];
- mailShareWithAppSignature = [SHKCONFIG(sharedWithSignature) boolValue];
-
- facebookURLShareDescription = [SHKCONFIG(facebookURLShareDescription) retain];
- facebookURLSharePictureURI = [SHKCONFIG(facebookURLSharePictureURI) retain];
+ printOutputType = [SHKCONFIG(printOutputType) intValue];
+
+ mailBody = [SHKCONFIG(mailBody) retain];
+ mailToRecipients = [SHKCONFIG(mailToRecipients) retain];
+ mailJPGQuality = [SHKCONFIG(mailJPGQuality) floatValue];
+ isMailHTML = [SHKCONFIG(isMailHTML) boolValue];
+ mailShareWithAppSignature = [SHKCONFIG(sharedWithSignature) boolValue];
+
+ facebookURLShareDescription = [SHKCONFIG(facebookURLShareDescription) retain];
+ facebookURLSharePictureURI = [SHKCONFIG(facebookURLSharePictureURI) retain];
+
+ textMessageBody = [SHKCONFIG(textMessageBody) retain];
+ textMessageToRecipients = [SHKCONFIG(textMessageToRecipients) retain];
}
+ (id)URL:(NSURL *)url
@@ -109,11 +116,11 @@ + (id)URL:(NSURL *)url title:(NSString *)title
+ (id)URL:(NSURL *)url title:(NSString *)title contentType:(SHKURLContentType)type {
- SHKItem *item = [[self alloc] init];
+ SHKItem *item = [[self alloc] init];
item.shareType = SHKShareTypeURL;
item.URL = url;
item.title = title;
- item.URLContentType = type;
+ item.URLContentType = type;
return [item autorelease];
@@ -207,15 +214,36 @@ + (id)itemFromDictionary:(NSDictionary *)dictionary
if ([dictionary objectForKey:@"image"] != nil)
item.image = [UIImage imageWithData:[dictionary objectForKey:@"image"]];
-
- item.printOutputType = [[dictionary objectForKey:@"printOutputType"] intValue];
- item.mailBody = [dictionary objectForKey:@"mailBody"];
- item.isMailHTML = [[dictionary objectForKey:@"isMailHTML"] boolValue];
- item.mailToRecipients = [dictionary objectForKey:@"mailToRecipients"];
- item.mailJPGQuality = [[dictionary objectForKey:@"mailJPGQuality"] floatValue];
- item.mailShareWithAppSignature = [[dictionary objectForKey:@"mailShareWithAppSignature"] boolValue];
- item.facebookURLShareDescription = [dictionary objectForKey:@"facebookURLShareDescription"];
- item.facebookURLSharePictureURI = [dictionary objectForKey:@"facebookURLSharePictureURI"];
+
+ if ([dictionary objectForKey:@"printOutputType"] != nil)
+ item.printOutputType = [[dictionary objectForKey:@"printOutputType"] intValue];
+
+ if ([dictionary objectForKey:@"mailBody"] != nil)
+ item.mailBody = [dictionary objectForKey:@"mailBody"];
+
+ if ([dictionary objectForKey:@"isMailHTML"] != nil)
+ item.isMailHTML = [[dictionary objectForKey:@"isMailHTML"] boolValue];
+
+ if ([dictionary objectForKey:@"mailToRecipients"] != nil)
+ item.mailToRecipients = [dictionary objectForKey:@"mailToRecipients"];
+
+ if ([dictionary objectForKey:@"mailJPGQuality"] != nil)
+ item.mailJPGQuality = [[dictionary objectForKey:@"mailJPGQuality"] floatValue];
+
+ if ([dictionary objectForKey:@"mailShareWithAppSignature"] != nil)
+ item.mailShareWithAppSignature = [[dictionary objectForKey:@"mailShareWithAppSignature"] boolValue];
+
+ if ([dictionary objectForKey:@"facebookURLShareDescription"] != nil)
+ item.facebookURLShareDescription = [dictionary objectForKey:@"facebookURLShareDescription"];
+
+ if ([dictionary objectForKey:@"facebookURLSharePictureURI"] != nil)
+ item.facebookURLSharePictureURI = [dictionary objectForKey:@"facebookURLSharePictureURI"];
+
+ if ([dictionary objectForKey:@"textMessageBody"] != nil)
+ item.textMessageBody = [dictionary objectForKey:@"textMessageBody"];
+
+ if ([dictionary objectForKey:@"textMessageToRecipients"] != nil)
+ item.textMessageToRecipients = [dictionary objectForKey:@"textMessageToRecipients"];
return [item autorelease];
}
@@ -256,27 +284,35 @@ - (NSDictionary *)dictionaryRepresentation
[dictionary setObject:[NSNumber numberWithInt:printOutputType] forKey:@"printOutputType"];
- if (mailBody) {
- [dictionary setObject:mailBody forKey:@"mailBody"];
- }
-
- [dictionary setObject:[NSNumber numberWithBool:isMailHTML] forKey:@"isMailHTML"];
-
- if (mailToRecipients) {
- [dictionary setObject:mailToRecipients forKey:@"mailToRecipients"];
- }
-
- [dictionary setObject:[NSNumber numberWithFloat:mailJPGQuality] forKey:@"mailJPGQuality"];
-
- [dictionary setObject:[NSNumber numberWithBool:mailShareWithAppSignature] forKey:@"mailShareWithAppSignature"];
-
- if (facebookURLSharePictureURI) {
- [dictionary setObject:facebookURLSharePictureURI forKey:@"facebookURLSharePictureURI"];
- }
-
- if (facebookURLShareDescription) {
- [dictionary setObject:facebookURLShareDescription forKey:@"facebookURLShareDescription"];
- }
+ if (mailBody) {
+ [dictionary setObject:mailBody forKey:@"mailBody"];
+ }
+
+ [dictionary setObject:[NSNumber numberWithBool:isMailHTML] forKey:@"isMailHTML"];
+
+ if (mailToRecipients) {
+ [dictionary setObject:mailToRecipients forKey:@"mailToRecipients"];
+ }
+
+ [dictionary setObject:[NSNumber numberWithFloat:mailJPGQuality] forKey:@"mailJPGQuality"];
+
+ [dictionary setObject:[NSNumber numberWithBool:mailShareWithAppSignature] forKey:@"mailShareWithAppSignature"];
+
+ if (facebookURLSharePictureURI) {
+ [dictionary setObject:facebookURLSharePictureURI forKey:@"facebookURLSharePictureURI"];
+ }
+
+ if (facebookURLShareDescription) {
+ [dictionary setObject:facebookURLShareDescription forKey:@"facebookURLShareDescription"];
+ }
+
+ if (textMessageBody) {
+ [dictionary setObject:textMessageBody forKey:@"textMessageBody"];
+ }
+
+ if (textMessageToRecipients) {
+ [dictionary setObject:textMessageToRecipients forKey:@"textMessageToRecipients"];
+ }
// If you add anymore, make sure to add a method for retrieving them to the itemWithDictionary function too
@@ -285,22 +321,42 @@ - (NSDictionary *)dictionaryRepresentation
- (NSString *)description {
- NSString *result = [NSString stringWithFormat:@"Share type: %@\nURL:%@\nURLContentType: %i\nImage:%@\nTitle: %@\nText: %@\nTags:%@\nCustom fields:%@\n\nSharer specific\n\nPrint output type: %i\nmailBody: %@\nisMailHTML: %i\nmailToRecipients: %@\nmailJPGQuality: %f\nmailShareWithAppSignature: %i\nfacebookURLSharePictureURI: %@\nfacebookURLShareDescription: %@",
- [self shareTypeToString:self.shareType],
- [self.URL absoluteString],
- self.URLContentType,
- [self.image description],
- self.title, self.text,
- self.tags,
- [self.custom description],
- self.printOutputType,
- self.mailBody,
- self.isMailHTML,
- [self.mailToRecipients description],
- self.mailJPGQuality,
- self.mailShareWithAppSignature,
- self.facebookURLSharePictureURI,
- self.facebookURLShareDescription];
+ NSString *result = [NSString stringWithFormat:@"Share type: %@\nURL:%@\n\
+ URLContentType: %i\n\
+ Image:%@\n\
+ Title: %@\n\
+ Text: %@\n\
+ Tags:%@\n\
+ Custom fields:%@\n\n\
+ Sharer specific\n\n\
+ Print output type: %i\n\
+ mailBody: %@\n\
+ isMailHTML: %i\n\
+ mailToRecipients: %@\n\
+ mailJPGQuality: %f\n\
+ mailShareWithAppSignature: %i\n\
+ facebookURLSharePictureURI: %@\n\
+ facebookURLShareDescription: %@\n\
+ textMessageBody: %@\n\
+ textMessageToRecipients: %@",
+
+ [self shareTypeToString:self.shareType],
+ [self.URL absoluteString],
+ self.URLContentType,
+ [self.image description],
+ self.title, self.text,
+ self.tags,
+ [self.custom description],
+ self.printOutputType,
+ self.mailBody,
+ self.isMailHTML,
+ [self.mailToRecipients description],
+ self.mailJPGQuality,
+ self.mailShareWithAppSignature,
+ self.facebookURLSharePictureURI,
+ self.facebookURLShareDescription,
+ self.textMessageBody,
+ self.textMessageToRecipients];
return result;
}
View
13 Classes/ShareKit/Sharers/Actions/Text Message/SHKTextMessage.m
@@ -116,8 +116,8 @@ - (BOOL)sendText
{
MFMessageComposeViewController *composeView = [[[MFMessageComposeViewController alloc] init] autorelease];
composeView.messageComposeDelegate = self;
-
- NSString * body = [item customValueForKey:@"body"];
+
+ NSString *body = self.item.textMessageBody;
if (!body) {
if (item.text != nil)
@@ -137,12 +137,13 @@ - (BOOL)sendText
// fallback
if (body == nil)
body = @"";
-
- // save changes to body
- [item setCustomValue:body forKey:@"body"];
}
-
[composeView setBody:body];
+
+ NSArray *toRecipients = self.item.textMessageToRecipients;
+ if (toRecipients)
+ [composeView setRecipients:toRecipients];
+
[[SHK currentHelper] showViewController:composeView];
[self retain]; //release is in callback, MFMessageComposeViewController does not retain its delegate

0 comments on commit 84fc33f

Please sign in to comment.
Something went wrong with that request. Please try again.