即使用户解雇,UIActivityViewController whatsapp总是返回yes

时间:2017-04-19 07:37:17

标签: objective-c uiactivityviewcontroller

我尝试从我的应用程序与UIActivityViewController共享。 但是当试图分享给' whatsapp'或者提醒'即使用户点击已完成标志中的解雇,我也会收到。

在facebook上工作很棒。

可能是什么问题?

- (void)share
{
    NSString *text = @"share test";

    NSArray * activityItems = @[[NSString stringWithFormat:@"%@", text], [NSURL URLWithString:@"http://www.test.co"]];
    NSArray * applicationActivities = nil;
    NSArray * excludeActivities = @[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage];

    UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
    activityController.excludedActivityTypes = excludeActivities;

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


    [activityController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError)
    {
        NSLog(@"The setCompletionWithItemsHandler completed = %i", completed);

        if (completed)
        {

            NSLog(@"The selected activity was %@", activityType);

            if ( [activityType isEqualToString:UIActivityTypeMail])
            {
                NSLog(@"Mail sended");
            }
            else if ( [activityType isEqualToString:UIActivityTypePostToTwitter])
            {
                NSLog(@"Post on twitter, ok!");
            }
            else if ( [activityType isEqualToString:UIActivityTypePostToFacebook])
            {
                NSLog(@"Post on facebook, ok!");
            }
            else if ( [activityType isEqualToString:UIActivityTypeMessage])
            {
                NSLog(@"SMS sended!");
            }
        }
    }];
}

0 个答案:

没有答案