Activate your free membership today | Log-in

Monday, May 18th, 2009

Someone at Apple, please review stance on PhoneGap

Category: Editorial, iPhone

We are big fans of PhoneGap, the “open source development tool for building fast, easy mobile apps with JavaScript” including apps that run on the iPhone platform.

The PhoneGap team has been winning awards and developers like it.

However, we have just heard that some applications using PhoneGap have been targetted by the Apple review process:

Upon review of your application, cannot be posted to the
App Store due to the usage of private API. Usage of such non-public
API, as outlined in the iPhone SDK Agreement section 3.3.2 is
prohibited:

” An Application may not itself install or launch other executable
code by any means, including without limitation through use of a plug-
in architecture, calling other frameworks, other APIs or otherwise.
No interpreted code may be downloaded and used in an Application
except for code that is interpreted and run by Apple’s Published APIs
and built-in interpreter(s).

The PhoneGap API implemented in your application is an external
framework.

This is just wrong. They haven’t targeted RegexKitLite or Google Toolbox for Mac, or Joe Hewitt’s cool new framework. PhoneGap only uses official APIs, so it isn’t doing anything wrong there.

You could assume that this is on purpose, to keep people in the Obj-C sandbox. Or, you could consider the fact that the review process is probably manned by a LOT of people who sit there with check lists. I am hoping that someone at Apple gets to see the outcry from developers and steps in to do the right thing, just like they did when Trent Reznor and many others complained about the hypocrisy of his iPhone app not getting in the store.

So, fix it Apple. Please.

Posted by Dion Almaer at 9:03 pm
21 Comments

++++-
4.2 rating from 41 votes

Thursday, March 26th, 2009

jQTouch: a mobile WebKit JavaScript framework

Category: JavaScript, Library, Mobile, iPhone

David Kaneda has created jQTouch a "jQuery plugin with native animations, auto list navigation, and default application styles for Mobile WebKit browsers like iPhone, G1, and Pre."

Features

Setup

jQTouch can now be initialized with one function:

JAVASCRIPT:
  1.  
  2. $(document).jQTouch({
  3.    icon: 'jqtouch.png',
  4.    statusBar: 'black-translucent'
  5. });
  6.  

This function writes all of the meta tags needed for an iPhone web app. Here are the default settings:

JAVASCRIPT:
  1.  
  2.  fullScreen: true,
  3.  slideInSelector: 'ul li a',
  4.  backSelector: '.back',
  5.  flipSelector: '.flip',
  6.  slideUpSelector: '.slideup',
  7.  statusBar: 'default', // options: black-translucent, black
  8.  icon: null,
  9.  iconIsGlossy: false,
  10.  fixedViewport: true
  11.  

Animations

There are now functions for sliding a page up, and "flipping" to a page, using WebKit's built-in 3D capabilities. Both can be seen in the new preview

These new animations are integrated into the page history, and can be navigated by using the back button.

Image Preloading

I've added a quick-and-dirty function for preloading images, which you just send as an array. For example:

JAVASCRIPT:
  1.  
  2.  $.preloadImages([
  3.      'themes/jqt/img/chevron_white.png',
  4.      'themes/jqt/img/bg_row_select.gif',
  5.      'themes/jqt/img/back_button.png'
  6.      ]);
  7.  });
  8.  

Minor Improvements

  • New HTML structure to ease toolbar button variations and improve animations.
  • Various performance improvements
  • Added minified code
  • Started a custom theme, which will be offered alongside the standard Apple theme
  • Created a new Home Screen icon
  • Removed some iPhone-dependent code

David also answered some questions for us:

How does it compare to iUI?

It is similar in the way it can load views via built-in HTML or dynamic GET/POST requests, but it uses hardware-accelerated animations, and also includes transitions like slide up and 3D page flip. It also includes code for image preloading, a custom theme, and a much easier setup function which eliminates the need to write META tags for the app icon, viewport settings, etc.

What kind of extended functionality are you looking into

Ultimately, I plan on testing extensively on the G1 and, eventually, the Palm Pre. Other plans include a more robust theming system, and various callback methods to make extending jQTouch even easier.

With PhoneGap, would it just be a script that you can get built in?

I am currently in talks with the PhoneGap crew, and we are planning on including it stock with the kit. We're currently unsure if the script should be ported to XUI or remain based on jQuery.

Posted by Dion Almaer at 4:02 am
6 Comments

+++--
3.3 rating from 34 votes

Wednesday, March 18th, 2009

iPhone 3.0 now with SquirrelFish Extreme?

Category: JavaScript, Mobile, iPhone

James Churchman did a quick bit of detective work and pointed the iPhone 3.0 simulator on the WebKit detector that we blogged about in the past.

The new showed this:

Compared to the old version:

Posted by Dion Almaer at 10:12 am
4 Comments

+++--
3.9 rating from 9 votes

Friday, February 20th, 2009

Windows iPhone Simulator

Category: iPhone

There's no way to emulate the iPhone on Windows, but Shaun Sullivan has the next best thing: taking a Windows build of WebKit and embedding it inside an iPhone-like Chrome. It's not perfect, but it's as close as Windows users are going to get for now–and is very handy for checking how your site will likely look (modulo font issues).

He's only tested it on Vista, however.

Posted by Ben Galbraith at 9:00 am
5 Comments

+++--
3.6 rating from 49 votes

Tuesday, February 3rd, 2009

HTML5 Features in latest iPhone; Application Cache and Database

Category: Database, HTML, Mobile, Standards, iPhone

Brad Neuberg told me about two cool additions to the iPhone that now use HTML5 features:

Safari JavaScript Database Programming

The HTML 5 specification provides a new mechanism for client-side data storage: JavaScript database support. HTML 5 is currently in development by the Web Hypertext Application Technology Working Group (WHATWG).

JavaScript database support is available in Safari 3.1 and later, and in iPhone OS 2.0 and later.

You should read this documentation if you are a web developer who wants to store data locally on a user’s computer in amounts beyond what can reasonably be stored in an HTTP cookie.

HTML5 Application Cache

Michael Nordman of Google asked "Is this stuff built into shipping Safari or iPhone browsers yet?"

David Kilzer replied "This feature shipped with iPhone OS 2.1. When you use "Add to Home Screen" from the "+" button on Safari for iPhone, a web application with a manifest defined (per the HTML5 spec) will be saved with any cached resources. Note that the manifest file *must* be served with the correct MIME type for this to work.

There is no shipping version of Safari for Mac OS X or Windows that supports this feature yet."

Fantastic to see!

Posted by Dion Almaer at 12:31 am
7 Comments

++++-
4.6 rating from 12 votes

Tuesday, December 2nd, 2008

S5 Presentations with CSS Transitions

Category: Ajax, CSS, iPhone

Shawn Lauriat hacked CSS Transition support into the presentation app S5. Now he has posted slides from one of his talks that uses the functionality.

See how you can add fun (or annoying ;) transitions to your S5 prezos, even on the iPhone:

Posted by Dion Almaer at 5:48 am
1 Comment

+++--
3.7 rating from 19 votes

Monday, November 24th, 2008

Interactive iPhone Console using JSCocoa

Category: Debugging, JavaScript, iPhone

KUMAGAI Kentaro has created a JSCocoa based interactive console for the iPhone:

I’ve been struggling with transform property of UIView for long time. at last, I’ve decided to create UIMonkey that allows to manipulate the variables by trial and error through HTTP in Javascript with SpiderMonkey. Few days after I’ve started the project, I found JSCocoa through John Resig's article and I abandoned my project and rewrited my codes on JSCocoa.

Now it works on the top of JSCocoa. It’s very helpful while inspecting the hierarchy of the view tree or size of the views etc.

Very cool stuff as you can run code on the fly and see it all change in the emulator. His article explains how you set it up, and gives you some fun examples.

Posted by Dion Almaer at 6:12 am
Comment here

+++--
3.5 rating from 4 votes

Friday, November 21st, 2008

iPhone for JavaScript Developers

Category: Mobile, iPhone

John has done a really good job at wrapping up information on the various options for JavaScript developers on the iPhone platform.

He discusses the various approaches:

  • JiggyApp: JiggyApp provides a full API for developing an application - apparently separate from most of the typical APIs. Arguably, though, the code ends up being relatively usable (jailbroken only :(
  • JSCocoa: JSCocoa is a full bridge that maps Cocoa development into JavaScript (instead of the typical Objective-C/Cocoa mapping). The result ends up working in both OS X and on the iPhone.
  • PhoneGap: PhoneGap is an application that exposes a few JavaScript APIs to pages running MobileSafari. Right now this includes Geolocation and access to the Accelerometer.
  • WebTouch: The other day "Dr Nic" wrote up an article on how he had used a WebKit instance (along with HTML, CSS, and JavaScript) to render a portion of his iPhone application.

I was chatting with someone on the PhoneGap team about their Android support. There is a play to be had to enable rich mobile applications all based on the Open Web stack that we know and love :)

Posted by Dion Almaer at 6:23 am
14 Comments

+++--
3.9 rating from 8 votes

Friday, November 14th, 2008

Using UIWebView (WebKit) in your iPhone App

Category: Mobile, iPhone

Dr Nic has shared his experiences using WebKit to implement part of your iPhone app (in his case SurfView):

Negatives

  • - (void)webViewDidFinishLoad:(UIWebView *)webView is slow. "You’re running an interpreter (JavaScript runtime) on top of a device with a small CPU and small memory. Go figure."
  • The JavaScript bridge does not appear to block the main thread. This is a good/bad thing. You can invoke JavaScript code within the WebKit via your native Objective-C code.
  • The JavaScript bridge is one directional. From Objective-C/UIKit you can invoke JavaScript upon the WebKit and henceforth do wonderful things
  • Multiple languages in one project. Whilst we mainly just wanted to take a static HTML file, and dynamically update various elements with application data (e.g. the surf and weather conditions in the example above), we needed to do that via JavaScript.

Why you may want to do it

WebKit for rapid prototyping: WebKit exists and it is awesome at rendering HTML and CSS, with access to the powerful CSS3 transformations and webkit-specific bonus features.

It is highly likely that your designer can make something beautiful looking in Photoshop and cut it up into HTML + CSS. Comparatively, its highly unlikely they can cut it up into native Objective-C code.

WebKit isn’t the holy grail for non-Objective-C developers, but if your grand-poobar level skills are in JavaScript and HTML, and your Objective-C/iPhone skills are still catching up, then its a wonderful prototyping platform. Especially for static, complicated displays of data. Especially if that data includes HTML content from an external feed which needs to be rendered.

For Oakley’s Surf Report app, Anthony is toying with replacing some of the WebKit usage with native UI elements (normal UITableView with custom UITableViewCells) so that we can get back those precious seconds and give them to the user as a Christmas present.

A very nice read.

Posted by Dion Almaer at 8:21 am
4 Comments

++++-
4.3 rating from 9 votes

Friday, November 7th, 2008

CSS-VFX: CSS Visual Effects Tutorials and Components

Category: Apple, iPhone

We've talked a bit about Apple's extensions to HTML and CSS; <canvas> has of course gone on to much fame and fortune. Charles Ying pointed us to his CSS-VFX project which aims to be

a collection of components and code examples that illustrate the power of CSS Visual Effects. So far, only 1 gem that illustrates a popular RIA user interface demo, "Cover Flow" is currently available. If you'd like to see more, please don't hesitate to suggest something you'd like to see.

Charles has a blog entry with a video showing off a mobile Safari demo of using Apple's CSS Visual Effects to create a Cover Flow interface:

The demo makes use of a variety of these extensions:

* zflow starts by loading each image from the images array. When each image is loaded, we scale the image to fit in a square region, and apply 3D CSS transforms to scale it in place.
* Reflections - zflow then takes the scaled image and creates a Canvas element that contains a gradient alpha mask of the image’s reflection (using a “reflect” function to do this) and positions the canvas element in place.
* Touch Controller - zflow creates a TouchController object, who’s job is to field touch events from Mobile Safari and calculate an appropriate offset.
* Clicking - zflow detects when no move events have been made, and zooms + rotates the focused image forward by setting a “CSS Transition”ed 3D transform on the focused image. Clicking again transitions the image back.
* Inertia - zflow achieves inertia by setting the “transition timing function” of the “tray” to an “ease-out” function, which slows things down. On the touch end event, we calculate the projected velocity and set the tray’s target position to that location. CSS Transitions handles the decay in velocity as the transition timing function executes — slowing the tray down gradually.

It makes you wonder how many folks are going to need to learn the SDK in the future...

Posted by Ben Galbraith at 7:00 am
5 Comments

++++-
4 rating from 6 votes

Thursday, October 9th, 2008

Exclusive iPhone in Action Chapter Downloads

Category: iPhone

Now that the NDA has been released, book publishers are finally able to get out their wares. Christopher Allen and Shannon Appelcline have written iPhone in Action, and have kindly given the Ajaxian community free downloads of a couple of the early access chapters:

I hope to see books that focus on what you can do with the Web APIs too of course ;)


This article is based on iPhone in Action, to be published January 2009. It is being reproduced here by permission from Manning Publications. Manning early access books and ebooks are sold exclusively through Manning. Visit the book's page for more information.

Posted by Dion Almaer at 10:26 am
Comment here

++---
2 rating from 4 votes

Friday, October 3rd, 2008

iPhone Web Apps running at full screen

Category: Mobile, iPhone

I am so happy that the NDA mess is over! Clancy has written about how you can have your iPhone Web app run in full screen and has a demo app that shows it off:

HTML:
  1.  
  2. <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
  3. <meta name="apple-mobile-web-app-capable" content="yes" />
  4. <meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
  5.  

Posted by Dion Almaer at 4:03 pm
13 Comments

+++--
3.3 rating from 25 votes

Monday, September 29th, 2008

iPhone Safari 3D Navigation Menu

Category: Mobile, iPhone

Ben Putman has put together a nice iPhone Safari 3D navigation menu example that shows off the transforms and events available on the latest mobile Safari.

Ben told us:

In thinking of an interesting test, I've created a menu that you can rotate across a fixed y-axis with touch, allowing you to spin the menu around and see the depth and back of elements. There are also some examples of how animations can be used as you click and the menu unfolds. I also added a lightbox to examine how one might view some photos although it's not really practical in this form.

Open up the demo in your iPhone / Touch and also take a peak at the source to see what is going on, with snippets like this:

CSS:
  1.  
  2. .second_show {
  3.   -webkit-animation-name: 'second_show';
  4.   -webkit-animation-duration: 1s;
  5. }
  6.  
  7. @-webkit-keyframes 'second_show' {
  8.   from {    -webkit-transform: translateZ(0px) rotateX(180deg);}
  9.   to {    -webkit-transform: translateZ(100px) rotateX(0deg);}
  10.  
  11. }
  12. .second_hide {  -webkit-animation-name: 'second_hide';  -webkit-animation-duration: 1s; }
  13. @-webkit-keyframes 'second_hide' {
  14.   from {    -webkit-transform: translateZ(100px) rotateX(0deg);}
  15.   to {    -webkit-transform: translateZ(0px) rotateX(180deg);}
  16. }
  17.  

Posted by Dion Almaer at 6:42 am
1 Comment

++---
2 rating from 65 votes

Monday, September 22nd, 2008

PhoneGap: “AIR for the iPhone”

Category: iPhone

Dave Johnson calls PhoneGap "AIR for the iPhone" because this nice little hack, first created at an iPhone BarCamp, wraps the Web view with a container. This container gives the view access to APIs available on the device, that may not be available yet via WebKit alone. AIR provides a similar container for Flash and Ajax content on the desktop.

PhoneGap is a free open source development tool and framework that allows web developers to take advantage of the powerful features in the iPhone SDK from HTML and JavaScript. We're trying to make iPhone app development easy and open. For many applications a web application is the way to but in Safari you don't get access to the native iPhone APIs, and the that's the problem we're trying to solve.

It is written in Objective-C and allows developers to embed their web app (HTML, JavaScript, CSS) in Webkit within a native iPhone app. We're big advocates of the Open Web and want JavaScript developers to be able to get access iPhone features such as a spring board icon, background processing, push, geo location, camera, local sqlLite and accelerometers without the burden of learning Objective-C and Cocoa.

PhoneGap also has a web app that allows web developers to quickly package their web app into a native iPhone app by providing a URL, a name and icon graphic the web service with automagically create a native iPhone application. We haven't open sourced that code but we're going to soon.

PhoneGap was conceived at iPhoneDevCamp II by Nitobi developer Brock Whitten, Rob Ellis, freelance designer Colin Toomey and Eric Oesterle.

There are a few APIs available now, and others pending:

JAVASCRIPT:
  1.  
  2. // Location API
  3. // Feels a little ugly compared to passing in a closure. Using a hard coded name? :)
  4.   getLocation();
  5.  
  6.   //GAP will invoke this function once it has the location
  7.   function gotLocation(lat,lon){
  8.     $('lat').innerHTML = "latitude: " + lat;
  9.     $('lon').innerHTML = "longitude: " + lon;
  10.   }
  11.  
  12. // Accelerometer API
  13.  
  14.   function updateAccel(){
  15.     $('accel').innerHTML = "accel: " + accelX + " " + accelY + " " + accelZ;   
  16.     setTimeout(updateAccel,100);
  17.   }
  18.  
  19. // Camera (pending)
  20.   function takePhoto(){
  21.     var photo = gap:takePhoto();
  22.     return photo;
  23.   }
  24.  
  25. // Vibration (pending)
  26.  
  27.   function vibrate(){
  28.     gap:vibrate();
  29.     return false;
  30.   }
  31.  

You can take a peak at the open source code on github. For example, here is the code that wraps the iPhone location service:

[c]
@implementation Location

- (id)init{
NSLog(@"Gap::Location");
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
return self;
}

+ (void)startTracking{
NSLog(@"starting location tracker");
[locationManager startUpdatingLocation];
}

+ (void)stopTracking{
NSLog(@"stopping location tracker");
[locationManager stopUpdatingLocation];
}

- (void)location{
NSLog(@"location is");
}

- (void)log{
NSLog(@"the location is...");
}

- (void)dealloc {
[locationManager release];
[super dealloc];
}

@end
[/c]

Posted by Dion Almaer at 7:33 am
5 Comments

+++--
3.8 rating from 19 votes

Thursday, September 18th, 2008

SVG working on the iPhone

Category: Mobile, SVG, iPhone

Dylan Schiemann wrote about how disappointing it was that the iPhone didn't support SVG:

Safari on the iPhone does not currently have support for SVG. Safari 3 beta on Mac and Windows is currently the best browser on the planet for SVG performance, so this is a somewhat disappointing omission. We are hopeful that by the end of the year, the iPhone will receive the Safari 3 upgrade, and along with that native support for SVG. For now, we’ll have to wait on dynamic charting and drawing tools due to no SVG and the lack of mousemove event handlers.

It appears that if you point your iPhone 2.1 browser to SVG content and tests it now works!

Posted by Dion Almaer at 6:41 am
9 Comments

+++--
3.3 rating from 6 votes

Wednesday, September 17th, 2008

iPhone Web App: Spin the Bottle

Category: Mobile, iPhone

Tomi Mickelsson has created a fun iPhone Web App called Spin the Bottle. You know, a Web app, not one that has to get into the Apple store.

You can check it out on the iPhone/Touch/emulator and you will see how Tomi uses the iPhone specific APIs, such as:

JAVASCRIPT:
  1.  
  2. function startTouch() {
  3.     setTimeout(hideURLbar, 100);
  4.  
  5.     document.body.ontouchstart = function(e) {
  6.         oldangle1 = 0; oldangle2 = 0; oldangle3 = 0;
  7.         //spinout();
  8.         cancelspin();
  9.     }
  10.  
  11.     document.body.ontouchmove = function(e) {
  12.         // prevent window scrolling!
  13.         e.preventDefault();
  14.  
  15.         if (timer_rot != 0)
  16.             return;
  17.  
  18.         var touch = e.touches[0]; // finger 1
  19.         var dx = centerx - touch.pageX;
  20.         var dy = centery - touch.pageY;
  21.         var angle = Math.atan2(dy, dx);
  22.  
  23.         oldangle3 = angle;
  24.         oldangle1 = oldangle2;
  25.         oldangle2 = oldangle3;
  26.  
  27.         var val = "rotateZ(" + angle + "rad)";
  28.         bottle.style.webkitTransform = val;
  29.         shadow.style.webkitTransform = val;
  30.         rot = angle;
  31.         //cancelspin();
  32.     }
  33.     document.body.ontouchend = function(e){
  34.         if (timer_rot == 0) {
  35.             var val = ((oldangle2 - oldangle1) + (oldangle3 - oldangle2)) / 2;
  36.             val /= 3;
  37.             if (val == 0.0)
  38.                 val = rand(0.3)+0.2;
  39.             else if (Math.abs(val) <0.3)
  40.                 val *= 3;
  41.  
  42.             //cancelspin();
  43.             startanim(val);
  44.         }
  45.     }
  46. }
  47. // remove our touch handlers
  48. function stopTouch() {
  49.     document.body.ontouchstart = null;
  50.     document.body.ontouchmove = null;
  51.     document.body.ontouchend = null;
  52. }
  53.  

Posted by Dion Almaer at 8:24 am
3 Comments

++---
2.9 rating from 16 votes

Next Page »