How to show email sent notification ipad - iphone

I've a mail controller which successfully sends email.
But I want to show a notification of "Email Sent Successfully" as the email is sent. Is there a way to do that?
Thanks.

If you are using MFMailComposeViewController, you can use its delegate method.
1. Set the delegate: mailController.mailComposeDelegate=self;
2. Then use the delegate method `
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
if(result == MFMailComposeResultSent)
{
UIAlertView*sentalert=[[UIAlertView alloc] initWithTitle:#"Mail Sent succesfully!" message:nil delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[sentalert show];
[sentalert release]; // if not using ARC
}
[self dismissModalViewControllerAnimated:YES]; //Dismiss your mail controller
}

Related

My alertview for the UIWebView doesn't work

Why doesn't this code work? All I have is this:
-(void)_webview:(UIWebView *)_webview didFailLoadWithError:(NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!" message:#"You have no internet connection!" delegate:self cancelButtonTitle:#"Close" otherButtonTitles:nil, nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
exit(0);
}
It should work, right?
Because you mistyped the name of the UIWebViewDelegate method. You have
_webview:didFailLoadWithError:
whereas the real name of this method is
webView:didFailLoadWithError:
The delegate method is mistyped, as stated in the above response. Also, did you set the delegate of the UIWebView to the instance of the class that has those methods implemented?
for example, if it's a view controller, it could be in viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
_webView.delegate = self;
}

Email Signature App Iphone

I am making an email signature application that allows user to make signatures and use them to send with emails, Their is signature name(Text Field), content(Text View) and image(Image View) and i am saving them in Database so that if the user selects the signature name from the table view that is on the second view the preview will show up on the same view like if i select signature 1 from table view then in preview section the signature image should show up with the signature content in (Text View), and then on the same view we press send(Button) the text and image from the Text View of preview section will be copied to clipboard and then in third view i can paste it in the message section and send the email, is it possible to do that if yes how can i implement it or any other idea how to do this ?
i have this one method for send email with image and message .. just add MFMessageComposeViewControllerDelegate in .h file and add framework MessageUI.framework in your project
-(void)sendMailWithImage:(NSString *)message Image:(UIImage *)image{
if ([MFMailComposeViewController canSendMail])
{
UIImage *tempImageSave=image;
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
NSString *mailBody = message;
NSData *imageData = UIImagePNGRepresentation(tempImageSave);
[mailComposeViewController addAttachmentData:imageData mimeType:#"image/png" fileName:#"Testing"];
[mailComposeViewController setMessageBody:mailBody isHTML:NO];
mailComposeViewController.mailComposeDelegate = self;
[self presentViewController:mailComposeViewController animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"e-Mail Sending Alert"
message:#"You can't send a mail"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
and this bellow method is delegate method of MFMessageComposeViewControllerDelegate
#pragma mark - MFMessage Delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent)
{
NSLog(#"\n\n Email Sent");
}
[self dismissViewControllerAnimated:YES completion:nil];
}
i hope this help you...

How to set actions for Push notification alert view in iOS

In my application I have implemented the Push notification feature and I am getting the notifications. I used the following code in the appDelegate file.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSMutableArray *array = [userInfo objectForKey:key];
NSString *message = [NSString stringWithFormat:#"%#",[array valueForKey:#"alert"]];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"iPhoneApp" message:message delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Ok", nil];
[alert show];
[alert release];
}
}
I want to perform actions on the OK button click event of the Push notification alert (when the app is running). I have three view controllers in this app. So in which class should I add the code
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex?
In the same class you set as the delegate of that particular UIAlertView. In your current case, the AppDelegate is the receiver of the -clickedButtonAtIndex:.
If you would like to receive the click events in one of the 3 controllers you have. You must set that particular controller as the delegate to your UIAlertView:
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"iPhoneApp" message:message delegate:myViewController cancelButtonTitle:#"Cancel" otherButtonTitles:#"Ok", nil];
[alert show];
[alert release];
As you see I assigned myViewController as the delegate. myViewController should conform to the UIAlertViewDelegate protocol and implement the -clickedButtonAtIndex: method. Now once you select one of the button's you will get the call in myViewController.

NSNotification issue

i want to show the alert box in my whole applicaton when we got the response from my Signin
how it is possible?
can we use NSNotification?
You could put a public method in your appdelegate and let it show your alertview.
You can access the app delegate like this:
[UIApplication sharedApplication].delegate
You'll need to cast it to you app delegate class to prevent a warning, then you can send the message:
[(MyAppDelegate *)[UIApplication sharedApplication].delegate showMyAlertView];
- (void)afterSignIn
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Title" message:#"Message" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
It's simple to create and receive notifications:
1) Add an observer (for example, it's YourViewController) to your notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(someEventHappend)
name:#"SomeEvent" object:nil];
You should add this code in viewDidLoad method.
2) Implement someEventHappend method in YourViewController
3) Post notification when you've git response from Signin:
[[NSNotificationCenter defaultCenter] postNotificationName:#"SomeEvent" object:nil];
After that NSNotificationCenter will call someEventHappend method on YourViewController
#anil take one and set this in Global.h "BOOL Signin" value .When When it's true
Then show
Your alter view like this
-(void)afterSignIn
{
if(Signin == YES)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Title" message:#"Meassage" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
it is not compulsory to use NSNotificationCenter

how to let user choose the mail receiver?

in my app i used the code below to handle the messages send from iphone i want to know how to let him choose between contact us and tell a friend like other apps how can i make this issue ?
the code :
-(IBAction)sendEmail {
//Create a new mailComposer object and set the mailComposeDelegate (required).
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
//Set Fields such as Subject, recipients, and message body.
[mailComposer setToRecipients:[NSArray arrayWithObjects:#"info#Myweb.com",nil]];
[mailComposer setSubject:#"App Feadback"];
//Present the mail view controller
[self presentModalViewController:mailComposer animated:YES];
}
//release the mailComposer as it is now being managed as the UIViewControllers modalViewController.
[mailComposer release];
}
//MFMailComposeControllerDelegate method that handles success or failure
//and dismisses the mailComposer
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
if (result == MFMailComposeResultFailed) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Message Failed" message:#"Your message failed to send" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
For Contact Us, you have to prefill your mail address to mailComposer.setToRecipient. as you have done.
And for tell a friend, you have to collect your friend's email address prior the mail composer in view. e.g. using Address book person picker control.
Whatever you do, MFMail composer will not allow you to do anything without the knowledge of the user. The user can delete/add in the mailto field when it pops up.