检查用户是否与Twitter共享

时间:2015-10-21 13:49:50

标签: objective-c twitter share sharing

我正在使用UIActivityViewController来显示我的分享对话。

如何检查用户是否使用Twitter / Facebook /等?

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
UIPopoverPresentationController *presentationController = [activityViewController popoverPresentationController];

[self presentViewController:activityViewController animated:YES completion:nil];

我想自定义文本以便与不同的服务共享,所以这会非常有用。

1 个答案:

答案 0 :(得分:1)

您可以像这样使用 setCompletionWithItemsHandler

更新 - 删除if(complete)

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];

[activityViewController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError)
{
     //if (completed)
     //{
         if ([activityType isEqualToString:UIActivityTypeMail]) {
           //code for email
         } else if ([activityType isEqualToString:UIActivityTypeMessage]) {
           //code for iMessage
         } else if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
           //code for Facebook
         } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
           //code for twitter
         }
     //}
 }];

UIPopoverPresentationController *presentationController = [activityViewController popoverPresentationController];

[self presentViewController:activityViewController animated:YES completion:nil];