detection for iPhone - confused
nycgeek
Status: New User - Welcome
Joined: 16 Jan 2008
Posts: 2
Reply Quote
Thanks for the software and website. Been using it for over a year. I have a webpage that is using FCKeditor and that was not compatible with Opera and Safari (now safari is compatible and soon when Opera 9.5 it will be too). Now I've noticed that iPhone is not compatible as well. So checked the new YUI Rich Text editor as possible replacement for FCKeditor ... turns out that one is also not iPhone compatible. I think I need to start testing for Opera version once 9.5 becomes available. Have not needed to do that yet.

So want to detect for iPhone and can't seem to figure out what call to make (the parameter choice) to your function.

just googled and found this:
:: Quote ::

Grab that same environment value from a slick Apple iPhone query, though, and the values are quite a bit different:

HTTP_USER_AGENT=Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)
AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3

so I need to seek the string "iphone" in the lowercase converted HTTP_USER_AGENT string.

I can probably do this myself with a PHP string function, but that's pretty much the whole reason for your function in the first place. Just, I can't figure out how to use it ... it is confusing me. On line 87:

$browser_user_agent = ....

that gets the HTTP_USER_AGENT string and converts to lower case. But after that I'm lost.

Would you kindly advise how to use your function and detect for iPhone user. Please email me in addition to responding in your forum so I don't miss ya. Thanks a lot for the effort on this.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
A reasonable question. The main problem with trying to do even a half-assed handheld device identification is that there are just so many of them, there is no standard, each subversion from each company could run completely different operating systems, etc.

But I agree it's probably time to add a basic handheld detection option to the script, and we'll see if we can't get something up to do that over the next few days.

The right way to handle it I think is create a separate test, which will then return the basic handheld type, eg, blackberry, iphone, etc.

You'll also be able to extract the normal OS and browser data.

This should be fairly easy to do, and shouldn't require any massive changes, just needs simply adding one more return option to the script, which won't break any existing installs I think, hopefully anyway, and will add that one extra functionality.

Your sample string is helpful, as you can see, you can determine a few things automatically: it's a mac, it's running osx, it's running khtml/safari, mobile version, and it's iphone.

Many other handheld strings give only the barrest of information, like blackberry23254/23
Back to top
nycgeek
Status: New User - Welcome
Joined: 16 Jan 2008
Posts: 2
Reply Quote
Thanks, and for the quick reply. Appreciated.

I think you know exactly how to upgrade for a few more detctions. Perhaps use parameter "phone" and have it return blank "" if not a phone, or return "iPhone" or "n95" or whatever. Yahoo is using the terminology "A Grade" phone. Perhaps you can just add 1 or 2 now and then more in future if needed. I do think iPhone is popular enough with millions of them in service already.

You might also add "phone_version" parameter if you think that will have impact for programmers. I'm not sure about it. Perhaps old versions will need to be detected.

I'm using it for populating a text area with either regular text if nonFCKedior, or html marked up text if ok to use FCKeditor. Actually not even loading the editor if client browser can't handle it. That saves a bunch of time. Dang WYSIWYG editors are slooooooow.
Back to top
trimble
Status: New User - Welcome
Joined: 20 Jul 2008
Posts: 3
Reply Quote
I'm running v4.9.16 (20080704) of php_browser_detection.php and I see that mobile browser hasn't made it into a release yet.

I was wondering if mobile browser detection existed in any development versions that (perhaps) I could help with for testing purposes.

I'm currently able to identify Windows CE devices using the os_number value (it returns "ce"), but am still blind to Blackberries.

Thanks,
Mark
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4126
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
The problem of handheld detection is radically more complex than people realize, and could possibly entail a full rewrite of the script, though now, for the first time ever, people are actually using handheld devices in some numbers, though not very many, but with iphone and a few others there are finally some surfing interfaces that are a bit useful.

However, just to give you an idea, on techpatterns.com, blackberry requests last week are: 0.00019% of total, SonyErikson, Nokia, LG, DoCoMo, blackberry/8330-4 are each 0.00005%, and so on. I could dig up the stats from a large mainstream site too, but it's pretty much given that any one site will see very little realworld traffic, maybe google, maps.google.com, email sites, yahoo, ebay, some very basic stuff is my guess.

You see the pattern? Basically, nobody really uses these to surf in the real world. And then, to make matters worse, they have no unified identifier interface at all, one might be seen as an opera browser, another as a safari, another as blackberryxxxx, another as blackberry/xxyx-e, and so on.

I've kept lists of them, but in terms of actual useful browser id, it's just not practical to try to actually serve up content based on such erratic strings, that you simply never know what will be the browser or software running it. Eg, what is the LG running as a browser? Who knows. Is the browser in one LG the same as another, or is one running a tiny MSIE on windows CE, and another opera on a linux platform? Who knows.

I have never been able to think of a way to properly handle this, and since I've also never seen any actual realworld use in any significant numbers (ie, handheld use is lower than Dillo, Lynx, etc, and those numbers are LOW) I've always put this idea on hold until there's some actual real world utility for the time spent.

The only solution I can think of is to create a new module completely, and simply do a handheld test using a set of parameters. If the browser test or os test return not null, that will be extra information as well.
Back to top
trimble
Status: New User - Welcome
Joined: 20 Jul 2008
Posts: 3
Reply Quote
On further thought, I guess I'm basically interested in detecting four things for all users: (1) Does the browser support current stylesheet standards, (2) Is javascript enabled, (3) Are cookies enabled, and (4) What's the resolution of the user's device?

With these answers in hand, I think that I can make all necessary optimizations to a web environment for my users, regardless of what device/browser/os they're using... now and in the future.

With the exception of the stylsheet question, I think your script(s) may provide all of this information now, but I know could benefit from some advice on how to get this information. In particular, how to determine screen resolution would help.

Mark
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4126
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
For ALL stylesheet information, do not use this method. CSS has support for media types

Do not waste your life trying to track these random items, it's utterly impossible, let the unit itself declare what it is to css.

:: Quote ::
all
Suitable for all devices.
aural
Intended for speech synthesizers. See the section on aural style sheets for details.
braille
Intended for braille tactile feedback devices.
embossed
Intended for paged braille printers.
handheld
Intended for handheld devices (typically small screen, monochrome, limited bandwidth).
print
Intended for paged, opaque material and for documents viewed on screen in print preview mode. Please consult the section on paged media for information about formatting issues that are specific to paged media.
projection
Intended for projected presentations, for example projectors or print to transparencies. Please consult the section on paged media for information about formatting issues that are specific to paged media.
screen
Intended primarily for color computer screens.
tty
Intended for media using a fixed-pitch character grid, such as teletypes, terminals, or portable devices with limited display capabilities. Authors should not use pixel units with the "tty" media type.
tv
Intended for television-type devices (low resolution, color, limited-scrollability screens, sound available).

Media type names are case-insensitive.

Due to rapidly changing technologies, CSS2 does not specify a definitive list of media types that may be values for @media.

Note. Future versions of CSS may extend this list. Authors should not rely on media type names that are not yet defined by a CSS specification.

eg:
:: Code ::
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
   <HEAD>
      <TITLE>Link to a target medium</TITLE>
      <LINK rel="stylesheet" type="text/css"
    media="print, handheld" href="foo.css">
   </HEAD>
   <BODY>
      <P>The body...
   </BODY>
</HTML>
or
@media print {
    BODY { font-size: 10pt }
  }
  @media screen {
    BODY { font-size: 12pt }
  }
  @media screen, print {
    BODY { line-height: 1.2 }
  }


The same goes for javascript and cookies, do explicit tests for each function you will use and send to defaults in javascript, same for cookies.

This browser detection stuff is useful for larger market share browsers to some degree, but it's pretty useless for anything but ultra specific handling of handhelds.

Basically, the furthest I see the php browser detection is allowing you to get one more piece of information: $handheld = browser_detection('handheld'); for example, then if $handheld is not null, apply something or other, or if it's not null AND iphone, do something else. But preserve your sanity, do not try to track these hardware identified handheld devices and guess what each version supports or does not support, that's a road leading to wasted days you will never get back and which you will regret having lost when you look back on your life.

Also, keep this in mind, the authors of Opera, a popular handheld browser, or the Mac OS X safari in iphone, aren't stupid, they know it's impossible to really serve up customized pages, so they make their browsers handle it, opera does it by simply ignoring most css, and breaking the page so it can flow linearly, and ignoring much of javascript, when its in its handheld mode, I'm sure all the other ones do something similar, which makes the entire process a total waste of time except just to pick up raw stats.
Back to top
trimble
Status: New User - Welcome
Joined: 20 Jul 2008
Posts: 3
Reply Quote
I'm convinced, thanks techAdmin!

Cheers,
Mark
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4126
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
iphone and other webkit browsers detection now enabled.

The primary detection is for applewebkit

so:

browser_name is webkit
browser string is <iphone/chrome/epiphany/etc>
browser version is <webkit version number>

See php browser detection 4.10.x
Back to top
Display posts from previous:   

All times are GMT - 8 Hours