Blog

PhoneGap iOS UIWebView and Safari.app Links

When creating a PhoneGap jQuery Mobile project you have two options for opening links:

  • UIWebView This is PhoneGap’s in app browser
    • The draw back for me was that there is no navigation in UIWebView. Thus no way to navigate back to the app
    • The upside for me was that I could use iFrames (out of necessity not out of want) using UIWebView
  • Safari.app As you can guess, this is iOS’s default browser
    • Links open in Safari and load as expected
When I was creating my project I had a bunch of external links that I was happy sending off to Safari but I had a 3rd party iFrame for a chat feature that needed to function within the app.  To just enable UIWebView for the single URL I used this code [projectFolder > Classes > AppNameDelegate.m]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:
    (NSURLRequest*)request navigationType:(UIWebViewNavigationType)
    navigationType
{
    NSURL *url = [request URL];

    if ([[url absoluteString] rangeOfString:
        @"URLToOpenInUIWebView.com"].location != NSNotFound) {
       
        return YES;
    }
    else {
        return [self.viewController webView:theWebView
            shouldStartLoadWithRequest:request
            navigationType:navigationType];
    }
}

To enable external domains in PhoneGap you have to whitelist the URLs as of PhoneGap 1.0.
To do this go to projectFolder > Supporting Files > PhoneGap.plist
You should have a list of Key/Type/Values.  First check to see if ExternalHosts is one of the keys.  If it isn’t then right click the list and choose Add Row.  You’ll want it to look like ExternalHosts/Array/count (this is auto generated)
Now that you have ExternalHosts you will want to add URLs to this array to whitelist.
You can use the wildcard symbol * in this list.  So *.domainName.com would allow all subdomains.  There is nothing stopping you from using * or *.* to allow ALL URLs to be whitelisted.  I leave that to you.

I was using Xcode 4.2.1, OSX Lion 10.7.3, PhoneGap 1.4.1 and jQuery Mobile 1.0.1

Zombie Lane Gifting URLs Exploit

Zombie Lane (Facebook game) uses URLs to send in game items called Gifts.

Therefore the game normally locks out specific items until the player has reached a specific character level.
For instance a user should be level 30 before being able to send +7 energy to another user.  Using the URLs below allows you to circumvent this.

As of version 1.1.8 of the game this is still a security hole that has not been patched.

Originally I was pretty psyched to create an application that would allow other ZL players to easily do this as well.  The problem comes in the form of time.  Already wasted 3 hours making a solution specific to me (a single webpage with 32 ZL players that when I click on their 32×32 pixel FB photo an individual page loads prompting 7 pop up windows to send all 7 items to that specific user).  So now I click on 32 images and some super crude Javascript window.open pop ups do the work for me.  Of course I had to tell my browser to allow pop ups and each browser has limits on the number of pop ups it will allow (Chrome allowed me to load 25 before it blocked further, Firefox 4 blocked after 20 and Internet Explorer 8 allowed me to open all 192 pages while almost freezing my 8GB RAM, 6 core computer).  I couldn’t find where to alter these limits.

If anyone is interested in making an app that would take advantage of these links would have to consider these points:

  1. Facebook vanity / username URLs won’t work
    &recipient=some.name.that.you.chose won’t work.  So you’ll have to convert vanity names to UIDs.
  2. Possible TOS issues
    I skimmed through both Facebook Developer TOS and Zombie Lane TOS and didn’t see anything that would be an issue.  After all these are using URLs that are publicly available.
  3. Pop Ups
    To open the URLs you will need to use pop ups.  No one likes pop ups.  Every browser has pop up blockers enabled and it will be a hassle to have people unblock them.
  4. Storing User Facebook Friends
    If you make it web based you are going to have to keep track of who people want to send to, otherwise they will have to enter this information every time.  So now you have to handle the privacy issue.  You can encode the data, but the average user is still going to be suspicious of your intent.
  5. Webbased vs Standalone
    So PHP, Javascript, FBML, Ruby.  Now you need hosting or you have to have people trust a EXE.  Fun times.
  6. Digital Chocolate changes exploit in next version and you wasted a huge amount of time
    THIS.

So what do I suggest.  Just use the URLs for yourself for now.

Shotgun
+3 Energy
+5 Energy
+7 Energy
Blueprint
Grenade
Land Mine

Shotgun
http://apps.facebook.com/zombielane/SendGift?gid=Shotgun&request_type=GiftRequest&recipient=580606262
Energy +3
http://apps.facebook.com/zombielane/SendGift?gid=EnergyCola&request_type=GiftRequest&recipient=580606262
Energy +5
http://apps.facebook.com/zombielane/SendGift?gid=EnergyCola2&request_type=GiftRequest&recipient=580606262
Energy +7
http://apps.facebook.com/zombielane/SendGift?gid=EnergyCola3&request_type=GiftRequest&recipient=580606262
Blueprint
http://apps.facebook.com/zombielane/SendGift?gid=Blueprint&request_type=GiftRequest&recipient=580606262
Grenade
http://apps.facebook.com/zombielane/SendGift?gid=Grenade&request_type=GiftRequest&recipient=580606262
Land Mine
http://apps.facebook.com/zombielane/SendGift?gid=LandMine&request_type=GiftRequest&recipient=580606262
How the links look.  Replace the &recipient= at the end to the UID of your friend.

To find this I made this really quick.  Enter a vanity name and it will show you the user ID number.

http://www.facebook.com/

All that is left to do is to create a list of links that you can click on.  You’ll have to look into HTML or Javascript

HTML Example

<a href=’http://apps.facebook.com/zombielane/SendGift?gid=Shotgun&request_type=GiftRequest&recipient=580606262′>Shotgun</a>

Javascript Pop Up Example

<script language=”javascript”>window.open(‘http://apps.facebook.com/zombielane/SendGift?gid=Shotgun&request_type=GiftRequest&recipient=580606262′,”,’width=350,height=200′)</script>

Hope this helps.

Tax Return Spending

Upgraded my computer a few weeks ago.  I had a Dual Core 2.2GHz, 4GB RAM with a Nvidia 8600 GTS graphics card.  My new computer is a AMD Phenom II X6 (6 cores), 8GB of RAM with a ATI Radeon HD 6670 1GB DDR5.

I was also using an old wooden writing desk that my parents had bought when I was a teenager.  With my tax return I bought a new BENQ 20 inch LED LCD monitor (man they are thin) and a desk from Ikea.

All and all, I love my new work area.

Ordered Some Threadless Shirts

Today I purchased a few shirts from Threadless for $12 a piece.  I wouldn’t have even known about the sale if it wasn’t for a Facebook ad.  I find this interesting because it is the first time that an online ad has resulted in me purchasing something.  I’m sure it won’t be the last, but I felt like sharing that online marketing does work, or at least it works on me apparently.

Pixel Adventure

Up late playing with hair modifications on the base sprites.

Its been awhile since I updated this blog.  Moved to St Albert, been working at a grocery store for the last six months while trying to find a job in anything computer related (programmer, technical support, QA, etc).  Finished one of three courses remaining in my BSc.  The image above is from a project that will be used in the second last course.  That brings me to Pixel Adventure (I really suck at the naming – see Ninja Adventure).  It is a Java 2 ME game that will then be ported to Flash, where then it will be further extended into either a more robust J2ME game or more likely a better Flash game.  For those that are counting this course requires the creation of three “games”.  They are not full games mind you, they only require 2 levels, so its more about the mechanics/systems.

The first two games will involve basic platforming.  Walk, jump, collect things and have a timer count down.  Very simplistic.  The third game is to be extended but this means making more systems available.  Perhaps character customization (as you can see above I’ve been preparing for this, however haven’t decided if it will be used), highscores, inventory system, and moving platforms.  Stuff like that.

I personally like having assets to begin with so that I feel like I’m bringing these characters to life and creating a world for them to navigate.  I simply can’t bring myself to use placeholder sprites (ex. a black box).  I realize that is a bad way to go about things, but perhaps its just my lack of experience in game programming that makes me think this way.

Either way, I hope to update progress on Pixel Adventure throughout its development.