4

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 :

  1. Display the UIActivityViewController
  2. Share with another device using AirDrop
  3. 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!

Community
  • 1
  • 1
Dalzhim
  • 1,970
  • 1
  • 17
  • 34
  • Did you ever solve this problem? I'd be interested as I am getting it too and this seems a unique question on SO! Thanks. – Nick Feb 13 '17 at 09:19
  • The details are not very clear in my memory, but I think it might have been related to a memory management problem where a retain cycle would keep the view controllers alive when they should have been dealloced. – Dalzhim Feb 14 '17 at 05:17

0 Answers0