Friday, 15 May 2015

ios - UIDocumentInteractionControllerDelegate methods not called when open system apps like Mail, Messages, Twitter or Facebook -



ios - UIDocumentInteractionControllerDelegate methods not called when open system apps like Mail, Messages, Twitter or Facebook -

i'm using uidocumentinteractioncontroller share image in instagram , other apps whatsapp, google drive, dropbox... (as many of know instagram pictures has ".ig" or ".igo" file extensions). if share picture.ig in other apps instead of instagram pictures appears file , not picture. implement delegate method:

- (void)documentinteractioncontroller:(uidocumentinteractioncontroller *)controller willbeginsendingtoapplication:(nsstring *)application { if (![application isequaltostring:@"com.burbn.instagram"]) { nsurl *newpath; nsstring *oldpathstr = [controller.url absolutestring]; nsstring *newpathstr = [oldpathstr stringbyreplacingoccurrencesofstring:@"ig" withstring:@"jpg"]; newpath = [nsurl urlwithstring:newpathstr]; controller.url = newpath; controller.uti = @"public.jpeg"; }}

that way if app not instagram share other version of file in jpg (i have both .ig , .jpg versions stored in disk).

but, problem documentinteractioncontroller doesn't phone call delegate method when trying share image scheme apps mail, messages, twitter or facebook could't utilize jpg url , people receive .ig file in iphones or laptops don't know how open. if seek open other apps whatsapp there isn't problem , delegate called.

do know how take command of before scheme open mail service composer, message composer or social composer?

thank much.

i find solution. first of configure uidocumentinteractioncontroller

- (void)setupdocumentcontrollerwithurl:(nsurl *)url { if (self.docinteractioncontroller == nil) { self.docinteractioncontroller = [uidocumentinteractioncontroller interactioncontrollerwithurl:url]; self.docinteractioncontroller.delegate = self; } else { self.docinteractioncontroller.url = url; } }

then open instagram .ig file docinteractioncontroller, if open .jpg instead of .ig file, instagram app wouldn't appear in "open in app" menu

//share instagram .ig image fileurl [self setupdocumentcontrollerwithurl:fileurl]; [self.docinteractioncontroller presentoptionsmenufromrect:self.view.frame inview:self.view animated:yes];

then have alter url within delegate method allow scheme apps share .jpg instead file .ig extension (only instagram , few other apps recognize .ig file picture

- (void)documentinteractioncontrollerwillpresentoptionsmenu:(uidocumentinteractioncontroller *)controller { nsurl *theurl = controller.url; nsstring *theinstagrampath = theurl.path; nsstring *jpgpath = [theinstagrampath stringbyreplacingoccurrencesofstring:@"ig" withstring:@"jpg"]; nsurl *jpgurl = [nsurl fileurlwithpath:jpgpath]; controller.url = jpgurl; }

after mail service app, messages, twitter , facebook (and non scheme apps) open file jpg. have alter url 1 time again if want open file within instagram:

- (void)documentinteractioncontroller:(uidocumentinteractioncontroller *)controller willbeginsendingtoapplication:(nsstring *)application { //check if app calling instagram if ([application isequaltostring:@"com.burbn.instagram"]) { nsurl *newpath; nsstring *oldpathstr = [controller.url absolutestring]; nsstring *newpathstr = [oldpathstr stringbyreplacingoccurrencesofstring:@"jpg" withstring:@"ig"]; newpath = [nsurl urlwithstring:newpathstr]; controller.url = newpath; }}

and that's all. seems willbeginsendingtoapplication: not beingness called if select scheme app in menu.

ios iphone objective-c facebook uidocumentinteraction

No comments:

Post a Comment