I am using iOS with parse.com and mailgun. I am trying to send an email with a pdf attached. I have read that the parse.com cloudCode doesn't allow attachments. But I have also seen this post, Mailgun: Sending image using parse cloud code ,saying instead of attaching place it inline.
First off, is this still the case, that we cannot send attachments via cloud code? If so, could someone give me a hand in figuring out how to get a pdf from my app into an email sent through mail gun? Im not using the built in mail view from apple because I need to be able to set the "from" address of the email.
I have the pdf created dynamically in the app and I present it in the code like this:
NSString* fileName = #"Invoice.PDF";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 60, 320, 480)];
NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];
[self.view addSubview:webView];
I don't know how to get the file from the Docdir into the proper data form and either attached (if now possible) or place it inline like the post mentions above.
Any help would be appreciated. If you need more info, have questions or have alternate idea on how to accomplish this task please ask/suggest.
Thanks in advance
Related
I need to modify an app to print and email a document created on the iPad.
I'm thinking that I should create a PDF document, as shown in the tutorial link below:
http://www.raywenderlich.com/6818/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-2
However, once created, I want to print and/or email the document? Are there any other suggestions which may not require pdf document?
I need to create a document based on data entered into a UIView and then either print and/or email it accordingly.
Any suggestions or assistance with this would be great.
You might want to use UIDocumentInteractionController for this purpose. Once you've created your PDF, you can present it with UIDocumentInteractionController by passing the URL of your created/saved PDF. This automatically gives you the option of printing/copying and emailing.
Example: (Assuming that you've saved your PDF in the local Documents folder)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath= [documentsDirectory stringByAppendingPathComponent:#"SAVED_PDF_NAME HERE"];
NSURL *URL = [NSURL fileURLWithPath:writableDBPath];
if (URL) {
// Initialize Document Interaction Controller
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
documentInteractionController.UTI = #"com.adobe.pdf";
// Configure Document Interaction Controller
[documentInteractionController setDelegate:self];
[documentInteractionController presentPreviewAnimated:YES]; // This will present the PDF along with options like Mail, Print and Copy..
NOTE: This is after creating your PDF.
Checkout the following links
http://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/drawingprintingios.pdf
or
http://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/Printing/Printing.html#//apple_ref/doc/uid/TP40010156-CH12-SW14
In my app i want to display the videos uploaded by a particular user in his Vimeo account.
I have completed the OAuth steps and got the video_id's of the video's uploaded by user. I tried to download the thumbnails for videos so that they can be displayed in table view or collection view.
Vimeo has provided the api method using that i got the response like this:
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=72961770"];
but i pasted the user id there. i tried another approach so that the user id is loaded dynamically.
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc]initWithURL:url consumer:consumer token:token realm:nil signatureProvider:nil];
OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:#"video_id" value:[array objectAtIndex:0]];
NSArray *params = [NSArray arrayWithObject:p0];
[request setParameters:params];
but i got an error saying that Msg = Method not found.
can you help me to get the id dynamically or is there a way to give the video_id as a parameter to the url. Thank you
create a string for url and paste until video_id=.
NSString *url = #"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=";
and after that use stringByAppendingString method to append the video_id value to it and use it.
This is also not a direct way but somehow enables you to get the video thumbnails dynamically without having to paste it
i am working on an iPhone app, in my project I added an HTML5 page that is a template, and have a webview and want to load it on viewdidload. I can't seem to be able to access it, I am trying this :
NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains( NSAllApplicationsDirectory, NSUserDomainMask, YES ) ;
NSString *documentDirectory = [ documentDirectories objectAtIndex: 0 ] ;
NSString *longPath = [ documentDirectory stringByAppendingFormat:#"/%#" filename ] ;
I am a bit confused? How can I achieve this? do I need to tell xcode that this html5 needs to be built and sent to a specific folder at runtime? like treated as a resource?
I am new to xcode coming from a .NET environment, so maybe the terminology is a bit awkward.
Thanks
If it's part of the project it won't be in the documents directory it'll be in your application bundle. For example:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:filename ofType:#"html"]];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:req];
How can I display face book feeds related to a group on an iOS App?
Is there any JSON/JSONP call to fetch the feeds??
Any help is Appreciated.
The simplest - is just to show a web page on web view. Facebook manages itself to fit the width of your webView control.
// Load facebook data
NSString *fbUrlAddress = #"http://www.facebook.com/FLORtiles"; // here you put your own group
//Create a URL object.
NSURL *fbUrl = [NSURL URLWithString:fbUrlAddress];
NSString *webHTMLfb = [NSString stringWithContentsOfURL:fbUrl encoding:NSUTF8StringEncoding error:NULL];
//NSLog(#"webHTML of facebook: %#", webHTMLfb);
//URL Requst Object
NSURLRequest *fbRequestObj = [NSURLRequest requestWithURL:fbUrl];
//Load the request in the UIWebView.
[fbWebView loadRequest:fbRequestObj];
You might need to get familiar with Facebook's Graph Api
Go through this -> https://developers.facebook.com/docs/mobile/ios/build/
I've a problem that i couldn't solve, i wanna run the Apple - HTML5 Showcase - Gallary
in UIWebView inside my ipad app.
I've tried a local html file:
NSString *strr = [[NSBundle mainBundle] pathForResource:#"photo-gallery" ofType:#"html"];
NSString *str = [[NSString alloc] initWithContentsOfFile:strr encoding:NSASCIIStringEncoding error:nil];
NSLog(#"%#",str);
[webView loadHTMLString:str baseURL:nil];
and also a server html file, but it didn't work, can anyone help me, i wanna show an html5/css3 in UIWebView.
thx in advance.
hi this is what you can do
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:webFrame];
//getthe path of the local html file
NSURL *baseURL = [NSURL fileURLWithPath:fileNamePath];
NSURLRequest *aRequest = [NSURLRequest requestWithURL:baseURL];
//load the html file into the web view.
[aWebView loadRequest:aRequest];
//add the web view to the content view
[view addSubview:aWebView];
For server html you simply skip the second line, and put the address.
Hope it helps
You can take a look at phonegap. Its a complete framework for building html5 apps inside a UIWebview with native capabilities.
See: http://www.phonegap.com