Search code examples
iosobjective-cshareuiactivityviewcontrollerviber

Why my message is shared twice in viber, I have used UIActivityViewController


I have used UIActivityViewController for sharing my message in Facebook, Twitter, Viber etc....It seems the message is send twice in Viber but for others are ok. Can u please help me?? I have used the code given below...

-(void)shareContent {
    NSString * message;
    NSArray * itemsArray = [NSArray new] ;
    if ([shareFlag isEqualToString:@"Friend"]) {
        message = @"Hi, I am using Amar Sticker, an amazing app to download & share cool Bangla Stickers. Click here and get it for FREE: http://goo.gl/qK7HRw";
        NSURL *appLink = [NSURL URLWithString:@"http://goo.gl/qK7HRw"];
        itemsArray = @[message, appLink];
        shareFlag = @"";
    }

    UIActivityViewController * avc = [[UIActivityViewController alloc] initWithActivityItems:itemsArray applicationActivities:nil];

    [avc setExcludedActivityTypes:@[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard,UIActivityTypeSaveToCameraRoll]];

    [avc setCompletionHandler:^(NSString *activityType, BOOL completed) {

    }];
    [self presentViewController:avc animated:YES completion:nil];

}

Solution

  • After many searching and doing in several way I see that it only happens when I share an array, it can not handle the shared object of the array properly, maybe its a bug of viber. When I post only one string or url it can send properly. I have tested using 2,3,4 items arrry and only one single string/url etc.