[英]Social framework - how to know if message was sent or not
我在我的項目(iOS6)中使用Social framework
,因此用戶可以在Facebook或Twitter上發布帖子。
我的問題是,如果有辦法找出用戶是否已將帖子發送到社交網絡,或者他已取消該帖子並且尚未發布任何內容?
我使用此代碼在Twitter上分享帖子:
-(IBAction)askOnTwitter
{
if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
{
[self showErrorAlert];
twitterButton.enabled = NO;
return;
}
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[slComposeViewController setInitialText:@"Hey"];
[self presentViewController:slComposeViewController animated:YES completion:nil];
// So have user published a post or he haven't? How to know?
}
}
有人知道這個伎倆嗎? 提前致謝。
您可以為撰寫視圖控制器設置完成處理程序。 在那里你將得到結果SLComposeViewControllerResultDone
或SLComposeViewControllerCancelled
__block __weak SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[slComposeViewController setCompletionHandler:^
(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultDone) {
NSLog(@"Done successfully");
}
else{
NSLog(@"Cancelled");
}
[slComposeViewController dismissViewControllerAnimated:YES completion:nil];
}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.