i want to build an app that tells the user the environmental impact of different products, and naturally i want to include the phone itself in this. to do this i want to know how much electricity my phone has used up over its lifetime to calculate the electrical consumption.
as such, im trying to work out how many times my battery has been charged (how many cycles) in swift. ive looked into the documentation for UIDevice.BatteryState but it doesnt seem to give me this info? i also found some info pointing me at IOKit but not much further, the apple doc that ive found said that its unsupported?
theres an app called CoconutFlavour that does this, and i can find the maximum capacity in the menus but i need to find it using Swift.
how do i find the number of cycles my battery has run through in Swift? which class am i looking for? please help.
As far as I know, Apple keeps the battery information of the phone in log-power-date.session File and this file contains phone information written in XML. It writes the information you want in <key>.com.apple.ioreport.BatterCycleCount </key> section.
This file is located in the analysis and data section of the phone's privacy section. But I don't know how you can get it with an app.
Related
I am using Swift to develop a personal app for my family and have been researching methods of what toolset to use to build an app that allows a user to see other people using the same app in a vicinity of around 0 - 200meters.
I was looking at bluetooth and also trying to work out how Tinder finds other users. Do they just use GPS? If so how would one best implement that.
What would be the most effective way to determine another users location within 200 meters?
Note: 1 user would search the surrounding area for any devices that are on the app - Then it would tell the user their location. So it is doing both, finding the distance between the two locations and how you should get to that location. Obviously as this is for personal use, security issues arent much of a concern.
As you may have expected, you have many options of different approaches that will all accomplish your goal. I suggest you start by taking a look at a couple open-source projects:
PeerKit
LocationChat
Both of these libraries demonstrate a way to transfer a payload of data between devices. In addition, both projects provide very helpful example apps.
Assuming you choose to use PeerKit, each device could be responsible for obtaining its own location (via CoreLocation) and then broadcasting it to other devices (via PeerKit). Then the receiving device will be able to calculate the distance between itself and its nearby peers.
Note: At the time of writing, I have not contributed to either of the projects suggested above.
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.
I am developing an application where I need to know some of my iphone system information such as the cpu speed and above the list of processes in memory and the system log.
I have seen on AppleStore that there are some apps (Apple-approved) that display the data (Ex JustSys) then it means that Apple provides tools for information system of this type.
I tried searching on the net but could not find anything. Does anyone know how to get this info?
thanks
You should look at below link. Might be helpful for you
http://iphonesdkdev.blogspot.com/2009/01/source-code-get-hardware-info-of-iphone.html
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
what are the advantages and disadvantages in using Flurry or Localytics?
I can't answer about iOS, but the Android libraries for Flurry had a very half-baked feel to them when I tried them out about 3 months ago. There's a lot less power in their stats reporting and drilling down through the data can be like pulling teeth.
Additionally, I was getting wildly inaccurate session counts in a small closed beta test of my app (1000 sessions reported in a few minutes from one device). When I contacted Flurry support, it took them nearly a week to get back to me and then all I got was a fairly useless stock response. That alone knocked them straight off my list of potential analytics providers.
I've used Localytics on Android for hundreds of thousands of total installs at this point and am quite happy. Android gets treated as a first-class citizen (rather than feeling like a bolt-on on Flurry or even Google Analytics), and they have a pretty nice looking UI with a lot of good drilldown controls.
Both services are free and both services provide the same basic functionality of providing app analytics (e.g. number of users, type of devices, how the users are interacting with the app, etc.).
I have used both services for Android, although I am currently using Localytics because the Localytics library is open source. The Flurry library is closed source. Open source has the advantage that you can modify the library, as well as see exactly what the library is collecting.
Using flurry in your app you can trace your app, Suppose you want to track that this button pressed how many times ,You can use flurry it shows that in this location this app is used and that button is pressed that number of times.
DISADVantage:- Flurry is very slow it gives you results in 14-15 hours.
ADVANTAGE:- it is free
OTHER :- in place of flurry you can use google analytics(free) and omniture(Paid but give result faster)
you have to register yourself in flurry.com
Both of them store the data in public area. Although the data is so-called privacy, but it's not on your own server.
Flurry is free but provides much less detailed information, and flurry also only accepts up to 10 parameters per event. Localytics makes it easy to sort your data in many ways. For example I can look at all my users for the past week, now I can view users per day, or per hour. Then I can split the data to show me which users that played in the last week started playing the game for the first time, and then I can view that chart scaled to 100%. I could then add a filter so that I'm only looking at data from the users that started on a specific date, or specific week, or even multiple specific dates/weeks/etc. There are only a few things that I'd like from the localytics website that they don't provide, like retention data for days 8-13, or 15-27, or past 28 days, but those things can all be done through SQL queries.
Basically, flurry is free, but basic compared to what you get from localytics. Localytics I believe is free up until 10k MAU (monthly active users). Using localytics over flurry has made a huge difference on the product I'm on, we have been able to make much better decisions based on data.