简体   繁体   English

还有另一种在iOS中启动Messages应用程序的方法吗? (捐款)

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

We're trying to submit an iOS app that makes charitable SMS donations. 我们正在尝试提交一个可以进行慈善短信捐赠的iOS应用。 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. 但Apple不再愿意接受我们的方法,并拒绝了我们的应用程序。

Their claim is that the app doesn't comply with point 21.2 of the guidelines. 他们声称该应用程序不符合指南第21.2点的要求。 Which is: 这是:

21.2 The collection of donations must be done via a web site in Safari or an SMS 21.2捐赠的收集必须通过Safari或SMS中的网站完成

In the past, and in this current app, we are using MFMessageComposeViewController in the MessageUI framework to build the SMS message. 在过去,在当前的应用程序中,我们在MessageUI框架中使用MFMessageComposeViewController来构建SMS消息。 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: 在解决方案中心(以及拒绝争议)中经过一番反复思考之后,我能从Apple获得的最多关于我们应该做的事情是:

Sending SMS messages from within the app may not be in compliance with the App Store guidelines. 从应用程序内发送SMS消息可能不符合App Store指南。

and

The SMS link should launch Messages to make the donation. SMS链接应启动消息以进行捐赠。

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. 我们可以使用sms: URL方案为特定号码启动Messages应用程序,但该方法不允许我们添加所需的关键字。


So the question is: Does anyone know of another way of launching the Messages app? 所以问题是:有没有人知道启动Messages应用程序的另一种方式?

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. 我们的后备选项是放弃自己构建短信,并发出警告,告诉用户“ 文本YYYY到ZZZZ ”这是一个非常糟糕的用户体验。


Update (5th March 2013): 更新(2013年3月5日):

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. 我们再次与Apple竞争。


Update (6th March 2013): 更新(2013年3月6日):

After a stern message to Apple explaining the obvious... the app has passed submission. 向Apple发出严厉的消息后,解释了显而易见的......该应用程序已通过提交。

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. 如果您遇到同样的问题,我建议您先尝试投诉,然后再“修复”您的应用。

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. 我已经浏览了文档,而且您(相当令人沮丧地)在外部调用Messages应用程序时无法为您的消息设置正文。

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. 它提供的视图与作为ModalView的消息应用程序完全相同。 And for reference you can read the docs here . 作为参考, 您可以在这里阅读文档

  1. Import the MessageUI Framework to your project MessageUI Framework导入您的项目

  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). 将这些添加到视图的.h中,发送消息的操作已打开(在我的示例中为带有单个按钮的简单视图)。

     #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 . 上面的代码不会发送文本或取消视图,因为我们还没有实现messageComposeViewController:didFinishWithResult:方法 - 这里的文档可以在这里阅读。 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. 在每种情况下,您都可以显示提醒,关闭视图(如案例1)或应用程序所需的任何内容。

I am sure this second method should be approved or Apple should remove it from their documentation. 我确信第二种方法应该获得批准,否则Apple应该将其从文档中删除。 The key thing though is the canSendText if statement. 但关键是canSendText if语句。 If this (or the case switch for didFinishWithResult ) is not implemented Apple will certainly reject the app. 如果没有实现这个(或didFinishWithResult的case开关)Apple肯定会拒绝该应用程序。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM