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

我怕爱的太早我们不能终老 提交于 2019-11-29 03:32:52

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/14871949/is-there-another-way-of-launching-the-messages-app-in-ios-for-donations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!