Is there another way of launching the Messages app in iOS? (for donations)
Asked Answered
M

2

12

We're trying to submit an iOS app that makes charitable SMS donations. We've done a number of these in the past without issue; but Apple is no longer willing to accept our approach and have rejected our app.

Their claim is that the app doesn't comply with point 21.2 of the guidelines. Which is:

21.2 The collection of donations must be done via a web site in Safari or an SMS

In the past, and in this current app, we are using MFMessageComposeViewController in the MessageUI framework to build the SMS message. We use this because; being a donation to a shortcode we need to be able to write a keyword in the message.

After a bit of back-and-forth in the Resolution Center (and a Rejection Dispute) the most I can get out of Apple about what we're supposed to do is:

Sending SMS messages from within the app may not be in compliance with the App Store guidelines.

and

The SMS link should launch Messages to make the donation.

We can use the sms: URL scheme to launch the Messages app for a certain number, but that method doesn't allow us to add our required keyword.


So the question is: Does anyone know of another way of launching the Messages app?

Our fallback option is to give up building an SMS message ourselves and have an alert that tells the user "Text YYYY to ZZZZ" which is a pretty poor user experience.


Update (5th March 2013):

We resubmitted the app again with our alert-only fallback option ... it was rejected again for the same reasons. We are, again, contesting it with Apple.


Update (6th March 2013):

After a stern message to Apple explaining the obvious... the app has passed submission.

I wrote:

We have to disagree. The app does not include the ability to collect charitable donations within the app. It only informs the user on how they can donate.

So; if you have the same problem I suggest trying to complain first before going about 'fixing' your app.

Marinamarinade answered 14/2, 2013 at 9:49 Comment(0)
H
20

Yes and No.

On a basic level: NO. I have had a look through the docs and you (rather frustratingly) cannot set a body for your message when calling the Messages app externally.

You can only:

  1. Open the messages app

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];
    
  2. Input a number to message to

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:+1234567890"]];
    

More Complex: YES. Here is the method and code to send an SMS with body. It presents a view exactly like the messages app as a ModalView. And for reference you can read the docs here.

  1. Import the MessageUI Framework to your project

  2. Add these to the .h of the view that the action to send a message is on (in my case a simple view with a single button).

    #import <MessageUI/MessageUI.h>
    #import <MessageUI/MFMessageComposeViewController.h>
    
  3. The important code to send the message should be similar to:

    -(IBAction)sendSMS:(id)sender {
    
        if([MFMessageComposeViewController canSendText]) {
            MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
            controller.body = @"Hello";
            controller.recipients = [NSArray arrayWithObjects:@"+1234567890", nil];
            controller.messageComposeDelegate = self;
            [self presentViewController:controller animated:YES completion:nil];
        }
    }
    

The above code will not send texts or cancel the view as we have not implemented the messageComposeViewController:didFinishWithResult: method - the docs for this can be read here. This will look like the following:

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller 
                 didFinishWithResult:(MessageComposeResult)result {
    switch(result) {
        case MessageComposeResultCancelled:
            // user canceled sms
            [self dismissViewControllerAnimated:YES completion:nil];
            break;
        case MessageComposeResultSent:
            // user sent sms
            //perhaps put an alert here and dismiss the view on one of the alerts buttons
            break;
        case MessageComposeResultFailed:
            // sms send failed
            //perhaps put an alert here and dismiss the view when the alert is canceled
            break;
        default:
            break;
    }
}

In each case you can you can present alerts, dismiss the view (as in case 1), or anything your app requires.

I am sure this second method should be approved or Apple should remove it from their documentation. The key thing though is the canSendText if statement. If this (or the case switch for didFinishWithResult) is not implemented Apple will certainly reject the app.

Haynes answered 14/2, 2013 at 10:1 Comment(5)
We've taken the second route; almost exactly as you describe. They've still failed us. The only thing we do differently is that we don't have a switch-case in didFinishWithResult - we dismiss the controller regardless of the result.Marinamarinade
Ahh, I have just read a lot about your situation and I think its one of those things Apple are reluctant on changing. It seems ok to buy things for a pretend farm inside the app - where they get their cut - but not donating to charity. I guess the options are to wait it out and instruct your users to type in the word of phrase (perhaps you can automatically copy the text to clipboard to make the process easier and more user friendly).Haynes
The annoying part is that we've done it this way before a few times with donation apps. Now we have to explain to our client that Apple have had a change of heart. The clipboard idea is nice; but would require more user-instruction than it's worth. Cheers for the thoughts.Marinamarinade
No problem. Good luck with it all. You'd think there would be a bit more leeway for non-profit organisations.Haynes
I know this is an old thread, but you can use the first option in this answer and have it auto-populate the message body (which is what I believe the question was). use exactly as stated, but add the message body to the string like so: URLWithString:@"sms:+1234567890&body=this is the message text"Cautionary
D
6

You can set the body as well, but you have to escape the string.

NSString *sms = @"sms://+1234567890&body=This is the body.";

NSString *url = [sms stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
Dunsany answered 10/3, 2016 at 15:26 Comment(1)
I'm not sure if this was always this way with the sms: scheme, but it seems to be the case now.Marinamarinade

© 2022 - 2024 — McMap. All rights reserved.