1 Reply
      Latest reply on May 23, 2019 6:32 AM by janabanana
      dkal Level 1 Level 1 (0 points)

        I am trying to send a mail from within a sharingextension with the NSSharingService.

         

        There is no error in Console or in any other media i can debug.

        Did anyone manage to use the

        NSSharingService* sharingService = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];

         

        My code brings up the Mail dialog as soon as I copy it to a fresh cocoa app and run it. Only in my sharingExtension it is not working.

         

        from within an sharingExtension, or is it just not allowed / supported.

         

        Thanks

        Daniel

        • Re: Call NSSharingService from sharingExtension
          janabanana Level 1 Level 1 (0 points)

          I use this in an NSDocumentController subclass and it works fine.

           

          //------------------------------------------------------------------------------------------------

          -(IBAction)shareCurrentDocumentAction:(id)sender {

              NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"\n\n"];

              NSURL *theURL = [[self currentDocument] fileURL];

              NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];

              [service performWithItems:[NSArray arrayWithObjects:text, theURL, nil]];

          }

          //-------------------------------------------------------------------------------------------------------