【发布时间】:2014-06-05 04:22:14
【问题描述】:
我将 twitter 与我的 iOS 7 应用程序集成在一起,第一次在 twitter 上分享时运行良好,并在分享“你的推文已发送”后向我显示消息。我在SLComposeViewControllerResultDone 案例中展示。但是,当我在 Twitter 上再次分享相同的消息时会发生什么,它会显示消息“Tweet myappname 是重复的,无法发送。”然后是SLComposeViewControllerResultDone 案例并向我显示我的消息“您的推文已发送”。当用户发送重复消息时,我无法获得任何指示或提示,因为那时我必须阻止自己的警报。请帮助我,我怎么知道用户何时在 Twitter 上发送了重复的消息。谢谢
代码:
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0f) { SLComposeViewController *twitterController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
// if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
//{
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[twitterController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
// NSLog(@"Posted....");
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
message:@"Your Tweet has been sent."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
break;
}};
[twitterController setInitialText:@"MY App"];
[twitterController addURL:[NSURL URLWithString:@"http://google.com/"]];
[twitterController setCompletionHandler:completionHandler];
[self presentViewController:twitterController animated:YES completion:nil];
}
【问题讨论】:
-
您不能在短时间内发送两条完全相同的推文。它是 twitter 的事情..不是 iOS 7 的问题..
-
谢谢,我明白这一点,但是作为开发人员,当用户在短时间内发送重复消息时,我必须在 Result Done 案例中阻止我自己的消息,这可能是 twitter 给我们任何关于重复消息的提示吗?
-
如果您想限制用户在短时间内发送相同的推文或在特定时间成功分享后禁用“分享”按钮,则需要在代码中添加“NSTimer”。但我仍然会说你不需要这样做,因为 twitter 本身给你的信息是“重复”..
-
谢谢@JohnDoe,我不想限制用户发送相同或重复的消息,我只想隐藏我的警报,上面写着“您的推文已发送”。当用户发送重复消息时。可能吗?
-
为什么不添加一个简单的 if - 条件.. if([message isEqualToString:@"Tweet myappname 是重复的,无法发送。"]){ NSLog(@"随便你想在这里"); } else { //显示警报 }