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

Added shareToMail and shareToTwitter, also changed shareToFacebook #203

Merged
merged 1 commit into from Nov 27, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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