regarding potential leak - iphone

am getting the potential leak in the following code.(returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];)pls help me to find out.
+ (NSString *) getResponseFromServer:(NSString *) url
{
NSString *URLString1 = [NSString stringWithContentsOfURL:[NSURL URLWithString:#"http://www.google.com"]];
if(URLString1 == NULL)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Info" message:#"You must be connected to the Internet to use this app. Wireless , 3G and EDGE are supported" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
alert.delegate = self;
[alert show];
[alert release];
return #"NO" ;
}
else
{
//CFStringRef escapeChars = (CFStringRef) #":/?#[]#!$&’()*+,;=";
// url = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)url, NULL, escapeChars, kCFStringEncodingUTF8);
url = [url stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
//[self alert:escapedUrlString];
url=[url stringByReplacingOccurrencesOfString:#"%2526" withString:#"%26"];
//NSLog(#"url 2 = %# ",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:url]];
NSLog(#"******Loading URL = %#",[NSURL URLWithString:url]);
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = #"";
if(returnData)
{
returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; //Potential leak here...
// NSRange range = [str rangeOfString:supplierSearchText.text options:NSCaseInsensitiveSearch];
//NSLog(#"Searching = %d, %#, %#, %d", i, str, supplierSearchText.text, range.location);
//if(range.location == 0)
int num = [url rangeOfString:#"iphone_logout.php" options:NSCaseInsensitiveSearch].location;
NSLog(#">>>>>>>>> NUmber = %d", num);
if(isUserLoggedIn > 0 && global_Timer != nil && num > 1000)
{
if(((int)([url rangeOfString:#"iphone_user.php" options:NSCaseInsensitiveSearch].location) < 1000) ||
((int)([url rangeOfString:#"company_name.php" options:NSCaseInsensitiveSearch].location) < 1000) ||
((int)([url rangeOfString:#"company_search.php" options:NSCaseInsensitiveSearch].location) < 1000) ||
((int)([url rangeOfString:#"view_web.php" options:NSCaseInsensitiveSearch].location) < 1000))
{
[global_Timer invalidate];
NSLog(#">>>>>>>> Timer invalidating >>>>>>>>>>>>>>, %d, %d, %d, %d", ((int)([url rangeOfString:#"iphone_user.php" options:NSCaseInsensitiveSearch].location) > -1) , ((int)([url rangeOfString:#"company_name.php" options:NSCaseInsensitiveSearch].location) > -1) , ((int)([url rangeOfString:#"company_search.php" options:NSCaseInsensitiveSearch].location) > -1), ((int)([url rangeOfString:#"view_web.php" options:NSCaseInsensitiveSearch].location) > -1) );
global_Timer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)300.0 target:global_SupplierToolsViewController selector:#selector(pressButton_Logout) userInfo:nil repeats:NO];
}
else {
NSLog(#"No matches found!, %d", (int)([url rangeOfString:#"iphone_user.php" options:NSCaseInsensitiveSearch].location));
}
}
}
else //if(!networkFlag)
{
//networkFlag = YES;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Network connection failed! Try again later!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return #"NO";
}
//[url release];
[request release];
return returnString;
}
}

You could add autorelease to the creation of the string.
In general, any time you use alloc you need to either use autorelease or else use release.

You have a path that returns before releasing the request.
else //if(!networkFlag)
{
//networkFlag = YES;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Network connection failed! Try again later!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return #"NO";
}
//[url release];
[request release];

You are alloc-ing returnString without a matching release.
Try having an autoreleased string, like so:
returnString = [NSString stringWithData:returnData encoding:NSUTF8StringEncoding];

Related

Want to get my captured video back

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];
}
}

detecting youtube video links programmatically in Objective-C

I need to download and save videos from video sites like youtube. I want to save them to the video library of the iPhone. How can I detect the videos and save them to library? I already checked out some source codes available. This is what i have done in the download action, but is not working.
- (IBAction)download {
[downloadButton setEnabled:NO];
[webView setUserInteractionEnabled:NO];
UIUserInterfaceIdiom userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom;
NSString *getURL = #"";
if (userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
getURL = [webView stringByEvaluatingJavaScriptFromString:#"function getURL() {var player = document.getElementById('player'); var video = player.getElementsByTagName('video')[0]; return video.getAttribute('src');} getURL();"];
} else {
getURL = [webView stringByEvaluatingJavaScriptFromString:#"function getURL() {var bh = document.getElementsByClassName('bh'); if (bh.length) {return bh[0].getAttribute('src');} else {var zq = document.getElementsByClassName('zq')[0]; return zq.getAttribute('src');}} getURL();"];
}
NSString *getTitle = [webView stringByEvaluatingJavaScriptFromString:#"function getTitle() {var jm = document.getElementsByClassName('jm'); if (jm.length) {return jm[0].innerHTML;} else {var lp = document.getElementsByClassName('lp')[0]; return lp.childNodes[0].innerHTML;}} getTitle();"];
NSString *getTitleFromChannel = [webView stringByEvaluatingJavaScriptFromString:#"function getTitleFromChannel() {var video_title = document.getElementById('video_title'); return video_title.childNodes[0].innerHTML;} getTitleFromChannel();"];
NSLog(#"%#, %#, %#", getURL, getTitle, getTitleFromChannel);
[webView setUserInteractionEnabled:YES];
NSArray *components = [getTitle componentsSeparatedByCharactersInSet:[[NSCharacterSet alphanumericCharacterSet] invertedSet]];
getTitle = [components componentsJoinedByString:#" "];
if ([getURL length] > 0) {
if ([getTitle length] > 0) {
videoTitle = [getTitle retain];
bar = [[UIDownloadBar alloc] initWithURL:[NSURL URLWithString:getURL]
progressBarFrame:CGRectMake(85.0, 17.0, 150.0, 11.0)
timeout:15
delegate:self];
[bar setProgressViewStyle:UIProgressViewStyleBar];
[toolbar addSubview:bar];
} else {
NSArray *components = [getTitleFromChannel componentsSeparatedByCharactersInSet:[[NSCharacterSet alphanumericCharacterSet] invertedSet]];
getTitleFromChannel = [components componentsJoinedByString:#" "];
if ([getTitleFromChannel length] > 0) {
videoTitle = [getTitleFromChannel retain];
bar = [[UIDownloadBar alloc] initWithURL:[NSURL URLWithString:getURL]
progressBarFrame:CGRectMake(85.0, 17.0, 150.0, 11.0)
timeout:15
delegate:self];
[bar setProgressViewStyle:UIProgressViewStyleBar];
[toolbar addSubview:bar];
} else {
//NSLog(#"%#", [webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('html')[0].innerHTML;"]);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"MyTube" message:#"Couldn't get video title." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
[downloadButton setEnabled:YES];
}
}
} else {
//NSLog(#"%#", [webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('html')[0].innerHTML;"]);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"MyTube" message:#"Couldn't get MP4 URL." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
[downloadButton setEnabled:YES];
}
}
This will grab the video ids if you are consistently expecting they to be in the < object > format.
Regex will obviously need to be changed if it's in an iframe.
NSError *error = nil;
NSRegularExpression *regex =
[NSRegularExpression regularExpressionWithPattern:#"<object .*name=\"movie\" value=\"[a-zA-z:\\/]*.com\\/\\w*\\/([A-Za-z0-9\\_-]*).*<\\/object>"
options:NSRegularExpressionCaseInsensitive
error:&error];
[regex enumerateMatchesInString:pageSource options:0 range:NSMakeRange(0, [string length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop){
NSString *videoID = [pageSource substringWithRange:[match rangeAtIndex:1]];
}];
You can save downloaded videos either to photos album or to the app directory itself.For downloading videos u have to generate a downloadble link of the corresponding video.In the case of downloading videos from the site youtube,refer this source code https://github.com/comonitos/youtube_video. Some sites are download restricted ones that may not be possible.In the case of all other sites by generating the downloadable url,you can make it work

In-App purchases not working on iPhone?

This is the code:
-(IBAction)purchase5010:(id)sender{
productUserRequests = 0;
SKPayment *payment = [SKPayment paymentWithProductIdentifier:#"com.mobice.wtm.5010"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:productUserRequests];
}else if(!validProduct){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"No products available at this time."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:productUserRequests];
}else if(!validProduct){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"No products available at this time."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
if (productUserRequests == 0) {
NSString *hints = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Hints"]];
int hintValue = [hints intValue];
hintValue+=50;
[hints release];
hints = [[NSString alloc]initWithFormat:#"%i", hintValue];
[hints writeToFile:[self pathOfFile:#"Hints"] atomically:YES];
NSString *reveals = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Reveals"]];
int revealValue = [reveals intValue];
revealValue+=50;
[reveals release];
reveals = [[NSString alloc]initWithFormat:#"%i", revealValue];
[reveals writeToFile:[self pathOfFile:#"Reveals"] atomically:YES];
}else if(productUserRequests == 1){
NSString *hints = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Hints"]];
int hintValue = [hints intValue];
hintValue+=150;
[hints release];
hints = [[NSString alloc]initWithFormat:#"%i", hintValue];
[hints writeToFile:[self pathOfFile:#"Hints"] atomically:YES];
NSString *reveals = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Reveals"]];
int revealValue = [reveals intValue];
revealValue+=20;
[reveals release];
reveals = [[NSString alloc]initWithFormat:#"%i", revealValue];
[reveals writeToFile:[self pathOfFile:#"Reveals"] atomically:YES];
}
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"In-app purchase failed. No money was charged."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
}
}
Now, whenever I attempt to purchase the item, it says "No products available at this time.", and also "In-app purchase failed. No money was charged."
I want to know, is there something wrong with the code above? Or is it more likely an itunes connect issue?
Instead of the full bundle id for the request: #"com.mobice.wtm.5010", go ahead and feed it just a #"5010".
For example I have a product com.example.somerandomapp.track01 the following code works:
SKPayment *paymentRequest = [SKPayment paymentWithProductIdentifier: #"track01"];
There are alot of different factors that can lead to the error, this is a good list of what can lead to failure here

How to pase a JSON array in iphone sdk?

I have a login form where the user can login only with the valid memberID and password. If the user enter correct enamel and password i get a result string contains the user information that the user created in the signup process, if it the password is wrong it shows the status 400 as the result string, the result string is the json array which contains one f the above values, one thing is the if the success login occur it gives the staus 200 along with the user information, my need is to retrieve the status message from the array and i need to validate it within the app, if the login success(status 200) it needs to be redirected to the main page; if it is(status 400) it shows a unsuccessful login message.
my code:
EDit
-(IBAction)_clicksbtnsignIN:(id) sender
{
[_txtmemberId resignFirstResponder];
[_txtpassword resignFirstResponder];
NSString *connectionstring = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:#"http://www.google.com"]];
if ([connectionstring length]==0) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Error" message:#"you are not connected to the internet" delegate:self cancelButtonTitle:#"ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
//NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *emailString = _txtmemberId.text; // storing the entered email in a string.
// Regular expression to checl the email format.
NSString *emailReg = #"[A-Z0-9a-z._%+-]+#[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:#"SELF MATCHES %#", emailReg];
//[pool drain];
if (_txtmemberId.text.length == 0 || _txtpassword.text.length == 0) {
UIAlertView *alertblnk = [[UIAlertView alloc]initWithTitle:#"ALERT" message:#"Fill the required text fields" delegate:self cancelButtonTitle:#"ok" otherButtonTitles:nil];
[alertblnk show];
[alertblnk release];
}
if (([emailTest evaluateWithObject:emailString] != YES) || [emailString isEqualToString:#""])
{
UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:#" Alert" message:#"Invalid Email ID" delegate:self
cancelButtonTitle:#"OK" otherButtonTitles:nil];
[loginalert show];
[loginalert release];
}
else {
[_spinner startAnimating];
NSString *uname = _txtmemberId.text;
NSString *pwd = _txtpassword.text;
NSString *urlVal = #"http://dev.eltouchapps.net/api/?app=1&type=m1&action=t2&var1=";
NSString *urlVal1 = [urlVal stringByAppendingString:uname];
NSString *urlVal2 = [urlVal1 stringByAppendingString:#"&var2="];
NSString *urlVal3 = [urlVal2 stringByAppendingString:pwd];
NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)urlVal3,NULL, (CFStringRef)#"\n" "",kCFStringEncodingUTF8 );
NSURL *url = [NSURL URLWithString:encodedString];
NSString *resultString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:#" Message" message:resultString delegate:self
cancelButtonTitle:#"OK" otherButtonTitles:nil];
[loginalert show];
[loginalert release];
lblresult.text = resultString;
NSString *responseString = [resultString responseString];
NSLog(#"Got Profile: %#", responseString);
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *firstName;
if ([[responseJSON valueForKey:#"Status"] isEqualToString:#"200"]) // if success
{
ParallelReadViewController *detailViewController = [[ParallelReadViewController alloc] initWithNibName:#"ParallelReadViewController" bundle:nil];
//detailViewController.firstString = firstString;
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
// do something
firstName = [responseJSON valueForKey:#"FirstName"];
}
}
}
}
Result string is why i get from the server. I know there is parsing of JSONB array we want , but i didn't know how to done this.
Thanks in advance.
based on assumption of your response , try below code
NSString *resultString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSMutableDictionary *responseJSON = (NSMutableDictionary *)[responseString JSONValue];
NSString *firstName;
if ([[responseJSON valueForKey:#"Status"] isEqualToString:#"200"]) // if success
{
// do something
firstName = [responseJSON valueForKey:#"FirstName"];
}
Hope it gives you an idea.
Check out this JSON framework: https://github.com/stig/json-framework/

Sending Email in background in iphone sdk with body

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");
}