ayushi
ayushi

Reputation: 101

How can share images, messages and urls in ios (objective-c)

Please Help us..

We want to share projects (i.e. Its Images, text and also my app url).

But i can't get SDK to share all on whatsApp, facebook, twitter, mails and messages. same as android developer using Intent called ACTION_SEND

Upvotes: 2

Views: 1423

Answers (1)

Dipankar Das
Dipankar Das

Reputation: 700

Try this -

- (void)shareText:(NSString *)text andImage:(UIImage *)image andUrl:(NSURL *)url
    {
        NSMutableArray *sharingItems = [NSMutableArray new];
        if (text) {
            [sharingItems addObject:text];
        }
        if (image) {
            [sharingItems addObject:image];
        }
        if (url) {
            [sharingItems addObject:url];
        }
        UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
        [self presentViewController:activityController animated:YES completion:nil];
    }

Call shareText like this -

[self shareText:@"Your text" andImage:nil andUrl:nil];

Upvotes: 1

Related Questions