the below code successfuly post my text on facebook wall now i want to post a image along with text using Below code
- (IBAction)callFacebookAPI:(id)sender
{
[self.txtinputfield resignFirstResponder];
if (txtinputfield.text.length !=0)
{
//create the instance of graph api
objFBGraph = [[FbGraph alloc]initWithFbClientID:FbClientID];
//mark some permissions for your access token so that it knows what permissions it has
[objFBGraph authenticateUserWithCallbackObject:self andSelector:#selector(FBGraphResponse) andExtendedPermissions:#"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins,publish_checkins,email"];
}
else
{
UIAlertView *objAlert = [[UIAlertView alloc]initWithTitle:#"Alert" message:#"Kindly enter data in the text field" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[objAlert show];
}
}
- (void)FBGraphResponse
{
#try
{
if (objFBGraph.accessToken)
{
SBJSON *jsonparser = [[SBJSON alloc]init];
FbGraphResponse *fb_graph_response = [objFBGraph doGraphGet:#"me" withGetVars:nil];
NSString *resultString = [NSString stringWithString:fb_graph_response.htmlResponse];
NSDictionary *dict = [jsonparser objectWithString:resultString];
NSLog(#"Dict = %#",dict);
NSMutableDictionary *variable = [[NSMutableDictionary alloc]initWithCapacity:1];
[variable setObject:txtinputfield.text forKey:#"message"];
[objFBGraph doGraphPost:#"me/feed" withPostVars:variable];
UIAlertView *objAlert = [[UIAlertView alloc]initWithTitle:#"Alert" message:#"String posted on your wall and you may check the console now" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[objAlert show];
}
}
#catch (NSException *exception) {
UIAlertView *objALert = [[UIAlertView alloc]initWithTitle:#"Alert" message:[NSString stringWithFormat:#"Something bad happened due to %#",[exception reason]] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[objALert show];
}
txtinputfield.text = clearText;
}
I tried some methods but did'nt work for me, i have no experience with Graph Api Any help will be appriated.Thanks
Try like below:
- (IBAction)buttonClicked:(id)sender
{
NSArray* permissions = [[NSArray alloc] initWithObjects:
#"publish_stream", nil];
[facebook authorize:permissions delegate:self];
[permissions release];
}
- (void)fbDidLogin
{
NSString *filePath =pathToImage;
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData, pathToImage,
#"picture/jpeg", #"contentType",
#"Video Test Title", #"title",
#"Video Test Description", #"description",
nil];
[facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
-(void)fbDidNotLogin:(BOOL)cancelled
{
NSLog(#"did not login");
}
- (void)request:(FBRequest *)request didLoad:(id)result
{
if ([result isKindOfClass:[NSArray class]])
{
result = [result objectAtIndex:0];
}
NSLog(#"Result of API call: %#", result);
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error
{
NSLog(#"Failed with error: %#", [error localizedDescription]);
}
Related
I'm using below code to share the content (from UITextView, UIImageView) through twitter
-(void)shareViaTweet:(NSString *)shareMessage{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:[NSString stringWithFormat:#"%#",shareMessage]];
if (self.imageString)
{
[tweetSheet addImage:[UIImage imageNamed:self.imageString]];
}
if (self.urlString)
{
[tweetSheet addURL:[NSURL URLWithString:self.urlString]];
}
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Sorry"
message:#"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
}
But I need share this, without using the pop up view (I think tweet sheet). It's happening because the below code,
[self presentViewController:tweetSheet animated:YES completion:nil];
When I click the button "Share" of my app, I need to post that in twitter.
Edited:
- (IBAction)doneButtonClicked:(id)sender
{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSString *message = messageTextView.text;
//hear before posting u can allow user to select the account
NSArray *arrayOfAccons = [account accountsWithAccountType:accountType];
for(ACAccount *acc in arrayOfAccons)
{
NSLog(#"%#",acc.username); //in this u can get all accounts user names provide some UI for user to select,such as UITableview
}
NSURL *url = [NSURL URLWithString:#"https://api.twitter.com"
#"/1.1/statuses/user_timeline.json"];
NSDictionary *params = #{#"screen_name" : message,
#"forKey":#"status",
#"trim_user" : #"1",
#"count" : #"1"};
// Request access from the user to access their Twitter account
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
// Populate array with all available Twitter accounts
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
//use the first account available
ACAccount *acct = [arrayOfAccounts objectAtIndex:0]; //hear this line replace with selected account. than post it :)
SLRequest *request =
[SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:url
parameters:params];
//Post the request
[request setAccount:acct];
//manage the response
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if(error)
{
//if there is an error while posting the tweet
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"Error in posting" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
else
{
// on successful posting the tweet
NSLog(#"Twitter response, HTTP response: %i", [urlResponse statusCode]);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"Successfully posted" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
}];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"You have no twitter account" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
}
else
{
//suppose user not set any of the accounts
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"Permission not granted" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
} ];
//[widgetsHandler closeWidget:nil];
//[self postImage:shareImageView.image withStatus:messageTextView.text];
}
Update: Error
To send images u need do something like this
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
// Populate array with all available Twitter accounts
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
//use the first account available
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
//create this request
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:#"https://api.twitter.com"#"/1.1/statuses/update_with_media.json"] parameters: [NSDictionary dictionaryWithObject:message forKey:#"status"]];
UIImage *imageToPost = [UIImage imageNamed:#"image.jpg"];
NSData *imageData = UIImageJPEGRepresentation(imageToPost, 1.0f);//set the compression quality
[postRequest addMultipartData:imageData withName:#"media" type:#"image/jpeg" filename:#"image.jpg"];
//set account and same as above code
....
....
if u wanna share the tweet without using the tweet sheet see my answer it will post on twitter wall without using the tweet sheet see hear and also set the twitter account in the device. hope this helps
unfortunately the class TWRequest is deprecated in iOS 6 but alternatively we can use SLRequest present in the Social framework
the answer for this is similar to the old answer
i commented out something that i dont want but if u want to select which account to use then uncomment the commented code
- (IBAction)doneButtonClicked:(id)sender
{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSString *message = _textView.text;
// NSArray *arrayOfAccons = [account accountsWithAccountType:accountType];
// for(ACAccount *acc in arrayOfAccons)
// {
// NSLog(#"%#",acc.username);
// NSDictionary *properties = [acc dictionaryWithValuesForKeys:[NSArray arrayWithObject:#"properties"]];
// NSDictionary *details = [properties objectForKey:#"properties"];
// NSLog(#"user name = %#",[details objectForKey:#"fullName"]);
// NSLog(#"user_id = %#",[details objectForKey:#"user_id"]);
// }
// Request access from the user to access their Twitter account
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
// Populate array with all available Twitter accounts
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
//use the first account available
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
// Build a twitter request
// TWRequest *postRequest = [[TWRequest alloc] initWithURL:
// [NSURL URLWithString:#"http://api.twitter.com/1/statuses/update.json"] parameters:[NSDictionary dictionaryWithObject:message forKey:#"status"] requestMethod:TWRequestMethodPOST]; //commented the deprecated method of TWRequest class
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:#"http://api.twitter.com/1/statuses/update.json"] parameters:[NSDictionary dictionaryWithObject:message forKey:#"status"]]; //use this method instead
//Post the request
[postRequest setAccount:acct];//set account
//manage the response
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if(error)
{
//if there is an error while posting the tweet
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"Error in posting" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
// on successful posting the tweet
NSLog(#"Twitter response, HTTP response: %i", [urlResponse statusCode]);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"Successfully posted" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"You have no twitter account" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
else
{
//suppose user not set any of the accounts
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Twitter" message:#"You have no twitter account" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
} ];
[account release];
}
I have created a camera using AVFoundation, now i want my video back so i can upload it on my server how can i do that ?
I am using MKNetworkKit for upload video on server.
I am getting output like this:
file://localhost/private/var/mobile/Applications/4B2E02E5-3EE2-493E-8ECF-4B1DA29B9387/tmp/output.mov
Guys I have figured out it by some help here is code for that.
- (void) captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)anOutputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{
videodata = [NSData dataWithContentsOfURL:outputFileURL];
//NSLog(#"output file url is :%#",anOutputFileURL);
NSLog(#"output video data size is:%d", videodata.length);
if ([[self delegate] respondsToSelector:#selector(recorder:recordingDidFinishToOutputFileURL:error:)]) {
[[self delegate] recorder:self recordingDidFinishToOutputFileURL:anOutputFileURL error:error];
}
//NSLog(#"captureOutput is: %#",captureOutput);
// NSLog(#"anOutputFileURL is: %#",anOutputFileURL);
//videoPath = [NSString stringWithContentsOfURL:anOutputFileURL encoding:NSUTF8StringEncoding error:nil];
//videoPath = [anOutputFileURL absoluteString];
//videoURL = anOutputFileURL;
// videodata = captureOutput;
// NSLog(#"video path is: %#",videodata);
UIAlertView *message = [[UIAlertView alloc] initWithTitle:nil
message:#"Do you want to upload this content to the yes stream network ?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Yes",#"No",nil];
[message show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Yes"])
{
NSLog(#"Yes was selected.");
self.flUploadEngine = [[fileUploadEngine alloc] initWithHostName:#"manektech.net" customHeaderFields:nil];
NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"testApp", #"appID",
nil];
self.flOperation = [self.flUploadEngine postDataToServer:postParams path:#"/dilipvideotest/savefile.php"];
[self.flOperation addData:videodata forKey:#"uploadfile" mimeType:#"video/mov" fileName:#"output.mov" ];
[self.flOperation onCompletion:^(MKNetworkOperation *operation) {
NSLog(#"response string is : %#", [operation responseString]);
/*
This is where you handle a successful 200 response
*/
}
onError:^(NSError *error) {
NSLog(#"error : %#", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[alert show];
}];
[self.flUploadEngine enqueueOperation:self.flOperation ];
}
else if([title isEqualToString:#"No"])
{
NSLog(#"No was selected.");
//[self readMovie:outputFileURL];
}
}
could anyone pls help me to post fotos on facebook using objective c for iphone app.i tried it but its getting terminated when i check with iphone.its working properly in simulator.following is my code i used to post in fb.i use graph api for developing my app.
-(void)fbGraphCallback:(id)sender {
if ((fbGraph.accessToken == nil) || ([fbGraph.accessToken length] == 0)) {
NSLog(#"You pressed the 'cancel' or 'Dont Allow' button, you are NOT logged into Facebook...I require you to be logged in & approve access before you can do anything useful....");
//restart the authentication process.....
[fbGraph authenticateUserWithCallbackObject:self
andSelector:#selector(fbGraphCallback:)
andExtendedPermissions:#"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"];
[self.view addSubview:viewshare];
}
else {
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];
//imgPicture is my image view name
NSLog(#"the Data::%#\n",imgPicture.image);
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:imgPicture.image];
[variables setObject:graph_file forKey:#"file"];
[variables setObject:[NSString stringWithFormat:#"%#", txtComment.text] forKey:#"message"];
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:#"me/photos" withPostVars:variables];
NSLog(#"postPictureButtonPressed: %#", fb_graph_response.htmlResponse);
NSLog(#"Now log into Facebook and look at your profile & photo albums...");
txtComment.text=#" ";
[txtComment setHidden:YES];
[lblcmt setHidden:YES];
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:#"Successfully posted...Now log into Facebook & look at your profile" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
[fbGraph release];
}
First I check if facebook(the facebook object) has a valid session:
if (![facebook_ isSessionValid]) {
permissions_ = [[NSArray arrayWithObjects:#"read_stream", #"publish_stream", #"offline_access",nil] retain];
[facebook_ authorize:permissions_];
}
When I can guaranty that i'm logged into facebook I post the image like this:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
image, #"picture",
message, #"message",
nil];
[facebook_ requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Finally I check this methods in for being sure if the image post was succesful or not:
-(void)request:(FBRequest *)request didFailWithError:(NSError *)error {
//Error
}
-(void)request:(FBRequest *)request didLoad:(id)result {
//Succes
}
i have implemented this sample code below to get a connection to the user feed post
- (void)viewDidLoad
{
[super viewDidLoad];
facebook = [[Facebook alloc] initWithAppId:#"197765190297119" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
facebook.accessToken = [defaults objectForKey:#"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:#"FBExpirationDateKey"];
}
and this sample code is called when the user logs in... it calls now by a button pressed for check, but dosent do any, perhaps i can get a dialog feed insted
NSString *str=#"Your String to post";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
str,#"message",
#"Test it!",#"name",
nil];
Facebook *fb = [[Facebook alloc] init];
[fb requestWithGraphPath:#"me/feed" // or use page ID instead of 'me'
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
This is a walkthrough of uploading an image to the facebook wall. I copied this out of an older application, the current facebook API works a little bit different. I think you can see my main point of using a shared facebook object, which you use to do the authentication and also the requests to the API. I took out a few things to make it easier to understand. Apple actually wants you to check for an existing internet connection. I hope it helps.
#synthesize facebook;
//login with facebook
- (IBAction) facebookButtonPressed {
if (!facebook || ![facebook isSessionValid]) {
self.facebook = [[[Facebook alloc] init] autorelease];
NSArray *perms = [NSArray arrayWithObjects: #"read_stream", #"create_note", nil];
[facebook authorize:FACEBOOK_API_KEY permissions:perms delegate:self];
}
else {
[self fbDidLogin];
}
}
//upload image once you're logged in
-(void) fbDidLogin {
[self fbUploadImage];
}
- (void) fbUploadImage
{
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
resultImage, #"picture",
nil];
[facebook requestWithMethodName: #"photos.upload"
andParams: params
andHttpMethod: #"POST"
andDelegate: self];
self.currentAlertView = [[[UIAlertView alloc]
initWithTitle:NSLocalizedString(#"Facebook", #"")
message:NSLocalizedString(#"Uploading to Facebook.", #"")
delegate:self
cancelButtonTitle:nil
otherButtonTitles: nil] autorelease];
[self.currentAlertView show];
}
//facebook error
- (void)request:(FBRequest*)request didFailWithError:(NSError*)error
{
[self.currentAlertView dismissWithClickedButtonIndex:0 animated:YES];
self.currentAlertView = nil;
UIAlertView *myAlert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(#"Error", #"")
message:NSLocalizedString(#"Facebook error message", #"")
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"OK", nil];
[myAlert show];
[myAlert release];
}
//facebook success
- (void)request:(FBRequest*)request didLoad:(id)result
{
[self.currentAlertView dismissWithClickedButtonIndex:0 animated:YES];
self.currentAlertView = nil;
UIAlertView *myAlert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(#"Facebook", #"")
message:NSLocalizedString(#"Uploaded to Facebook message", #"")
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"OK", nil];
[myAlert show];
[myAlert release];
}
I am developing on app in that i want to send email at the back ground.
for that i used the "SKPSMTP" library but when i got the mail it is without body so can any one tell me where i m wrong in my code.
following is the code on button click..
- (void)sendMessageInBack:(id)anObject
{
if(![self validateEmail:txt_email.text])
{
if([txt_email.text isEqualToString:#""] )
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Mandatory field" message:#"Please fill complete email" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
if(self.interfaceOrientation==UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation==UIInterfaceOrientationLandscapeRight )
{
if(rotate)
[btn_Send setImage:[UIImage imageNamed:#"send_button.png"] forState:UIControlStateNormal];
}
else if(self.interfaceOrientation==UIInterfaceOrientationPortrait || self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown )
{
if(rotate)
[btn_Send setImage:[UIImage imageNamed:#"send button1.png"] forState:UIControlStateNormal];
}
NSLog(#"Start Sending");
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:#"RequestReview.txt"];
NSData *dataObj = [NSData dataWithContentsOfFile:writableDBPath];
//NSString *mailid;
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail =#"spymekdemo#gmail.com";
testMsg.toEmail = #"priyanka.chinchmalatpure#gmail.com";// txtEmail.text;
testMsg.relayHost = #"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = #"spymekdemo#gmail.com";
testMsg.pass =#"spymek123";
testMsg.subject =#"Sbject"; //[NSString stringWithFormat:#"Reply to Review From %#", txtName.text];
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
// Only do this for self-signed certs!
testMsg.validateSSLChain = NO;
testMsg.delegate = self;
NSString *deviceIdentifier=[NSString stringWithFormat:#"%#",[[UIDevice currentDevice]uniqueIdentifier]];//[NSString stringWithFormat:#"%#",deviceToken.uniqueIdentifier];
NSLog(#"%#",deviceIdentifier);
//NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,
// [NSString stringWithFormat:#"Request Review\n\nDevice Identifier=%#\nProduct Name=%#\nProduct Download URL=%#\nUser Name=%#\nEmail=%#\nPromo Code=%#\nDescription Of Product=%#\n\n\n", deviceIdentifier, txtProduct.text,txtDownloadURL.text, txtName.text,txtEmail.text,txtPromocode.text, txtDescription.text]
// ,kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/html",kSKPSMTPPartContentTypeKey,
[NSString stringWithFormat:#"<h2>Request Review</h2><br/><br/><b>Thank you for giving us your review</b> <br/>Device Identifier=%#<br/>Product Name=<br/>Product Download URL=<br/>User Name=<br/>Email=<br/>Promo Code=<br/>Description Of Product=<br/><br/><br/>", deviceIdentifier]
,kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
// [NSString stringWithFormat:#"<h3>Review App</h3> <br/> <br/><b>Name=%#<b><br/> <br/>,\n<u>Email=%#</u><br/> <br/>,\nPassword=%#,<br/><br/> <b>\nComments=%#\n\n</b><br/>",txtName.text,txtMailId.text, txtPassword.text, txtComment.text],kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
// #"<html><body><h1>Review App</h1> <br/> <b>Some text to include in body</b></body></html>"
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:#"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"%#.txt\"",txt_name.text],kSKPSMTPPartContentTypeKey,
[NSString stringWithFormat:#"attachment;\r\n\tfilename=\"%#.txt\"",txt_name.text],kSKPSMTPPartContentDispositionKey,[dataObj encodeBase64ForData],kSKPSMTPPartMessageKey,#"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart, nil]; //vcfPart
[testMsg send];
}
}
rotate=YES;
}
- (void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
[message release];
//open an alert with just an OK button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Unable to send email"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
[alert release];
NSLog(#"delegate - error(%d): %#", [error code], [error localizedDescription]);
//[self ClearFile];
//UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"Request Review" message:#"Review Posting failed.. Try Again Later.." delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Done",nil];
}
- (void)messageSent:(SKPSMTPMessage *)message
{
[message release];
NSLog(#"delegate - message sent");
}