Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #203 from swanify/master
Browse files Browse the repository at this point in the history
Added shareToMail and shareToTwitter, also changed shareToFacebook
  • Loading branch information
max-mapper committed Nov 27, 2011
2 parents c1b8019 + 375c5b6 commit 474a733
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
4 changes: 4 additions & 0 deletions iPhone/ShareKitPlugin/README.md
Expand Up @@ -69,6 +69,10 @@ you must logout the current one first );

7. `shareToFacebook(message, url )` Shows only the post in the wall form of Facebook if the user is logged in.

8. `shareToTwitter(message, url)` Shares an item specifically with Twitter, will automatically shorten the URL

9. `shareToMail(subject, body)` Opens up the iOS mail dialog with pre-filled subject and body

## Running the example
The example is a project for XCode 4. It shows a basic use case for the plugin, in order to use it you must add the API keys of the services that you want to test in the SHKConfig.h file.

Expand Down
4 changes: 4 additions & 0 deletions iPhone/ShareKitPlugin/ShareKitPlugin.h
Expand Up @@ -43,4 +43,8 @@

- (void)shareToFacebook:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

- (void)shareToTwitter:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

- (void)shareToMail:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

@end
14 changes: 14 additions & 0 deletions iPhone/ShareKitPlugin/ShareKitPlugin.js
Expand Up @@ -61,6 +61,20 @@ ShareKitPlugin.prototype.shareToFacebook = function( message, url)

};

ShareKitPlugin.prototype.shareToTwitter = function( message, url)
{

PhoneGap.exec(null, null, "ShareKitPlugin", "shareToTwitter", [message, url] );

};

ShareKitPlugin.prototype.shareToMail = function( subject, message)
{

PhoneGap.exec(null, null, "ShareKitPlugin", "shareToMail", [subject, message] );

};




Expand Down
47 changes: 44 additions & 3 deletions iPhone/ShareKitPlugin/ShareKitPlugin.m
Expand Up @@ -68,14 +68,55 @@ - (void)facebookConnect:(NSMutableArray*)arguments withDict:(NSMutableDictionary
}

- (void)shareToFacebook:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {

[[SHK currentHelper] setRootViewController:self.appViewController];

SHKItem *item;

NSString *message = [arguments objectAtIndex:1];
if ([arguments objectAtIndex:2]) {
NSURL *itemUrl = [NSURL URLWithString:[arguments objectAtIndex:2]];
item = [SHKItem URL:itemUrl title:message];
} else {
item = [SHKItem text:message];
}

[SHKFacebook shareItem:item];

}

- (void)shareToTwitter:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
[[SHK currentHelper] setRootViewController:self.appViewController];

SHKItem *item;

NSString *message = [arguments objectAtIndex:1];
if ([arguments objectAtIndex:2]) {
NSURL *itemUrl = [NSURL URLWithString:[arguments objectAtIndex:2]];
[SHKFacebook shareURL:itemUrl title:message];
NSURL *itemUrl = [NSURL URLWithString:[arguments objectAtIndex:2]];
item = [SHKItem URL:itemUrl title:message];
} else {
[SHKFacebook shareText:message];
item = [SHKItem text:message];
}

[SHKTwitter shareItem:item];

}

- (void)shareToMail:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
[[SHK currentHelper] setRootViewController:self.appViewController];

SHKItem *item;

NSString *message = [arguments objectAtIndex:1];
if ([arguments objectAtIndex:2]) {
NSURL *itemUrl = [NSURL URLWithString:[arguments objectAtIndex:2]];
item = [SHKItem URL:itemUrl title:message];
} else {
item = [SHKItem text:message];
}

[SHKMail shareItem:item];

}

@end

0 comments on commit 474a733

Please sign in to comment.