My App got rejected and reason is below:-
Did not integrate with iOS features. For example, the email button should enable users to compose emails in the app rather than launching the Mail app.
I did not get that what they want. I have used MFMailComposer class so what's wrong with it?Any Suggestion.
Did you do it like this:
- (IBAction)pushMail:(id)sender { //A button that initiates composition
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:#"My Mail Subject"];
if (controller) [self presentModalViewController:controller animated:YES];
[controller release];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error;
{
if (result == MFMailComposeResultSent) {
NSLog(#"It's away!");
}
[self dismissModalViewControllerAnimated:YES];
}
I think you have to use an MSMailComposeViewController (as I have in the above example) to do what you want.
... the email button should enable users to compose emails in the app ...
They mean that your program should allow people to compose emails, instead of opening Mail.app.
Related
I have a few questions regarding MFMessageComposeViewController:
Is there a way to know to whom the user actually sent the SMS to?
Or, at least be able to know to how many numbers the SMS was sent to?
What was the message that was actually sent?
Here is what I have so far, and it works OK. But It seems there is only one delegate, but it's so simple that it's pretty much useless.
- (void)showSMS:(NSArray *)numbers message:(NSString *)message {
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
[messageController setRecipients:numbers];
[messageController setBody:message];
[self presentViewController:messageController animated:YES completion:nil];
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result {
if (result == MessageComposeResultCancelled) {
NSLog(#"SMS cancelled");
}
else if (result == MessageComposeResultFailed) {
NSLog(#"SMS failed");
}
else if (result == MessageComposeResultSent) {
NSLog(#"SMS sent");
}
[self dismissViewControllerAnimated:YES completion:nil];
}
Thanks.
This isn't possible. The iOS SDK doesn't expose a way to access this.
From Apple's documentation of MFMessageComposeViewController:
Important: The message composition interface itself is not
customizable and must not be modified by your app. In addition, after
presenting the interface, your app is unable to make further changes
to the message content. The user can edit the content using the
interface, but programmatic changes are ignored. Thus, you must set
the values of content fields, if desired, before presenting the
interface.
I am adding some sharing in my app to allow the use to post to FaceBook and to Twitter. I decided to use the Social Sharing framework as it does exactly what I need and works well.
However I noticed that my app doesn't ask the user for permission it assumes it has permission and does a check if there is an account setup.
The problem I see here is due to this - my app doesn't appear in the Settings - > Twitter under "Allow these apps to use your account" section.
Her is the code I use when I want to share an item - user taps on a UIButton which presents a UIActionSheet with various options"
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler completionBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled){
NSLog (#"Cancelled");
}else {
NSLog(#"Done");
}
[controller dismissViewControllerAnimated:YES completion:nil];
};
controller.completionHandler = completionBlock;
NSURL *url = [NSURL URLWithString:self.item.url];
/* Adding the text to the Tweet */
[controller setInitialText:#"Online now!"];
[controller addURL:url];
[controller addImage:self.imageView.image];
[self presentViewController:controller animated:YES completion:nil];
}
else {
[self showUserAlert:#"" message:#"Please make sure your FaceBook account has been setup on this device"
delegate:self
cancelButtonTitle:#"Okay"];
}
How do I ask for access first? And add the app to the settings part of iOS so the user can turn it on or off?
I think you don't need a permission because your app can't post without user action. User have all control.
You can check if sharing possible with canSendTweet method in TWTweetComposeViewController. Look up Xcode documentation. I'm sure Apple has something similar for Facebook.
Apple documentation
I have created an application that uses the SMS and after the user clicks the sms button it opens up with my number already in and no message (thats their job). But when it loads up the sms message page it set the curser thing is up where the recipients are not where the message is. To explain that better, after the sms loads if they were to just start typing they would be adding another person to send the message to, not typing the message. For example if I would like to load up to a specific row on my UIPicker on startup I would:
[picker selectRow:3 inComponent:0 animated:NO];
sms load up:
- (IBAction)sms {
MFMessageComposeViewController *textComposer = [[MFMessageComposeViewController alloc] init];
[textComposer setMessageComposeDelegate:self];
if ([MFMessageComposeViewController canSendText]) {
[textComposer setRecipients:[NSArray arrayWithObjects: #"support#nicmacengineering.com", nil]];
[textComposer setBody:#""];
[self presentViewController:textComposer animated:YES completion:NULL];
} else {
NSLog(#"Can't Open Text");
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
NSLog(#"Cancelled");
break;
case MessageComposeResultFailed:
break;
case MessageComposeResultSent:
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
First, your question is fairly hard to understand. Here's my impression of it:
Can I set the cursor to the message field by default in an SMS controller?
And the answer is:
No.
Since it is an Apple framework, with no public method to switch fields (here's the class reference).
Because of this, you won't be able to automatically set the position of the cursor.
I am using MFMailComposeViewController in my app and the mail sending part seems to be OK.
But when I leave the mail app, things go wrong :
- one toolbar (UIToolbar object) has disappeared.
- one pointer (UIImageView*) has become nil, without me doing anything for that to happen.
In other words the calling environment is changed although I do not want it to change.
Where could be my mistake?
Here is my code, in case someone can see something wrong :
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[controller dismissModalViewControllerAnimated:YES];
}
-(IBAction)sendAsEMail {
MFMailComposeViewController *mailComposeViewController=[[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate=self;
[mailComposeViewController setSubject:#"Mail subject"];
[mailComposeViewController setMessageBody:#"This is for you !" isHTML:NO];
[mailComposeViewController addAttachmentData:
[NSData dataWithContentsOfFile:[[My_ViewController getDocDir] stringByAppendingPathComponent:
[pictureNames objectAtIndex:userItemSelected]]]
mimeType:#"image/png" fileName:#"Picture.png"];
if (mailComposeViewController) [self presentModalViewController:mailComposeViewController animated:YES];
[mailComposeViewController release];
}
Thanks for any piece of relevant information.
Try out this link it explain in detail
Add framework
Then .h file header files
Then .m file the mail code
Check at this link.
I am new in iPhone devlopment. I have an UITextView in a xib. There I displaying an email address link. I want to open iPhone's mail application while clicking on that email link. How can I achieve that?
As pointed out in this answer, you can set the dataDetectorTypes property of the UITextView:
textview.editable = NO;
textview.dataDetectorTypes = UIDataDetectorTypeAll;
You should also be able to set the detectorTypes in Interface Builder.
From Apple documentation:
UIDataDetectorTypes
Defines the types of information that can be detected in text-based content.
enum {
UIDataDetectorTypePhoneNumber = 1 << 0,
UIDataDetectorTypeLink = 1 << 1,
UIDataDetectorTypeAddress = 1 << 2,
UIDataDetectorTypeCalendarEvent = 1 << 3,
UIDataDetectorTypeNone = 0,
UIDataDetectorTypeAll = NSUIntegerMax
}; typedef NSUInteger UIDataDetectorTypes;
Clicking on the email address in your UITextView should then automatically open the Mail application.
On a side note, if you want to send the email from within your app itself, you can use the MFMailComposeViewController.
Note that for the MFMailComposeViewController to be shown, Mail app needs to be installed on the device, and have an account linked to it, otherwise your app will crash.
So you can check this with [MFMailComposeViewController canSendMail]:
// Check that a mail account is available
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController * emailController = [[MFMailComposeViewController alloc] init];
emailController.mailComposeDelegate = self;
[emailController setSubject:subject];
[emailController setMessageBody:mailBody isHTML:YES];
[emailController setToRecipients:recipients];
[self presentViewController:emailController animated:YES completion:nil];
[emailController release];
}
// Show error if no mail account is active
else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:#"Warning" message:#"You must have a mail account in order to send an email" delegate:nil cancelButtonTitle:NSLocalizedString(#"OK", #"OK") otherButtonTitles:nil];
[alertView show];
[alertView release];
}
MFMailComposeViewController Class Reference
In addition to the code above, once the user has pressed the send or cancel buttons you will need to dismiss the modal email view.
The MFMailComposeViewControllerDelegate protocol includes a method called "didFinishWithResult". This method will be automatically called as the view closes.
However, if you don't implement it, nothing will happen & the modal view will remain, bringing your app to a standstill!
The following code is required as a minimum:
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}