I have added MFMailComposeViewController to my application. In the MFMailComposeViewController
there is a button at the top of left side name Cancel. When i click the cancel button it shows an UIActionSheet with three option (save/delete/cancel).
My doubt is when i click the delete draft button it cancel the MFMailComposeViewController.The same process is for save draft button.But i dont know what function it does, when i click the cancel,save,delete (draft) What it will do and how can we check this ?(Whether is correct or not).
And also where can i view the saved draft mails in iphone.Is this possible ?If we can able to delete some option from UIActionSheet.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
}
I searched lot about this but didnt get an answer.I am running with iphone os 4.0 simulator.
Plz help me ?
Thanks in advance....
In the simulator, nothing is done with the mail you compose, regardless of which option you choose (even if you choose to send the email). On the device, the mail is either deleted or saved to the user's drafts folder in the Mail application, depending on the choice made.
It is not possible to alter the options available in this action sheet, as it is entirely controlled by the mail compose view controller.
You need to implement MFMailComposeViewControllerDelegate here, and implement the below method:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
NSString *message = #"";
// Notifies users about errors associated with the interface
switch (result) {
case MFMailComposeResultCancelled:
message = #"Mail: canceled";
break;
case MFMailComposeResultSaved:
message = #"Mail: saved";
break;
case MFMailComposeResultSent:
message = #"Mail: sent";
break;
case MFMailComposeResultFailed:
message = #"Mail: failed";
break;
default:
message = #"Mail: not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}
Related
I am sending SMS programmatically like this for a long time now. It worked without any problems in iOS6.
But now after update to iOS7 some users have probelms with the app. They need to deinstall the app - reboot the iPhone - reinstall it and then it works.Just reinstalling it without rebooting the phone does not work either.
What could be the reason for this really annoying problem?
Furthermore there are a few cases where they can send several SMS after this procedure but then the iPhone SMS-Dialog appears very slowly and no SMS is being sent again, until they restart the iPhone. Just stopping and restarting the app does not help.
Here's the normal SMS code:
MFMessageComposeViewController *messageVC = [[MFMessageComposeViewController alloc] init];
[messageVC setMessageComposeDelegate:self];
if ([MFMessageComposeViewController canSendText]) {
NSString *smsString = [NSString stringWithFormat:#"bla bla bla"];
messageVC.body = smsString;
messageVC.recipients = #[userPhone];
messageVC.messageComposeDelegate = self;
[self presentViewController:messageVC animated:YES completion:nil];
}
I even released a new Version of the app with the newest Xcode 5.0 with Deployment Target 5.1, since I need to support iOS5.1 users still.
There isn't enough information to tell what's causing the problem. Btw, why are you setting messageComposeDelegate twice?
This is apple's most recent sample code that I've modified worked on my own devices running iOS 7 and iOS 8. Make sure to import MessageUI.framework.
/* -------------------------------------------------------------------------------
showSMSPicker:
IBAction for the Compose SMS button.
------------------------------------------------------------------------------- */
- (IBAction)showSMSPicker:(id)sender
{
/* Checks that the current device can send SMS messages. If no, [[MFMessageComposeViewController alloc] init] will return nil and the app will
crash when -presentViewController:animated:completion: is called with a nil view controller */
if ([MFMessageComposeViewController canSendText])
// The device can send email.
{
[self displaySMSComposerSheet];
}
else
// The device can not send email.
{
self.feedbackMsg.hidden = NO;
self.feedbackMsg.text = #"Device not configured to send SMS.";
}
}
/* -------------------------------------------------------------------------------
displayMailComposerSheet
Displays an SMS composition interface inside the application.
------------------------------------------------------------------------------- */
- (void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
/* One or more preconfigured recipients can be specified. The user has the option to remove
or add recipients from the message composer view controller */
/* picker.recipients = #[#"Phone number here"]; */
// Message body
picker.body = #"This is a message about how great this app is. Please download it by clicking on the link below.";
[self presentViewController:picker animated:YES completion:nil];
}
/* -------------------------------------------------------------------------------
messageComposeViewController:didFinishWithResult:
Dismisses the message composition interface when users tap Cancel or Send.
Proceeds to update the feedback message field with the result of the
operation.
------------------------------------------------------------------------------- */
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result
{
self.feedbackMsg.hidden = NO;
// Notifies users about errors associated with the interface
switch (result)
{
case MessageComposeResultCancelled:
self.feedbackMsg.text = #"Result: SMS sending canceled";
break;
case MessageComposeResultSent:
self.feedbackMsg.text = #"Result: SMS sent";
break;
case MessageComposeResultFailed:
self.feedbackMsg.text = #"Result: SMS sending failed";
break;
default:
self.feedbackMsg.text = #"Result: SMS not sent";
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I am sending email from iphone app i want that when user clicks send button of email after that it should call test() method any idea how to do this I am using following code.
NSString * emailBody =#"<html><body>Thank you for your participation in Consulting<br>Practitioner and Client Program.</br><br>Attached is the copy of your signed contract for your records<p>Please email or fax your completed W-9 form to<br>our PEI Support Team<br>Email:PEISupportServices#zoetis.com<br>Fax:800-741-1310<body></html>";
[picker setMessageBody:emailBody isHTML:YES];
[self.navigationController presentViewController:picker animated:YES completion:nil];
}
}
[self test];
}
Please try to implemente this delegate method? It's called after the composer is exited by the user.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
NSString *message = #"";
// Notifies users about errors associated with the interface
switch (result) {
case MFMailComposeResultCancelled:
message = #"Mail: canceled";
break;
case MFMailComposeResultSaved:
message = #"Mail: saved";
break;
case MFMailComposeResultSent:
message = #"Mail: sent";
//------- call your test method here
break;
case MFMailComposeResultFailed:
message = #"Mail: failed";
break;
default:
message = #"Mail: not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}
I want to check if an alert is already present on my window or not. The alert is that of GPS (sumthing like "your app" will like to use your current location with Don't Allow and Allow buttons). I want to set some flag if this alert is present on screen. If anyone knows it, then please help me in getting this solved.
for (UIWindow* window in [UIApplication sharedApplication].windows) {
NSArray* subviews = window.subviews;
if ([subviews count] > 0)
if ([[subviews objectAtIndex:0] isKindOfClass:[UIAlertView class]])
return YES;
}
return NO;
this will help...
If you are developing for ios4.2 or later than you can authorizationStatus of CLLocationManager class.
For this you will need to check [CLLocationManager authorizationStatus] variable if its value is kCLAuthorizationStatusNotDetermined then it the alert will be shown.
In iOS 5 or later their is one option through which use can reset the location warning in that case also the status will be kCLAuthorizationStatusNotDetermined. So if your application is running and user switches to setting to reset that property than you will need to implmenet the following delegate method of CLLocationManagerDelegate.
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
switch (status)
{
case kCLAuthorizationStatusNotDetermined:
//If this is the case than alert will be shown
break;
case kCLAuthorizationStatusDenied:
break;
case kCLAuthorizationStatusRestricted:
break;
case kCLAuthorizationStatusAuthorized:
break;
default:
break;
}
}
Thanks,
i am using Twitter with IOS - 5 integration. i used tweeting app provide by apple for this.I am using TWTweetComposeViewController for this.
But if i have more than 2 twitter accounts. it is getting my first account every time. but i want that list of my different account shown to me and then when i select one of account and then i can use it with TWTweetComposeViewController. i like to show like bellow image From :"username"
i have used this code :
- (IBAction)sendEasyTweet:(id)sender {
// Set up the built-in twitter composition view controller.
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
// Set the initial tweet text. See the framework for additional properties that can be set.
[tweetViewController setInitialText:#"Hello. This is a tweet."];
[tweetViewController addImage:[UIImage imageNamed:#"Icon.png"]];
// Create the completion handler block.
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
NSString *output;
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
// The cancel button was tapped.
output = #"Tweet cancelled.";
break;
case TWTweetComposeViewControllerResultDone:
// The tweet was sent.
output = #"Tweet done.";
break;
default:
break;
}
[self performSelectorOnMainThread:#selector(displayText:) withObject:output waitUntilDone:NO];
// Dismiss the tweet composition view controller.
[self dismissModalViewControllerAnimated:YES];
}];
// Present the tweet composition view controller modally.
[self presentModalViewController:tweetViewController animated:YES];
}
Unfortunately, TWTweetComposeViewController doesn't give you much configuration flexibility. If you tap on the account name it will pop up your list of accounts. TWTweetCVC does seem to remember the last account you tweeted with though.
If you use ACAccountStore you can get the list of the users Twitter accounts and you could provide your own UI to choose one but you cannot configure TWTweetComposeViewController to use it. If you couple that with TWRequest you can roll your own tweet sheet class and do this yourself.
DETweetComposeViewController is a drop-in replacement for TWTweetComposeViewController. It's open source, so you can modify it to meet your needs. It's also compatible with iOS 4.
Now , i am getting my it , and picker is showing for it as shown in image
so from this picker , i can select one of my account for tweet.
When a user double clicks the home button and swipe right, some audio controls shows.
How do I get use them?
I've searched but havn't found anything that helps me.
Try this
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[self playTapped];
break;
case UIEventSubtypeRemoteControlPreviousTrack:
[self previousTapped];
break;
case UIEventSubtypeRemoteControlNextTrack:
[self nextTapped];
break;
default:
break;
}
PlayTapped is the method for playing the music.
nextTapped is the method for the next song to be played.
previousTapped is for playing the previous track.
All the best