Go Back   MacRumors Forums > iPhone, iPod and iPad > iPhone

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 17, 2013, 04:56 PM   #1
bonskovsky
Banned
 
Join Date: Dec 2012
How do you block your website from Android phones?

I have a website that I'm making, but I only want it to work on iPhones, specifically the iPhone 5. I want an error message to show whenever someone tries to use an Android phone or computer to view the website.

What kind of code can I use to make this happen?

Last edited by bonskovsky; Jan 17, 2013 at 11:08 PM.
bonskovsky is offline   2 Reply With Quote
Old Jan 17, 2013, 04:58 PM   #2
maxosx
macrumors 68020
 
Join Date: Dec 2012
Location: Southern California
Give it a rest, or look in the mirror. There's something very wrong with this picture.
maxosx is offline   6 Reply With Quote
Old Jan 17, 2013, 04:59 PM   #3
Squilly
macrumors 68020
 
Squilly's Avatar
 
Join Date: Nov 2012
Location: PA
Java? Enable a pop-up that prevents anything but 6,1 (iPhone code name) from accessing the site.
Squilly is offline   0 Reply With Quote
Old Jan 17, 2013, 05:01 PM   #4
Jman13
macrumors 65816
 
Join Date: Aug 2011
Location: Columbus, OH
Why? To intentionally restrict your audience? That's like Apple coming out with a great product that can only be purchased in New York by women aged 23-30.
Jman13 is offline   5 Reply With Quote
Old Jan 17, 2013, 05:01 PM   #5
Interstella5555
macrumors 603
 
Interstella5555's Avatar
 
Join Date: Jun 2008
No sure why you would want to do this, but there should be a way to identify the browser/device and throw up an error message.
Interstella5555 is offline   0 Reply With Quote
Old Jan 17, 2013, 05:06 PM   #6
bonskovsky
Thread Starter
Banned
 
Join Date: Dec 2012
I'm testing this new game, it can only work on iPhones. There's a reason to do this.

Just to see if it works, I feel like I'd need to edit the code that it uses to detect whether or not it's a mobile phone to begin with.
bonskovsky is offline   2 Reply With Quote
Old Jan 17, 2013, 05:09 PM   #7
Interstella5555
macrumors 603
 
Interstella5555's Avatar
 
Join Date: Jun 2008
Quote:
Originally Posted by bonskovsky View Post
I'm testing this new game, it can only work on iPhones. There's a reason to do this.

Just to see if it works, I feel like I'd need to edit the code that it uses to detect whether or not it's a mobile phone to begin with.
Just remember you'll need to block out desktop versions off all browsers as well as the associated OSs as well.
Interstella5555 is offline   1 Reply With Quote
Old Jan 17, 2013, 05:11 PM   #8
bonskovsky
Thread Starter
Banned
 
Join Date: Dec 2012
somehow, the code that i'm using automatically goes to mobile if on a mobile. so i just have to edit a little bit more code to make it more direct
bonskovsky is offline   1 Reply With Quote
Old Jan 17, 2013, 05:13 PM   #9
Brian Y
macrumors 68020
 
Join Date: Oct 2012
Just do a quick check of the referrer, and possibly the screen resolution too.

But remember these can all be faked - there's no known way to restrict to certain browsers/platforms that can't be circumvented.
Brian Y is offline   1 Reply With Quote
Old Jan 17, 2013, 05:22 PM   #10
Plutonius
macrumors 601
 
Plutonius's Avatar
 
Join Date: Feb 2003
Location: New Hampshire
Quote:
Originally Posted by bonskovsky View Post
I'm testing this new game, it can only work on iPhones. There's a reason to do this.

Just to see if it works, I feel like I'd need to edit the code that it uses to detect whether or not it's a mobile phone to begin with.
Let everyone into the site but mention on the site that Android users are out of luck if they want to play the game. They should upgrade their Android phone to an iPhone .
Plutonius is offline   3 Reply With Quote
Old Jan 17, 2013, 05:53 PM   #11
fireshot91
macrumors 601
 
fireshot91's Avatar
 
Join Date: Aug 2008
Location: Northern VA
You could just have a separate page be redirected to based on the OS.
__________________
MacRumors Scavenger Hunt score: 3
fireshot91 is offline   0 Reply With Quote
Old Jan 17, 2013, 07:55 PM   #12
Mrbobb
macrumors 601
 
Join Date: Aug 2012
The browser making request to ur page customarily sends that information to u.
Mrbobb is offline   0 Reply With Quote
Old Jan 17, 2013, 08:09 PM   #13
bonskovsky
Thread Starter
Banned
 
Join Date: Dec 2012
I'm going to try it.
bonskovsky is offline   1 Reply With Quote
Old Jan 17, 2013, 08:19 PM   #14
macsrcool1234
macrumors 6502a
 
Join Date: Oct 2010
I'm not aware of what web feature would work on iPhone 5's and nothing else but the easiest way to do this is to check the user agent string and only accept the iPhone 5's. This is relatively easy to bypass but gets the job done.
macsrcool1234 is offline   0 Reply With Quote
Old Jan 17, 2013, 08:31 PM   #15
tom71441
Banned
 
Join Date: Jan 2013
Use the 'User-Agent' property from the request header.

Look for ipad or iphone in the string.
Like
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16

I use regex just to match against iphone, so i don't have to worry about all the other version stuff


Quote:
Originally Posted by Brian Y View Post
Just do a quick check of the referrer, and possibly the screen resolution too.

But remember these can all be faked - there's no known way to restrict to certain browsers/platforms that can't be circumvented.
tom71441 is offline   0 Reply With Quote
Old Jan 17, 2013, 08:41 PM   #16
w00t951
macrumors 68000
 
w00t951's Avatar
 
Join Date: Jan 2009
Location: 116th & Broadway
Well, Apple uses this method for iCloud.com. On my Galaxy Nexus, it tells me that "Android Browsers are not supported."
__________________
MacBook Pro 15" Retina, iPhone 6 Plus, Harold (i7-4770K @ 4.5 GHz, GTX 980 @ 1512/3750MHz)
w00t951 is offline   0 Reply With Quote
Old Jan 17, 2013, 08:45 PM   #17
throAU
macrumors 68030
 
Join Date: Feb 2012
Location: Perth, Western Australia
Quote:
Originally Posted by bonskovsky View Post
I have a website that I'm making, but I only want it to work on iPhones, specifically the iPhone 5. I want an error message to show whenever someone tries to use an Android phone or computer to view the website.

What kind of code can I use to make this happen?
Don't be an idiot.


Writing non-standards compliant websites is bad when it is for IE, and also bad when it is for apple gear.


Yes, you CAN do it with the user-agent string. Doing so is still bad.

edit:
If the game does not support android, put a disclaimer on the site. Don't just block access entirely.
__________________
MBP (early 2011) - Core i7 2720 2.2ghz, Hires Glossy, 16GB, Seagate Momentus XT 750GB
Mac Mini (mid 2007) - Core2 Duo 1.8, 2gb, 320gb 7200 rpm
iPhone 4S, iPad 4, iPad Mini, HTC One (eval)
throAU is offline   2 Reply With Quote
Old Jan 17, 2013, 09:03 PM   #18
thehustleman
macrumors 65816
 
Join Date: Jan 2013
Quote:
Originally Posted by Plutonius View Post
Let everyone into the site but mention on the site that Android users are out of luck if they want to play the game. They should downgrade their Android phone to an iPhone .
Fixed that for you
thehustleman is offline   2 Reply With Quote
Old Jan 17, 2013, 09:18 PM   #19
Zac7
macrumors 6502a
 
Join Date: Jan 2011
Didn't think this guys threads could get better and he keeps proving me wrong.
Zac7 is offline   4 Reply With Quote
Old Jan 17, 2013, 11:02 PM   #20
bonskovsky
Thread Starter
Banned
 
Join Date: Dec 2012
Yeah and someone got rid of the iPhone-stupor thread. I guess they didn't think it was a real issue, which it is, I think.

I don't care about anyone bypassing it. The website just won't show up correctly. There are apps that only work with the 5, like the little panoramic vibration app.
bonskovsky is offline   0 Reply With Quote
Old Jan 18, 2013, 12:32 AM   #21
Zac7
macrumors 6502a
 
Join Date: Jan 2011
Quote:
Originally Posted by bonskovsky View Post
Yeah and someone got rid of the iPhone-stupor thread. I guess they didn't think it was a real issue, which it is, I think.

I don't care about anyone bypassing it. The website just won't show up correctly. There are apps that only work with the 5, like the little panoramic vibration app.
So you thought it was a necessary issue to discuss why you sometimes forget why you went on your iPhone?
Zac7 is offline   0 Reply With Quote
Old Jan 18, 2013, 12:40 AM   #22
bjm2660
macrumors 6502
 
Join Date: Jun 2011
Location: Virginia
sounds like technic cleansing
bjm2660 is offline   1 Reply With Quote
Old Jan 18, 2013, 01:16 AM   #23
vastoholic
macrumors 68000
 
vastoholic's Avatar
 
Join Date: Jan 2009
Location: Tulsa, OK
Quote:
Originally Posted by bonskovsky View Post
Yeah and someone got rid of the iPhone-stupor thread. I guess they didn't think it was a real issue, which it is, I think.

I don't care about anyone bypassing it. The website just won't show up correctly. There are apps that only work with the 5, like the little panoramic vibration app.
I just read that thread. That is not an iPhone issue. That's a brain fart issue. User error. People experience it. Phones and inanimate objects do not experience that issue and it was not necessary to create a thread about it.
__________________
View my flickr sets....if you want. They're not too exciting.
vastoholic is offline   0 Reply With Quote
Old Jan 18, 2013, 05:06 AM   #24
bonskovsky
Thread Starter
Banned
 
Join Date: Dec 2012
I still wanted to know why that happens to so many people. Because I think it's because of the way iOS is, is just a big long list of apps and they all look the same I just forget what I'm going to do.
bonskovsky is offline   0 Reply With Quote
Old Jan 18, 2013, 01:57 PM   #25
Stuntman06
macrumors 6502a
 
Join Date: Sep 2011
Location: Metro Vancouver, B.C, Canada
Quote:
Originally Posted by bonskovsky View Post
somehow, the code that i'm using automatically goes to mobile if on a mobile. so i just have to edit a little bit more code to make it more direct
Android browsers allow users to change the agent to make it appear to not be a mobile device.
__________________
<\
\>tuntman
Stuntman06 is offline   0 Reply With Quote

Reply
MacRumors Forums > iPhone, iPod and iPad > iPhone

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Smaller Android Phones Cole Slaw Alternatives to iOS and iOS Devices 10 May 7, 2014 06:48 PM
Moving between Android phones? How do I do it? gdourado Alternatives to iOS and iOS Devices 11 Nov 27, 2013 08:35 AM
phones: Who says Android phones are cheap? OllyW Alternatives to iOS and iOS Devices 10 Feb 13, 2013 08:29 AM
Apple Can Block Your Phones Whenever They Want!? Omacc iPhone 44 Oct 16, 2012 12:01 PM
Where are all these android phones made ? Che Castro Alternatives to iOS and iOS Devices 30 Jun 9, 2012 02:55 AM

Forum Jump

All times are GMT -5. The time now is 02:46 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC