I am trying to use ShareKit to share via email an HTML string and share on Facebook a regular stream containing an image and some text.
The sample project just shows how to share the same info for every platform(Twitter, Facebook, email) but I want to be able to share different content according to the platform.
SHKItem *item = [SHKItem image:image title: #"title"];
item.text = #"share text";
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
any ideas?
I was looking for something similar and found it in ShareKit's documentation:
http://www.getsharekit.com/docs/
What you are looking for (I believe) is sharing to a specific service provider, and not using that action sheet interface. That's what I've done to create different content for different platforms.
Code:
#import "SHKFacebook.h"
#import "SHKTwitter.h"
...
- (IBAction)shareOnFacebook {
// Create an image item
SHKItem *item = [SHKItem image:[UIImage imageNamed:#"myImage.png"] title:#"A Girraffe!"];
// Share the item on Facebook
[SHKFacebook shareItem:item];
return;
}
- (IBAction)shareOnTwitter {
// Create a text item
NSString *someText = #"This is a blurb of text I highlighted from a document.";
SHKItem *item = [SHKItem text:someText];
// Share the item on Twitter
[SHKTwitter shareItem:item];
return;
}
Hope this helps!
Oded.
My own experience: I succeeded in only sharing URLs on Twitter while sharing both URLs and images on Facebook.
What I did: I rewrote some of SHKItem's instance methods, such as:
//original
SHKItem *item = [SHKItem image:image title: #"title"];
//new version
SHKItem *item = [SHKItem image:image url:aURL title: #"title"];
and other related methods. In this way whenever I created a SHKItem instance, I would be able to pass both URLs and images to the following classes that are going to handle the sharing issues.
Related
In my App I sharing an image on Instagram. It is working well in my app.
I am using the following code.
#property (nonatomic, retain) UIDocumentInteractionController *dic;
CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents/test.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#", jpgPath]];
// NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#", screenshot]];
self.dic.UTI = #"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
Now I also want to share some text with the image.
As shown in the Image below. In " Write a Caption", I want some default custom text for eg. "Share this photo".
How can I do this?
Thanks in advance...
Edited
I am opening Instagram from my app for sharing images and it works fine.
But Is it possible that Can I check Whether the user has shared it successfully or not?
Means I want to perform some action in my DB when user successfully shares an image.
How can i do this?
I got my answer. Just added a line and it worked for me.
self.dic.annotation = [NSDictionary dictionaryWithObject:#"Here Give what you want to share" forKey:#"InstagramCaption"];
Thanks...
It is also documented in the official documentation at http://instagram.com/developer/iphone-hooks/
To include a pre-filled caption with your photo, you can set the annotation property on the document interaction request to an NSDictionary containing an NSString under the key "InstagramCaption". Note: this feature will be available on Instagram 2.1 and later.
You are no more allowed to share Pre-Filled Text with Instagram or Facebook.
Only Images/Screenshots can be shared via UIDocumentInteractionController.
I'm using sharekit/sharekit API to share via mail,twitter,facebook
NSDictionary *table = [[NSDictionary alloc] initWithObjectsAndKeys:#"SHKTwitter", SHKLocalizedString(#"Twitter", nil), #"SHKFacebook", SHKLocalizedString(#"Facebook", nil), #"SHKMail", SHKLocalizedString(#"Email", nil),#"SHKTextMessage", SHKLocalizedString(#"Text", nil),nil];
Class SharersClass = NSClassFromString([table objectForKey:"Facebook"]);
NSString *shareMsg = #"share message";
NSURL *shareUrl = [NSURL URLWithString:myURL];
SHKItem *item = [SHKItem text:shareMsg];
item.url = shareUrl;
[SharersClass performSelector:#selector(shareItem:) withObject:item];
the sharing works but my problem is that the url is not displayed to the user in the facebook pop up however it's displayed on the user wall on facebook.com ...
the same case happens with twitter ... but the links appears in mail and text sharing ...
any idea what might be the problem ?
I successfully posted content and (Links)URL using Google Plus API in iphone.
Using Following code:
googleShare =[[[GooglePlusShare alloc] initWithClientID:#"my key"] autorelease];
[googleShare setDelegate:self];
appDelegate.shareGOOGLe =googleShare;
NSString *inputURL = #"";
NSURL *urlToShare = [inputURL length] ? [NSURL URLWithString:inputURL] : nil;
NSLog(#"%#",urlToShare);
NSString *inputText = #"TEst Sharing testing from iOS 5.0";
NSString *text = [inputText length] ? inputText : nil;
NSLog(#"%#",text);
[[[[googleShare shareDialog]
setURLToShare:urlToShare]
setPrefillText:shareMessge] open];
But I want to post images to google plus.
Can any one help me?
Thanks in advance.
It is currently not possible to share images on Google+ with the Google+ iOS SDK.
This is possible to share a Image with google plus
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder attachImage:[UIImage imageNamed:#"yourImagename.png"]];
[shareBuilder open];
}
Referenced from https://developers.google.com/+/mobile/ios/share/
#Chirag... You should see Flipboard application for iPhone/iPad. It shares the link,comment and Image on Google+ account. Please take a look and let me know if i am wrong at any point.
These are the links will help:
Link Shows how and what can be shared.
https://developers.google.com/+/mobile/ios/share/
at the bottome of link 1, it mentions "Attaching media to your shared posts. You can attach pictures and movies to your posts for your users to share to their stream."
https://developers.google.com/+/mobile/ios/share/media
Link 2 shows the code snippet to share the media ; images and videos
Following is the Code snippet to share Image on google+
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
// Set any prefilled text that you might want to suggest
[shareBuilder setPrefillText:#"Achievement unlocked! I just scored 99 points. Can you beat me?"]
NSString *fileName = #"samplemedia1";
[shareBuilder attachImage:[UIImage imageNamed:fileName];
[shareBuilder open];
}
Below is the method I'm using with Sharekit to send an image and a title to facebook. I also want to send a URL along with the facebook post. If I try
SHKItem *item = [SHKItem image:image url:url title:titleString];
I get a too many arguments error message. Does anyone have any ideas on how this should be done? thanks for any help.
- (IBAction)myButtonHandlerAction
{
NSURL *url = [NSURL URLWithString:#"http://example.com/"];
NSString *titleString = [[NSString alloc] initWithFormat:#"*** %# * \n\nGet the ***** App - It's Free!", entity.name];
UIImage *image = [[[UIImage alloc] initWithData:entity.image] autorelease];
SHKItem *item = [SHKItem image:image title:titleString];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showFromBarButtonItem:barbtn animated:YES];
}
There is no method -[SHKItem image:url:title:]. So an error is being raised. Currently there is no mechanism to do what you require using ShareKit so you will have to customize ShareKit for your needs. You should also look at the Graph API.
Maybe what you want is a url item, with an image attached to it. If so, you can do this :
SHKItem *item = [SHKItem URL:[NSURL URLWithString:#"http://example.com/"] title:#"Check this link"];
[item setCustomValue:#"http://example.com/someimage.jpg" forKey:#"picture"];
[SHKFacebook shareItem:item];
I've implemented this with the latest sharekit, it works for me.
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = [NSString stringWithFormat: subjectTitle]; //subjectTitle works here but not as name where i need it.
NSString *src = #"http://www.sample.com/image.png";
NSString *name = storyLink; //<---------------------------------works with storyLink but not subjectTitle. I need subjectTitle to work here
NSString *href = storyLink;
NSString *attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\", \"src\":\"%#\", \"href\":\"%#\"}]}", name, src, href];
dialog.attachment = attachment;
[dialog show];
}
i want to add image from photo library instred of http://www.sample.com/image.png to the facebook wall.
can anyone provides me help ....
Thanks in advance ......
You can access the URL's of the iPhoto library items using the UIImagePickerController and its delegate method.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
When the user picks a photo the URL will be in the dictionary under the key UIImagePickerControllerMediaURL
Probably this Stack Overflow Question about uploading images to Facebook might help you.
Also Sharekit is a nice framework to add Social features to you iPhone App. I think it has facility to share images. You can check it out at Sharekit official website.