User loginSearchNavigationActive forum topics |
Setup a Mobile Website
A while back, I setup ApGap.com (now defunct) to distribute my own J2ME MIDlets. I already had several websites at that time, but I discovered making a mobile website involves a bit more work. The first thing you need to know about is MIME types. Does your server deliver WML pages with the proper "text/vnd.wap.wml" type? MIME Types?When a web server delivers a page to your browser, it also ships out a bunch of header information that you don't normally see. This header data precedes the web page and warns your browser about what's coming next. Included in the header is the MIME type. The Multipurpose Internet Mail Extensions type for most web pages is "text/html". A lot of cell phones don't understand HTML so I personally don't recommend trying to use it to run a mobile site. Sure, a lot of phones will process HTML reasonably well and a lot of sites are now using it, but if you want the widest audience then WML is your best bet. WML?Wireless Markup Language is sort-of a light-weight version of HTML. I'll warn you right now, it's a pain. It's pretty limited compared to HTML. It's similar but different enough that you'll find it hard to switch back and forth between the two. I won't try to re-create a WML reference here. There are plenty of those on-line. As usual, I found the fastest way to learn was to look at some examples and copy them. ExampleThis is the WML for the ApGap home page:
The site is divided into multiple "cards" that are stacked into a single "deck". Visitors only see one card at a time on their phone but the other cards are already loaded and ready to be displayed if the user selects one. When rendered, the page looks something like this: Welcome to the Mobile Application Gap.
Links: 1 Full ApGap 2 Applications 3 Games 4 Ring Tones 5 Pictures 6 Messaging You can see this site is solely designed to deliver downloadable content to Sprint phones. I try to make the pages small and to the point. If you want to read all about what you are downloading then you have to visit the full HTML version of ApGap. I'm not trying to deliver articles or any kind of long text. I just want something easy to navigate so people can find the item they want to download and get on with it. The first card is basically an index to the other cards. I also provide a link to the HTML version of ApGap just in case you are brave enough to try viewing it from your cell phone. Realistically, I provide this link for PDAs and smartphones that have fast(ish) processors and large(ish) displays. I've divided my content into applications, games, ring tones, and pictures. Currently I don't have any games available, but I might some day so the category is just a placeholder for now. The last item isn't content for downloading. Rather, it's a simple form for sending Sprint text messages from your cell phone. Sprint has a form at http://messagings.sprintpcs.com but you will find that page is practically unusable from a cell phone. I made a simpler version of it for my WML site, but that's a topic for another article. AccesskeyIf you already know WML, then you may be wondering what the "accesskey" attribute is on the anchor tags. While I am the first to standup and argue for adhering to standards, the accesskey attribute is an indulgence that can't be passed up. On most Sprint phones, this will create single keystroke shortcuts to hyperlinks. That means visitors can simply press "4" on their keypads to jump to the ring tone download page. While it's not a standard WML attribute, it sure makes a WML page easier to use. Alternatively, you'd have to scroll down to the link you want and select it. You'll find that every keystroke you save is important. Mobile keypads are hard to use and the more you can avoid it, the better. CardsRanking right up there with things to be avoided is network access. You'd like to design your site to minimize the number of times the mobile device has to query the network. In fact, you'll find that devices feel slow because of the number of network transactions, not because of the speed of the network. Sprint offers a very fast 3G network. I can download a good size MIDlet in just a few seconds, but slogging through multiple pages in the browser is painful. Every time you select a link, the device has a pleasant conversation with the server over tea and biscuits before you actually get to see what you want. I don't really know what they are discussing so thoroughly but it just seems to take forever. I suppose it's like watching a pot boil. You are left standing there staring at the little arrows go back and forth. Thrilling. It's one of the reasons Short Mail is so hated. Every message you receive requires three interactions with the network to read. You waste more time waiting for each client/server pleasantry then it would take to just download the stupid 100 character message in one shot. Sorry, back to the subject. I avoid these little network interactions by downloading several cards at once when the user requests the ApGap home page. If your mobile site has several pages to it, try putting them all together in a single deck, then look at how long it takes to retrieve the entire deck vs. downloading a smaller version that points to multiple files. I think you'll find the overhead of simply loading everything in one shot is worth it for the responsiveness that you gain. When you select "Ring Tones" from ApGap, you are immediately taken to a directory of GCD links for ring tones. That list was loaded along with the front page so the transition happens quickly, without network interaction. GCD?This is where things get sticky for most people. To download ring tones and pictures to Sprint phones, you need to have a General Content Descriptor for each file. Likewise, to send Java programs, you need a Java Application Descriptor. If you don't know what goes into a JAD, there's another article that covers that topic. What I'd like to point out here is that sending GCD files and JAD files requires that your sever have the proper MIME type defined for those files. Ah, this is where we started! Yes, it comes back to MIME types. Most servers are already configured to support the popular MIME types. Unfortunately, GCD, JAD, and JAR files aren't considered popular MIME types. Dollars to doughnuts, your server won't handle them properly. You can't just make a web page on your AOL account and server up cell phone content. In fact, it's difficult to find a hosting company that (1) will allow you to define MIME types or (2) has the proper types already defined. CachingOne final gotcha you will face is Sprint's aggressive caching policies. When you request a page or a file from a server it may not come from the server. It may instead come from Sprint's local cache of the file. You see, WAP browsing works through a proxy. When you request a page from ApGap, your phone sends the request to Sprint and Sprint acts as a proxy for your phone. Sprint goes to ApGap, retrieves the file and passes it on to you. In an effort to optimize, Sprint may not go to ApGap every time. Instead, Sprint will keep a local copy of pages that are requested frequently. Many times Sprint will just send that cached copy to your phone rather than requesting a fresh copy from the server. While this is a great way to save bandwidth for Sprint, it causes real problems for developers. While you are testing out some new code, you might upload several copies to your website so that you can then download them to your phone. Unless each copy has a unique name, Sprint will step in, cache the first version of your program and for there after and ever more, that will be the only version you will be able to download. Obviously this is not good. To get around the issue, I add some junk on to the end of my URLs that fool Sprint into thinking that I am requesting new content every time. That's why you'll notice the link to my SendNote application looks like "applications/SendNote.jad?r=020002". This means the program is in the "applications" sub-directory and the revision number is "020002". I use revision numbers to help me keep things straight but any junk will do. I could have easily used "?junkblahgarbage" at the end of the URL. As long as it's unique then I'm sure I'm getting the latest copy from my server instead of a stale copy from Sprint's cache. Remember, your GCD and JAD files also contain links to your actual content like your JPG or JAR file. You will also need to update the links in your descriptors every time as well. If you look inside my JAD file for SendNote, you'll find "http://www.apgap.com/applications/SendNote.jar?r=020002" for the JAR file. The need for this type of URL monkey business is one of the most annoying parts of trying to develop Sprint applications. I have written some scripts that automatically generate the corrected URLs by adding random numbers or using the version number from the JAD file. Cut to the ChaffI use Digital Sense Hosting for most of my websites and I highly recommend them. They are cheap and they give you lots of control over the server. I have Linux accounts using Apache servers. That means I can create all the MIME types I need by adding lines like the following to my ".htaccess" file. AddType text/x-pcs-gcd .gcd
AddType text/vnd.sun.j2me.app-descriptor .jad AddType application/java-archive .jar AddType text/x-hdml .hdml AddType text/vnd.wap.wml .wml AddType text/vnd.wap.wmlscript .wmls AddType image/vnd.wap.wbmp .wbmp AddType audio/x-midi .mid AddType audio/vnd.qcelp .qcp AddType image/png .png That's overkill really. Most of those are already properly defined in the httpd.conf file. Really, the only ones I need are jar, jad, gcd, and qcp. Step by StepMake some content you want to download. This could just be some small pictures you want to use for caller-ID or a complete J2ME MIDlet. Remember, you'll need GCD and/or JAD files for your content. Make a WML deck with links to your GCD and JAD files. You can start by taking mine and modifying it as needed. You can test it out using the Klondike WAP Browser. Go to GoDaddy and get a domain name. This is optional but they are less than $10/yr. Again, you don't need it. Go to Digital Sense and sign up for a Linux account. If they ask for your domain name and you don't have one, just make something up. It won't matter. They'll give you an IP address to access your account directly like http://127.0.0.1/~you or something similar. Upload your WML file, your descriptors, and your content to your new web server. Digital Sense supports FTP and they also have a web page interface for uploading files. Go to your phone and enter the URL to your WML file. Click, download, enjoy.
|