I am using the UIActivityViewController
with custom subclasses of UIActivityItemProvider
. My providers work just fine with every UIActivityType
I wish to make available except when performing the following sequence :
- Display the
UIActivityViewController
- Share with another device using AirDrop
- After successfully sharing to another device, share by sending an email
The erroneous behavior is that I have a text provider which provides NSString
instances and those do not appear in the email's subject and body.
The expected behavior is that the mail composition dialog should contain the subject and body provided by the text provider.
When performing this sequence, I get the following warnings in my console :
2014-03-27 18:35:09.065 TestApp[1347:60b] Warning - UIActivityItemProvider <MyActivityItemProvider: 0x170296620> ignored (duplicate, executing or finished)
2014-03-27 18:35:09.065 TestApp[1347:60b] Warning - UIActivityItemProvider <TestActivityItemProvider: 0x170480a00> ignored (duplicate, executing or finished)
2014-03-27 18:35:09.065 TestApp[1347:60b] Warning - UIActivityItemProvider <WonderfulActivityItemProvider: 0x1704b7760> ignored (duplicate, executing or finished)
Each of the warnings correspond to one of the UIActivityItemProvider
I have provided.
Within those providers, the - (id)item
method is implemented in this manner :
- (id)item
{
if ([self.activityType isEqualToString:UIActivityTypeMail]) {
return @"MyMailString";
}
return @""; // placeholder item
}
With this kind of implementation, I am able to create a single provider which is able to supply different strings to Facebook, Twitter, Mail, etc.
When sharing via AirDrop, I share a pdf file without any text. And since sharing by AirDrop doesn't close the UIActivityViewController
, all the other « activities » should work properly after sharing by AirDrop. Thanks for your help!