I use the SLComposeViewController to post a facebook message. But the SLComposeViewController result returns SLComposeViewControllerResultDone even when the facebook password is incorrect.
Here my code:
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[fbController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
CCLOG(#"Cancelled.....");
[self cancel];
}
break;
case SLComposeViewControllerResultDone:
{
[self success];
}
break;
}};
The message is not posted with an incorrect password.
How to check if the user is correctly logged or is the message is correctly posted?
Thanks.
Related
I am using Social framework for sharing from my iOS application and testing my iOS application on iOS9. When I click on share button it opens native facebook application ViewController as shown in following image.
The problem is that irrespective of user clicks post or hit back button it still return SLComposeViewControllerResultDone result. Here is my completion handler for SLComposeViewController. Here is code:
NSLog(#"%#Controller presenting",socialMediaSLType);//socialMediaSLType is SLServiceTypeFacebook
SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:socialMediaSLType];
[controllerSLC setInitialText:#""];
[controllerSLC addURL:[NSURL URLWithString:link]];
[controllerSLC addImage:[UIImage imageNamed:[NSString stringWithFormat:#"%#%#",BASEURL,image]]];
[controllerSLC setCompletionHandler:^(SLComposeViewControllerResult result){
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(#"Post Canceled");
break;
case SLComposeViewControllerResultDone:
NSLog(#"Post Done");
break;
}
}];
[self presentViewController:controllerSLC animated:YES completion:nil];
I'm sending an email with very trivial method
#import <MessageUI/MFMailComposeViewController.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMessageComposeViewController.h>
-(void) sendEmailto: (NSArray*)p_recipient withSubject:(NSString*)p_subject body:(NSString*)p_body andAttachment:(NSData*)p_attachment
{
MFMailComposeViewController *emailComposer = [[MFMailComposeViewController alloc] init];
emailComposer.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail] == YES)
{
[emailComposer setSubject:p_subject];
if(p_recipient != nil)
{
[emailComposer setToRecipients:p_recipient];
}
if (p_body!= nil && [p_body isEqualToString:#""]==NO)
{
[emailComposer setMessageBody:p_body isHTML:NO];
}
if(p_attachment != nil)
{
[emailComposer addAttachmentData:p_attachment mimeType:#"image/jpeg" fileName:#"image.jpg"];
}
// Present mail view controller on screen
[emailComposer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:emailComposer animated:YES];
self.sentEmailTargetController = p_target;
}
else
{
NSLog(#"Can't Open Email");
}
}
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(#"e-mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(#"e-mail saved");
break;
case MFMailComposeResultSent:
NSLog(#"e-mail sent");
break;
case MFMailComposeResultFailed:
NSLog(#"e-mail sent failure: %#", [error localizedDescription]);
break;
default:
break;
}
if (![[self presentedViewController] isBeingDismissed])
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
}
I have the declared MFMailComposeViewControllerDelegate delegate in the interface
running it on my device the email console opens, I can write a message, clicking on send closes the email window but doesn't actually send the email. The method - (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error logs email sent but the mail does not reach it's destination. tried several email accounts.
I can write a message, clicking on send closes the email window but doesn't actually send the email
This is in fact within the spec, as documented:
Using this interface does not guarantee immediate delivery of the corresponding email message
Lots of things can go wrong, lack of Internet connection being among the most obvious. And of course even if the email is sent, that is no guarantee that it will reach anyone; other things can go wrong down the line.
When i share an iTunes url on Facebook using SLComposerViewController, the post on Facebook is not showing the link description. Where as if i try some other URL's then i the post is showing the link description.
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet addImage:[UIImage imageNamed:#"s_720.jpg"]];
[mySLComposerSheet setInitialText:#"check my swap card..."];
[mySLComposerSheet addURL:[NSURL URLWithString:[swap_card_dict valueForKey:#"swapcard_url"]]];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(#"Post Canceled");
break;
case SLComposeViewControllerResultDone:
{
NSLog(#"Post Sucessful");
}
break;
default:
break;
}
}];
[[self viewController] presentViewController:mySLComposerSheet animated:YES completion:nil];
}
I am working on an app that automatically sends me an email message in certain circumstances but
I am unable to automatise the sending of the email, as the message composer picker comes up and I am required to physically press on the Send button...
Is it possible to automatise the "pressure" on the SEND button or does Apple prevent this to avoid spamming maybe?
What are the options for "completion"?
If this is not possible, is it then possible to send the email without using the message picker?
To bring up the message interface I'm using:
[self presentViewController:picker animated:YES completion:nil];
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(#"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(#"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(#"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(#"Mail sent failure: %#", [error localizedDescription]);
break;
default:
break;
}
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}
It is not possible to send an email from the user's mail account without MFMailComposeViewController and user's explicit interaction.
I was wondering if I need to create a facebook app to do a share on facebook.
I don't want the user to actually login or something like this.
As I see in the facebook docs it says that the prerequisite is to "make sure you already set up Facebook Login". I wanted to know if this is really needed or is something I can by pass, since the user is already logged in on their native facebook app.
I think you are talking about to store id and password of facebook.
you should do it from settings... and also you can check by logic that facebook id and password is entered or not.. if not then session will go for login page otherwise it ll just share the perticular thing.
Hope this Helps you...
Here is what I was talking about:
#pragma mark - Share
- (void)sharingStatus {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
NSLog(#"service available");
self.shareButton.enabled = YES;
self.shareButton.alpha = 1.0f;
} else {
self.shareButton.enabled = NO;
self.shareButton.alpha = 0.5f;
}
}
- (IBAction)facebookPost:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSString *shareText = #"This is my share post!";
[mySLComposerSheet setInitialText:shareText];
[mySLComposerSheet addImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:self.imageURL]]];
[mySLComposerSheet addURL:[NSURL URLWithString:#"http://yourURL.com"]];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(#"Post Canceled");
break;
case SLComposeViewControllerResultDone:
NSLog(#"Post Sucessful");
break;
default:
break;
}
}];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
}