sharekit/sharekit not displaying link when sharing on facebook and twitter - iphone

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 ?

Related

Unable to share text on Instagram in ios 5

I used following code, and instagram app displays my photo but text what I want to share dosen't display.
I used annotation property, but it's not working. I don't know where is wrong ?
instagram version : 3.5.0
my iphone version : 5.0.1
xcode version : 4.6
Regards.
NSURL *instagramURL = [NSURL URLWithString:#"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents/image.igo"];
NSString *urlString = [[NSString alloc] initWithFormat:#"file://%#", jpgPath];
NSURL *imageUrl = [[NSURL alloc] initWithString: urlString];
self.docController = [self setupControllerWithURL:imageUrl usingDelegate:self];
self.docController.UTI = #"com.instagram.exclusivegram";
self.docController.annotation = [NSDictionary dictionaryWithObject:#"I want to share this text" forKey:#"InstagramCaption"];
[self.docController presentOpenInMenuFromRect: self.view.frame inView: self.view animated: YES ];
}
According to the Instagram forum, 3rd party captions broke in the latest (3.5) release.
https://groups.google.com/d/topic/instagram-api-developers/wLfX0cJUUyM/discussion
See the following comment from Mike Krieger acknowledging the bug:
https://groups.google.com/d/msg/instagram-api-developers/wLfX0cJUUyM/SK_m4IJ3wn8J

Sharekit - sending a url link to facebook

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.

ShareKit iOS - different content for different platforms

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.

How to attach Image with message via iPhone application?

I want to send message with image data. So I used MFMessageComposeViewController.
But that controller provide only SMS service. So I used UIPasteBoard attached an image data.
But It doesn't work, either. There are no "Paste" button created when typing messages. Attaching image at UIPasteBoard was clearly success.
I think using MFMessageComposeViewController doesn't solve my problem.
How can I accomplish my goal?
This is not possible with the current MessageUI API: the MSMessageComposeViewController doesn't accept attachments like the MFMailComposeViewController does.
The only way to do this currently is to use an external service that allows you to send mms via a REST call for example.
GSMA defines a REST specification for exactly this purpose:
http://www.gsmworld.com/oneapi/reference_documentation-version_1.html (multiple pdf's on this page)
Try to find a local service provider that implements this specification and you're good to go.
Just to add the direct wiki link to the OneAPI MMS spec: http://gsma.securespsite.com/access/Access%20API%20Wiki/MMS%20RESTful%20API.aspx and a link to the PHP/Java sandbox https://github.com/OneAPI/GSMA-OneAPI where MMS can be tested locally . Cheers.
Here is the correct working code and it is working perfectly on my device.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = NO;
NSMutableDictionary *text = [NSMutableDictionary dictionaryWithCapacity:1];
[text setValue:label.text forKey:(NSString *)kUTTypeUTF8PlainText];
NSMutableDictionary *image = [NSMutableDictionary dictionaryWithCapacity:1];
[image setValue:imageView.image forKey:(NSString *)kUTTypePNG];
pasteboard.items = [NSArray arrayWithObjects:image,text, nil];
NSString *phoneToCall = #"sms:";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
I had the same question that I posted here. There is a bug in MFMessageComposeViewController and if you just use the code below it will launch a message that you can insert images into
NSString *phoneToCall = #"sms: 123-456-7890";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
This Method is tested and verified. I Used it in my code.
if (![MFMessageComposeViewController canSendText]) {
UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Your device not support SMS \nOr you hadn't login your iMessage" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alertV show];
return;
}
MFMessageComposeViewController *mVC = [[MFMessageComposeViewController alloc] init];
mVC.body = #"jjjj";
mVC.recipients = #[#"00XXXXXXXXXX"];
mVC.messageComposeDelegate = self;
if ([MFMessageComposeViewController canSendAttachments]) {
NSLog(#"ok");
}
[mVC addAttachmentData: UIImageJPEGRepresentation([UIImage imageNamed:#"test.jpg"], 1.0) typeIdentifier:#"public.data" filename:#"image.jpeg"];
[self presentViewController:mVC animated:YES completion:nil];
You can use any jpeg jpg and png formats.
Swift way. Works in iOS11
func shareViaMessage() {
if !MFMessageComposeViewController.canSendText() {
showAlert("Text services are not available")
return
}
let textComposer = MFMessageComposeViewController()
textComposer.messageComposeDelegate = self
textComposer.body = "Try my #app"
if MFMessageComposeViewController.canSendSubject() {
textComposer.subject = "AppName"
}
if MFMessageComposeViewController.canSendAttachments() {
let imageData = UIImageJPEGRepresentation(imageView.image!, 1.0)
textComposer.addAttachmentData(imageData!, typeIdentifier: "image/jpg", filename: "photo.jpg")
}
present(textComposer, animated: true)
}
Why don't you share the Image and Text via the Share API (selecting Message, and if you want exluding Facebook, twitter etc..)

write a message on wall of facebook using my iphone application

I am making an iphone game , In that I want to upload score on face book. I am new to face book codes, I've got it's API from github.com. But I don't know how to write or post directly my message on wall of face book of log in account else how to share my score on facebook. I've done log in portion.
Can any one help me????
Please refer the facebook api development at http://wiki.developers.facebook.com/index.php/Facebook_iPhone_SDK
Sample application also given by facebook for iPhone.
Thanks,
Jim.
Assuming the user has allready logged in and you have a vaild faceb0ok session, you could use something like this to get you started:
- (void) post {
postingDialog = [[[FBStreamDialog alloc] init] autorelease];
postingDialog.delegate = self;
postingDialog.userMessagePrompt = #"Prompt the User:";
NSString *name = #"Name of thing"
NSString *href = #"http://www.example.com"
NSString *caption = #"This is a caption"
NSString *description = #"This is a description";
NSString *imageSource = #"http://example.com/1.png";
NSString *imageHref = #"http://example.com/1.png";
NSString *linkTitle = #"Link title";
NSString *linkText = #"Text";
NSString *linkHref = #"http://www.example.com/iphone";
postingDialog.attachment = [NSString stringWithFormat:
#"{ \"name\":\"%#\","
"\"href\":\"%#\","
"\"caption\":\"%#\",\"description\":\"%#\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"%#\","
"\"href\":\"%#\"}],"
"\"properties\":{\"%#\":{\"text\":\"%#\",\"href\":\"%#\"}}}", name, href, caption, description, imageSource, imageHref, linkTitle, linkText, linkHref];
[postingDialog show];
}