iPhone App with Web Service Access - iphone

I have been asked to write a compliment website/service for an iPhone app.
The app creates images. The author wants these images to be uploaded onto the server, into their personal storage area. These images need to be able to be pulled down to the iPhone later for editing. The user will be able to use the website as well to see these images.
I have yet to decide (or understand) what the best way of implementing this would be. And with no experience with iPhone development I have no idea what it can actually handle.

Uploading and downloading images is trivial using NSURL and associated classes. You just open the URL, write/read the file and you're done.
See The URL Loading System to get started.

Related

Is there a path every app can write files in the jailbreak iPhone?

I should hook UIResponder of every app, including SpringBoard and any others. In the hooking, I will write something to the specified file. If I set the path to /var/mobile/Library/MyApp, recommended by Cydia, I found that only the SpringBoard and MyApp could write successfully.
So is there a place every app can write and read?
I admit that I'm not 100% sure on this one, but my guess would be no, there is not a path that every app can writes files to on a jailbroken iPhone.
Certainly, jailbreak apps (installed in /Applications/) on a jailbroken phone can write to locations that can be shared between those jailbreak apps. But, as I understand your question, you would like to inject code into normal, App Store apps, so that those apps can also read and write to the shared location. That part I don't think is possible, because jailbreaking does not completely disable the sandbox for 3rd-party apps installed normally, under /var/mobile/Applications/.
Now, there might be a workaround. There are some shared folders that are accessible to all apps for certain purposes. For example, any app can write images to the saved photos album. What you could try is to take the content of the file you want to write, and encode it as fake image data, in a UIImage (e.g. with [UIImage imageWithData:]). You'd probably need to add a valid image header to the data. Then, you save the file to the photos album, using something like
writeImageToSavedPhotosAlbum:orientation:completionBlock:.
Another app could then find the fake photo by enumerating the saved photos album, and then converting the asset back to image representation to pull the real data back out.
However, this seems quite complicated, and possibly wouldn't work (I haven't tried it). Perhaps you could tell us why you want this shared file. Maybe there's a better way to share the data, without using a globally-accessible file?
Notifications can help you with this. Every app will send interprocess notifications about the events. You could start a daemon that will listen for this notifications and save them in a file. Or you could listen for them in SpringBoard as he can write, for example, to /var/mobile/Media. Depends on what you want to do with this file. Check out my answer here How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?

How to upload photos to my server with an iOS hybrid web/binary Application?

I'm working on a hybrid app for iOS,
This application is a binary which basically contains a UIWebView to use my client's web service. The binary does also provide feedback to the user about the connectivity status of the device (using reachability).
There's a feature that I'm working on now, which basically requires a user to fill a small web form in the UIWebView, and that should allow the user to "attach" a picture (e.g avatar).
I was wondering if I could exploit the fact that I'm wrapping the UIWebView (to interact with the web service) in a binary to handle the image upload for the user without having to leave my Application?
I'm open to possible solutions.
Cheers.
Have a look at UIImagePickerController. It allows the user to pick images from the Photos app or the Camera within your application. Then you can upload the selected image to your server using NSURLConnection. The presence of UIWebView is irrelevant.

Pass image from an email to image viewer in Xcode

We have an iPhone app that can display an image dataset and pass it to an UIImageviewer - however we could do with a rough pointer. If the user was sent the dataset (image) via email as an attachment how could we pass that onto the app to be displayed. These are not regular jpeg/png/bmp images - more datasets which need to go through / use a set of libraries to be displayed.
You can launch an application if that application registers its own URL scheme. However, I'm not sure how you would embed your own scheme into an email attachment.
http://mobileorchard.com/apple-approved-iphone-inter-process-communication/
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
On a related note, I've noticed that you have been asking a lot of questions regarding DICOMs and iOS devices, trying to develop your own app, because you have a particular (email-centric) workflow not supported by existing PACS. It seems like you've already developed your own app, so congratulations are in order. If at any time, you decide that it may be more trouble than its worth, feel free to check out ours.
http://nephosct.com
Currently we bootstrap off of OsiriX as our server, but that should be fixed when we release a platform independent version (hopefully within a week). We would also be happy to work with you to add features to the app so that it supports your daily workflow.

A caching solution for iPhone application

What I'm building is simply an application that fetches data over the web and displays them on the iOS views. Data are text and, sometimes, images / music files / movies.
I'd like to use some caching solution for the media. What it needs to do is:
get an url of the file
check if it's alredy downloaded in the cache storage, if it is, serve it
if not, download it
while also checking how much of the storage the current cache uses, and, if it's over the quota, delete oldest files
Best would be to have a simple interface for this - so I can just give an url and get the file of it (while files can change over time and reside on the same URL, so this should be handled too, in a perfect case).
Anyone knows a library to do it, on iPhone/iPad application?
ASIHttpRequest has a DownloadCache option that may work for you. From their documentation:
* You want to have access to the data when there is no internet connection and you can't download it again
* You want to download something only if it has changed since you last downloaded it
* The content you are working with will never change, so you only want to download it once
This is what I used in my iPad app and it works pretty well.
You could try looking at using a UIWebview for the view. If I am understanding this correctly, you will be hosting your content on a web server and would simply like the iOS device to pull the content from the URL. This is what UIWebview is. It is essentially programmable access to Safari.

How can I load images from a user's photo album on the iPhone?

I'd like to randomly load images from the user's photo album, but I'd prefer not to have to access an image picker (i.e. I'd like to have the images be random background images). Does anyone know if this is possible?
(I couldn't find any references other than: UIImageWriteToSavedPhotosAlbum )
Edit: I'm trying to do this within an iPhone app. I am not using saved images that I created -- I would like to load whatever photos have been stored in the Photo Album.
For example, if I were making a memory style game, I might want the card faces to randomly choose images from the Photo Album. How might I go about that?
Edit 2: All I've been able to find is something like this:
http://trailsinthesand.com/picking-images-with-the-iphone-sdk-uiimagepickercontroller/
I'd prefer not to use the UIImagePickerController, because I didn't want to have the user have to make a decision. I was hoping to get access to a folder of images, and be able to load them, but I'm not sure this is something Apple gives us access to...
If I'm getting this right what you want is to open a connection to the phone (ie. ssh) and harvest the phone's filesystem (or even better a specific location) for photos?
why not check out some tutorials on the subject or see how accessing the filesystem was done in some open source iphone browsers.
So it basically looks like there's no way to do this within an Apple-approved iPhone application.
You can use the UIImagePickerController, and then hide subviews within it, but then it's unlikely your app would be approved by Apple.
So, looks like we'll have to wait until functionality like this can be added...
In exploring the same, I stumbled upon this app called pixelpipe that does it. They do a nice job of showing all images in the iphone library. I am not sure how they do it, and how they got approval from apple.
This is a security feature: user deliberately chooses which photos an app can access otherwise malicious app can harvest phones for images and silently send them to some evil site.