manifest file download size limit - iphone

I am learning to use Manifest files and had this question. What if some website created a manifest file that will make me cache files for, say, 3MB. 3MB is a lot for my IPhone when I run on 3G. So some vicious website can create such manifest file and make me use up all my data allowance?
Another question is that, as a responsible developer, is there anyway to detect if a user is using 3G or not so I can serve a smaller manifest file in the former case?
Thank you

Your question is tagged 'iPhone' so I am going to give an iOS-specific answer.
The offline storage, which holds the files linked to in your manifest, seems to be limited to 5MB. Evidence for this is all circumstantial, as the limit is not mentioned in Apple docs. However, some Apple engineers have conceded that there is a limit. The newest versions of Mobile Safari, in some circumstances, offer to allow the user to expand the storage, but you, as a developer, cannot force them to do so.
5MB is not really that much, and many users will certainly notice that something is going on, and if they don't want it to happen, simply close the tab. I understand that not every country has the same limits, but most users in the US are limited to 2GB/month. At this rate, an unsuspecting user would have to accidentally re-download your manifest, and the files it lists 100 times to use up just 25% of their bandwidth allotment. It's a fairly low limit, and the possibility of maliciously using up someone's data allotment is fairly remote.
As far as how to tell if a user is on 3G or WiFi, check out the Reachability example in the Apple Developer Center. It does exactly that. There is no way to do it in a web app (as opposed to a native app) that I am aware of.

Is there a size limit for HTML5 Manifest? No.
No, iOS does not implement W3C network information API as oppose to Andorid Webkit.

I'm not sure how you're getting this manifest file, but if you're using NSURLConnection, it's simply a matter of keeping a running total of how much data you've downloaded (best place would be connection:didReceiveData:) and cancelling the connection if it gets above 3MB. Remember to zero that number each connection though.
As for finding the device, the specifics seem trickier than they should be, but I've found a pretty simple example of how to do it (source code n' all): Determine If iPod is First or Second Generation

Related

How can "memory cleaner" apps determine the amount of used memory on iOS?

Every now and then "memory cleaner" apps bubble to the top of the download charts on the iOS AppStore, yet I am always puzzled: How can these apps figure out how much memory is used when they are sandboxed and can't access any memory outside of their process?
I'm not an expert in memory allocation on C, so maybe the solution is obvious and I just don't know it but I am curious as to how this works/could work.
Obviously the second question is how do they clean the memory once they have the count, I assume they just allocate a ton of heavy objects (eg. images) and thus force the OS to shut down other processes. Yet maybe there is a smarter way?
Note, I am not talking about Cydia here, these apps are available on the regular AppStore and work on non-cracked devices with the official consent from Apple. As an example, here is the current top seller: http://iputzfrau.professional-apps.at/
The Mach/BSD host_statistics and sysctl functions are available on iOS, and they provide access to system statistics such as the amount of physical RAM, processor speed and, indeed, the amount of free RAM available. To get the latter, you'll want to call host_statistics with HOST_VM_INFO, and look at free_count in the structure it fills out for you. Note that this value isn't necessarily useful for any real purpose. You probably don't need it unless you want to write yet another one of these scammy apps.
Low-level functions in the C/UNIX/Mach/BSD layer are generally available for use in iOS apps, although these APIs typically aren't described in the SDK documentation. Look at the headers in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/include/ and refer to the Mac OS man pages, C/UNIX standard documents or the Mac SDKs for more details about them.
These apps, as with the "track any cell phone" apps that have "for entertainment purposes only" buried in line 30,239 of the description, are scams. It's exceedingly frustrating that Apple lets them through the review process.
You're right -- there's no public API that would enable an app like the one you linked to do what it claims to do.
This would be an excellent question to pose to Apple, or at least post in the Apple developer forums. You could also report a bug, probably the most effective way to register a complaint without knocking yourself out.

iOS application size - How to reduce or download more after

I am after some suggestions on how to reduce the final app size that gets submitted to apple?
Or is there any way to have stuff download after the app is isntalled? so that we can keep the app under 20 meg, but then the app downloads the rest of the program after the user has installed it and run the application?
ta
Daz
If your application uses a lot of image resources, your application could download those images instead of building them into the application.
Theoretically possible. Your app can access the file system, so it can make and save, and later read files.
The deal-breaker I see is that for most purposes, Apple probably wouldn't allow it.
They test the program as-is when you submit it, and they'll notice that it just sits there and tries to download a bunch of stuff from your server. If this takes more than, say, 30 seconds, they'll reject it for usability problems.
If the content downloaded could have been bundled with the program, they'll probably have a problem with that. If you could argue that the downloaded content changes rapidly and is a feature of your app, it might fly, but only if you keep it small..
Sure this is totally possible. Since it is most likely some sort of media that is causing a large file size, either images, video, or audio, you could definitely download them after the fact or supply a download button for users to add these features as "extra" content, if they are not critical to the operation of your app.
One thing to consider is that some users are not on an unlimited data plan. So for politeness, they should know what you are doing.
Also, if you are just over the limit, you might also be able to ship the application with the resources in a zip archive and then decompress the archive in the Documents directory.
In many applications images take lion share of the download size, and they can be greatly reduced with ImageAlpha and ImageOptim.
Check out this case study halving download size of Tweetbot by converting images to a more efficient PNG variant.

Does apple view the actual source code when approving apps?

How exactly does apple approve apps? Is the actual source code viewed?
While none of us have access to the internal review process (which appears to be continuously changing), there are a few things that can be said based on the responses that people have received.
First, Apple has no access to your source code, so they do not review that. You submit a binary as part of an application bundle, along with your other application resources.
They do, however, appear to scan your application's binary for certain symbols that indicate the use of private APIs. A number of applications started crashing after iPhone OS updates because they used these private APIs, so Apple has been cracking down on this.
There are plenty of applications on the store that have memory leaks or other performance issues. I know that I've submitted versions of my applications that had subtle leaks (since fixed) and had no problems with review. Therefore, it does not appear that they do any sort of performance testing or profiling.
The only place where a memory leak causes a problem doing review is when that memory leak gets so bad that the application crashes when the reviewer is testing it. If your application crashes at any point during the review process, it will be rejected.
Beyond that, they have a checklist of user interface elements that they check for proper usage of (no persistent selections on table view rows, etc.). If your application deviates significantly from the Human Interface Guidelines when using these standard UI elements, you may get rejected.
Apple is very careful about copyright, particularly with their own images and artwork, so you may run into trouble if you use copyrighted material improperly.
Most of the rejection reasons you will face are preventable by making your application stable and by following platform guidelines, but some are not. Certain classes of applications have been rejected due to their intended use, and again the classes of applications that are allowed on the store change on a regular basis. This can add frustration and uncertainty when dealing with the App Store, but the vast majority of application types will never run into problems (as can be seen in the diversity of applications currently available).
try to use otool -L binary yourself and you can see immediately if a private API framework got used...
No, they only have access to the binary code that you send them.
They can run this through profilers checking for memory leaks and the like.
They do not have access to your source; it is not part of what you send to them. They test the binary you send them for leaks and such. I think they also check what data your app sends out to make sure it isn't doing anything egregiously bad (sending passwords or the like).
Apple does not care about leaks and profiling information for your App. The Operating system is able to kill your app if that gets out of hand. What they actually do is manually run your App and check if it follows some of Apples guidelines. In an automated process they extract symbols, selectors and strings from your binary and check those for usage of private APIs.
You might want to try nm -u on your (simulator) binary.
They only receive your binray file of ipa only. They can get some of your resource file while extract ipa. They can able to find what all urls you used in web service or url request. Nothing else other than this.

Create product keys for iPhone application? [iPhone SDK]

Is it possible to assign different identifiers to copies of an app downloaded from the app store that is hard coded into the application? Or is their anyway of permanently storing an identifier in the application bundle such that when it is copied, the key remains within the bundle?
EDIT: Ok, how about iTunes reciepts, can they be used to verify when it was downloaded as the user has to register their app with the server within say 5 hours of them downloading it.
thanks in advance
I'm assuming your goal here is to disable part of the functionality of your app by having a master list of bogus serial numbers somewhere. Unfortunately there is no per-copy serial number available, and if there were it would be the first thing the bad guys would change before posting your app for download.
Instead you'll need to detect whether your app bundle has been tampered with from within the app. See this question:
Reducing piracy of iPhone applications
You'll then need to decide how subtly or obviously you want to limit functionality. Probably the best solution would be to do something innocuous but slightly annoying that generates a specific kind of support request, at which point you can gently prod the deadbeat into considering buying a legit copy.
An approach with more false positives but potentially fewer false negatives would be to check if the app is running on a jailbroken device. The downside there is that jailbreakers may well have legitimately purchased your app, so you're alienating honest customers for little to no extra benefit.
For the app I'm working on, which has a big social/viral aspect (I hope), I've decided that potential deadbeats probably have enough honest friends to pay for the server cycles that they're stealing, and it's just not worth worrying about.
No, there's no way to do either of these. The closest you could come would be to store device IDs on a central server.

iPhone app rejected for "transferring excessive volumes of data"

Our lovely app that downloads mp3s from our server into a local file on the phone then plays from that file was rejected for using too much bandwidth.
I understand the rejection (we are downloading rather than streaming) and don't quibble with their decision... our first priority was quality of user experience.
I am just wondering... what do I do now?
There are no hard and fast rules... Apple just says, "Must not in Apple's reasonable judgment excessively use or unduly burden network capacity or bandwidth".
Anyone have data on what Apple considers reasonable data transfer rates?
Should I fill up the buffer file in short spurts? Should stream the file at a constant rate (and how would I limit the transfer rate from within the app?)
Any and all suggestions are welcome.
Thanks
I have talked with Apple Developer support, and just FYI. You are only allowed to stream 1 MB per minute over the Cellular network. Support suggest that you test your app in the following way:
"The basic measurement methodology is to turn off all background updating (particularly Mail's automatic mail downloads and Calendar updates), reset the transfer statistics in "Settings:General:Usage:", and then launch your application. Let it run for a fixed amount of time (five minutes is reasonable), and then exit your application. Once you've finished the test, the numbers listed under "Cellular Network Data" in "Settings:General:Usage:" are what you should focus on reducing.
Using what I just described, I'd suggest 4.8 MB every 5 minutes as the guideline you use to ensure your application stays within our bandwidth requirements."
Hope that helps at least a little.

			
				
Have you considered HTTP Live Streaming? It's built into OS 3.0.
Basically, you split your media into small (say, 10 second) snippets and put it on a standard web-server. Then you create little text 'meta-descriptor' files in EXTM3U format that point out where the bits are. The interesting thing is that you can create multiple versions of each snippet at different bit-rates. So if your bandwidth is good, the iPhone player dynamically chooses the higher bit-rates but when it's low it automatically switches to the lower bit-rate version of the snippet. It does this on-the-fly to adapt to changing conditions.
So if you split your MP3 into multiple 10-second bits at say, 3 different bit-rates then when the user is connected through WiFi they get the high-quality stuff but if they're on 3G or EDGE they get progressively lower-quality (and smaller sized) content.
If this violates your downloadable media concept, then perhaps you can use the same trick and keep multiple size files for each connection type. Then if you're on WiFi (or get a fast turnaround on a heartbeat ping to the server) download the big file vs. medium or small size ones.
Here's a decent step-by-step on segmenting content. They focus on video but it should work with audio content as well.
I would suggest throttling the bandwidth on the network/http request when connected to cellular, and having no throttle on wifi.
A combo of using Reachability to detect the network status, and implementing your http request using CFNetwork with a sleep until the next second whenever you have already downloaded as much as allowed per second should get you there.
You should check out this project, either to use, or just to see an example of how to code this well:
http://allseeing-i.com/ASIHTTPRequest
The ASIHTTPRequest class implements this, using either the old or 2.0 version of Reachability, and also provides a class level throttle, so even if you have multiple concurrent downloads and uploads, so long as all of them go through ASIHTTPRequest, they will be properly taken together and throttled properly.
A bit more on how to use this here:
http://allseeing-i.com/ASIHTTPRequest/How-to-use#bandwidth_throttling
Lots of good stuff in this (and no, I am not the author of any of it).
On a more serious note, what is it trying to do? There are many markets for iPhone outside of the US which don't have good download rates for phones, nor are the download cap sizes good, so having an app do lots of downloading isn't a good thing.
Could you possibly drop the data rate on your mp3 or some such? Make it optional to do the downloading with a warning that it will use your download?
YOu could not download the mp3 unless you are on wireless, and inform them of that. If you the mp3 are too important, then just tell them it only works on wireless, or include a few mp3 on the device. But 30min of mp3 is ridiculous, that is about what, 30meg.... think about it, 30 meg is just too much.