Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 67

Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
03/30/13 09:15 PM (12 years ago)

Custom url email problem

I enabled the "email document link" button at the custom url plugin, but when I press it the following error is shown: "There was a problem attaching the document?". What is wrong?
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
03/30/13 09:25 PM (12 years ago)
I don't think that option is applicable for that screen. The custom URL Plugin retrieves content from a URL, which could be an HTML document with text, images, video, etc. So, there's no real "document" to send. I believe that option is more applicable to screens like PDF Doc, Word Doc, etc. Mark
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/30/13 09:45 PM (12 years ago)
yeah - I used this in my recent app, "Fiverr!". I had to rework the code to allow for emailing the url. Here's what I did: In the BT_screen_customURL.m file, find the "-(void)actionSheet" method. Replace the method with this code: -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"actionSheetClick for button index: %i", buttonIndex]]; if(buttonIndex == 0){ //tag == 1 for launch in native app button if([actionSheet tag] == 1){ //we cannot open local files in the external browser NSString *openURL = self.externalURL; if([openURL rangeOfString:@"file://" options:NSCaseInsensitiveSearch].location != NSNotFound){ //use the screens dataURL openURL = self.dataURL; } //show error if we could not opent he url if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:openURL]]){ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"launch_errorTitle", "Problem Launching App?") message:NSLocalizedString(@"launch_errorMessage", "Your device could not determine which app to use to launch this URL?") delegate:self cancelButtonTitle:NSLocalizedString(@"ok", "OK") otherButtonTitles:nil]; [alertView show]; [alertView release]; }else{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"launching native app: %@", openURL]]; } } //tag == 2 for email document button if([actionSheet tag] == 2){ //appDelegate BT_appDelegate *appDelegate = (BT_appDelegate *)[[UIApplication sharedApplication] delegate]; if([appDelegate.rootApp.rootDevice canSendEmails]){ NSURL *currentURL = webView.request.mainDocumentURL; NSString *stringOfURL = [NSString stringWithFormat:@"%@", currentURL]; NSLog(@"emailing document with url in message:%@", stringOfURL); //find the nav controller BT_appDelegate *appDelegate = (BT_appDelegate *)[[UIApplication sharedApplication] delegate]; //get reference to the navigation controller... BT_navigationController *theNavController = [appDelegate getNavigationController]; //get reference to the view controller... BT_viewController *theViewController = [appDelegate getViewController]; MFMailComposeViewController *picker = [[[MFMailComposeViewController alloc] init] autorelease]; picker.mailComposeDelegate = theViewController; //empty message body NSString *emailBody = @"Check out this awesome url I found!\n\n"; emailBody = [emailBody stringByAppendingString:stringOfURL]; [picker setMessageBody:emailBody isHTML:NO]; //style the model view like it's parent viewController [theNavController presentViewController:picker animated:YES completion:nil]; [picker.navigationBar setTintColor:[BT_viewUtilities getNavBarBackgroundColorForScreen:screenData]]; }else{ [self showAlert:nil theMessage:NSLocalizedString(@"emailsNotSupportedMessage", @"Sending emails is not supported on this device") alertTag:0]; } } } }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/30/13 09:47 PM (12 years ago)
Just be sure to replace "BT_appDelegate" with "<yourAppName>_appDelegate" for each time it appears in the plugin, unless you are uploading the change as a new plugin or as an update to the existing plugin.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
03/30/13 10:25 PM (12 years ago)
And keep in mind this will email the URL only...not the content from that URL. Great code mod, Chris! Mark
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/31/13 02:01 AM (12 years ago)
thank you guys @chris1 you are the best man...nice work there!!!thnx for sharing that info. And with this will I be able to send the url,right?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/31/13 04:04 AM (12 years ago)
Nice snippet Chris! Thanks! -- Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.