On Jun 25, 9:56 pm, Stan Wiechers <[email protected]> wrote:
> Hey,
>
> as usual you can't tell from the user-agent which iphone model you are
> dealing with.
There is no reason to think you can - a browser is an application, the
underlying hardware is irrelevant. There is no specification for what
a UA string should contain, it might be anything.
> in the past i used a simple 20ms benchmark in javascript to
> distinguish between 2g/3g and 3gs. the idea was formed in a discussion in
> this very group here.
Do you have an estimate of the percentage of incorrect results? If a
3gs is busy doing something else when the test runs (say a call is
incoming or some other task runs in the background), likely it will be
misidentified. Changes to the script engine that affect performance
(e.g. so that older models with the update run as fast as new models
without) will likely make things even more difficult.
> var percentmobile_t=new Date().getTime();
> var percentmobile_s=0;
> while(new Date().getTime()-percentmobile_t<20)
There is no need to use getTime(), though I doubt it is relevant here.
Subtracting one Date object from another will return the difference in
ms (per ECMA-262):
> {
> Math.random();
> percentmobile_s++;}
>
> var model=(percentmobile_s>1000)?"3gs":"2g3g";
>
> this worked well and i expected to be able to do something similar for the
> new device. didn't work. within the 20ms both create between 1500-2400
> random numbers. i tried creating some other objects such as images or DOM
> nodes, but same thing, the browser performance is not distinguishable. does
> anyone of you have an idea what else to try?
Ask the user?
[...]
> disclosure: i am co-founder of percentmobile.com, a *free* mobile web
> analytics solution and we used the methods like the one above in the past to
> differentiate between models.
Hopefully you advise clients of the difficulty of reliably detecting
underlying platforms and provide an estimate of accuracy when
reporting data or statistics.
--
Rob
--
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en.