How do you block your website from Android phones?

Discussion in 'iPhone' started by bonskovsky, Jan 17, 2013.

  1. bonskovsky, Jan 17, 2013
    Last edited: Jan 17, 2013

    macrumors 6502

    bonskovsky

    Joined:
    Dec 31, 2012
    #1
    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?
     
  2. macrumors 68020

    Joined:
    Dec 13, 2012
    Location:
    Southern California
    #2
    Give it a rest, or look in the mirror. There's something very wrong with this picture.
     
  3. macrumors 68020

    Squilly

    Joined:
    Nov 17, 2012
    Location:
    PA
    #3
    Java? Enable a pop-up that prevents anything but 6,1 (iPhone code name) from accessing the site.
     
  4. macrumors 65816

    Joined:
    Aug 7, 2011
    Location:
    Columbus, OH
    #4
    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.
     
  5. macrumors 603

    Interstella5555

    Joined:
    Jun 30, 2008
    #5
    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.
     
  6. thread starter macrumors 6502

    bonskovsky

    Joined:
    Dec 31, 2012
    #6
    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.
     
  7. macrumors 603

    Interstella5555

    Joined:
    Jun 30, 2008
    #7
    Just remember you'll need to block out desktop versions off all browsers as well as the associated OSs as well.
     
  8. thread starter macrumors 6502

    bonskovsky

    Joined:
    Dec 31, 2012
    #8
    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
     
  9. macrumors 68030

    Joined:
    Oct 21, 2012
    #9
    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.
     
  10. macrumors 601

    Plutonius

    Joined:
    Feb 22, 2003
    Location:
    New Hampshire
    #10
    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 :).
     
  11. macrumors 601

    fireshot91

    Joined:
    Jul 31, 2008
    Location:
    Northern VA
    #11
    You could just have a separate page be redirected to based on the OS.
     
  12. macrumors 601

    Joined:
    Aug 27, 2012
    #12
    The browser making request to ur page customarily sends that information to u.
     
  13. thread starter macrumors 6502

    bonskovsky

    Joined:
    Dec 31, 2012
    #13
    I'm going to try it.
     
  14. macrumors 6502a

    Joined:
    Oct 7, 2010
    #14
    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.
     
  15. macrumors newbie

    Joined:
    Jan 17, 2013
    #15
    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


     
  16. macrumors 68000

    w00t951

    Joined:
    Jan 6, 2009
    Location:
    116th & Broadway
    #16
    Well, Apple uses this method for iCloud.com. On my Galaxy Nexus, it tells me that "Android Browsers are not supported."
     
  17. macrumors 68030

    Joined:
    Feb 13, 2012
    Location:
    Perth, Western Australia
    #17
    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.
     
  18. macrumors 65816

    Joined:
    Jan 3, 2013
    #18
    Fixed that for you
     
  19. macrumors 6502a

    Joined:
    Jan 9, 2011
    #19
    Didn't think this guys threads could get better and he keeps proving me wrong.
     
  20. thread starter macrumors 6502

    bonskovsky

    Joined:
    Dec 31, 2012
    #20
    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.
     
  21. macrumors 6502a

    Joined:
    Jan 9, 2011
    #21
    So you thought it was a necessary issue to discuss why you sometimes forget why you went on your iPhone?
     
  22. macrumors 6502

    Joined:
    Jun 7, 2011
    Location:
    Virginia
    #22
    sounds like technic cleansing
     
  23. macrumors 68000

    vastoholic

    Joined:
    Jan 28, 2009
    Location:
    Tulsa, OK
    #23
    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.
     
  24. thread starter macrumors 6502

    bonskovsky

    Joined:
    Dec 31, 2012
    #24
    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.
     
  25. macrumors 6502a

    Stuntman06

    Joined:
    Sep 19, 2011
    Location:
    Metro Vancouver, B.C, Canada
    #25
    Android browsers allow users to change the agent to make it appear to not be a mobile device.
     

Share This Page