Social plugin for Phonegap 2.6 and up

In my search to have the iOS 6 default social sharing plugin, I landed up at this page. While everything seems right for this plugin, I somehow faced some problems in the UX. Thought would look a little deeper into it and found that this plugin relies upon the old plugin architecture of Phonegap. It still works, but then if it does not, you know know why.
Now to implement social sharing in my project, I have done a quick round of update to the plugin. Its working in my phonegap version 2.6. And that should work on Phonegap 3 as well, as the new plugin implementation has not changed after version 2.0.
Here is the github link for the new plugin.
While currently this plugin only shares the link and the message, you have to send a third parameter as an empty string for the image parameter. I will do the code cleanup and fix as I get some time to look into it. For the time being, its ready to use in new Phonegap versions.

Happy coding :)

Phonegap ( cordova ) and iOS longtap

This is perhaps the most significant effect of using a webview for iOS development. When working with Phonegap(cordova) which uses WebView, the user gets a longtap event as it use to on a web browser. All sort of long tap menus will come up in an application using Phonegap (ex : select, copy etc).
To suppress these unwanted menus on a native application, which uses Phonegap(Cordova), there are a number of options found throughout the internet, but the one which worked for me is a style declaration as below.

/* Disabling the default iOS bevaviour of copy-paste on long tap */
*:not(input):not(textarea) {
	-webkit-user-select: none; /* disable selection/Copy of UIWebView */
    -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */

}

Happy coding :)

Settings Check for Apple Push Notification

While developing an iOS application with Push Notification, there might be a time, one comes across the following error message.

- no valid 'aps-environment' entitlement string found for application

Well, that means the APN (Apple Push Notification) server is denying to register your application. This situation arises when the signing certificate for the application differs from the one you generated for Push Notification.

The fix is to select the proper certificate in the settings for the project.
codeSigningCert

Happy coding.

iOS notifications from developer's view

Notifications in iOS devices such as iPhone and iPad are a way to tell the user about some important thing has happened. From a users perspective it is just a message reminding thing.
For a developer, one must note the difference between the type of notifications. Well, to be at its simplest form, there re two kinds of notifications. One is local notification and one is push notification (think this as server is telling the iOS device to show the notification).
Well, why should I bother about these two as a developer ?! That might be the question if you are doing the notification programming in iOS for the first time. The answer is, iOS gives very certain instructions as to what and how to do the notification implementation.
Here is the official link to the Apple documentation.

There are only three types of UX for either of the notification (local or push). They are
1. Displaying an alert message
2. Badge the application icon
3. Play a sound

The settings to control these notification types are located in the global settings menu of iOS. Remember it, the settings of all the applications, which use notifications are at one place in all iOS devices and that is the “settings” menu.
Well, another subtle but important option is “notification center”. Its the place, where all the notifications from all the applications reside. The settings, whether to keep the “notification” in “notification center” or not is also inside the global “settings” menu. Being a developer, the good thing about Apple and for that matter the iOS is, one does not code for adding settings item for notifications. It is done automatically for you by the OS (Operating System). All this magic happens, when you as a developer, makes a “certificate” for the application in Apple developer’s portal for the application saying “this application used notification”. Simple and elegant.

The major difference from developer’s point, between local notification and push notification is local notification is scheduled. That means, we can not show a notification if certain things happen in the application. Once application goes to background, we lost power as a developer to do anything at all with that application. So local notifications can only be scheduled for a normal application (for music streaming applications we do get a little more control). If at all we have to notify the user on certain data change, we have to fall back to push notifications. This one is pushed by Apple Push Notification server. Though, there are third party services which can push data, but all of the data push to an users device route through Apple Push Notification server.
The last thing to note is Push notifications are created on the server and pushed to the device, at max, upon tapping the notification, the underlying application can be brought to foreground and thats all one can do as a developer.

Tips for phonegap developers :
1. There are two different official plugins (one for local and one push notification), but then these plugins are not always up to date or might not support your version of the phonegap(cordova), do some reading before you settle down with the plugins.
2. The third party service providers (for push notification) might have their own plugins (a lot of do have), its better to use their plugins if you are developing upon their infrastructure.

Tip for push notification :
Make sure you are creating proper certificate with “push notification service” enabled at “Apple developer portal” and then using a profile on XCode which uses that certificate.

Some push notification servers are
1. http://www.pushwoosh.com
2. http://www.xtify.com
3. https://pushwizard.com

Would like to know if anything I am missing here, I am putting things here as I am doing hands-on with this iOS “notifications” for the first time.

haXe : doing a regular update and NME

This came to me as a surprise while trying to write a script, which can run in iOS, HTML5, Flash and Neko. I knew it can be done by cross-compiling through NME to all these target platforms. While this hold good almost in every case but when it comes to regular stage update or the ENTER_FRAME event, it is a problem.
Well, if you are a flash developer and depend on ENTER_FRAME event for a long time, then it may come to you as a surprise like me. The game loop as the gaming engines call it, now has to be worked upon. Fortunately we have a timer function in haXe and that quite fits the game.
Before going ahead in timer, lets see the unreliable nature of ENTER_FRAME for all targets. Firstly I was creating different circles in stage area with an ENTER_FRAME, while that worked well in all platforms, I thought its good to go for all. But then I tried to rely upon the same ENTER_FRAME event with a drag and drop and position change of the elements. Whoa!! That does not work! I stopped relying on the ENTER_FRAME event and changed that with Timer and everything is back in the action again.
The haXe timer code is a little different than Flash timer and the code looks as below.

var timer = new Timer(10); //10 is the time difference in milliseconds between the timer call
timer.run = onEachTimerTick;//its kind of event listener
function onEachTimerTick():Void {}

For me, ENTER_FRAME event only worked for Flash targets and nothing else. So be careful if you want to target other delivery methods.

Happy coding!

some cool haXe IDE

Well developing in a language without a specific IDE for itself might be too much for a beginner. Fortunately we have some very cool and nice IDEs available for us.
1. FlashDevelop (Based on SciTE)
2. FDT5 (Based on Eclipse)

While both these IDEs are free, FlashDevelop is windows only. But I am surely in love with FlashDevelop. FDT is good but being on Eclipse, it takes up a lot of memory, on the other hand FDT runs on all platforms. So choose your weapons and get ready to haXe it all.

haXe basics

The bare bone basic of haXe language is one must need an Entry point to the Application. This could be any class, but then one must specify the entry point function, which is “main()” , the signature of function looks like

public static function main() {}

Constructors in HAXE are written as “new()” as below

class GameStage
{
 public function new(){}
}

the package declaration ends with a semicolon (unlike any other major laguages, it does not contain curly braces)

package com.saumya.haxe.helloWorld;
class GameStage
{
	public function new() {}
}

If you are extending an display object, then “super” must be called from the constructor. It snot optional, its mandatory.
Every line of code must end with “;” semicolon, again this is mandatory not optional.
Every class file is saved with “.hx” extension.
The haxe compiler file is saved with “.hxml” extension.
The NME compiler file is saved as “.nmml” extension.
A typical “.hxml: file looks as

-swf bin/swf/inTheBigBrain_as3_FP10.swf
-main Main
-swf-header 800:600:30:000000
-cp src

Similarly to compile from NME, you have to create a “.nmml” file.
A typical “.nmml” file description is here.

for compiling a .hxml file, you fire up the following command,

haxe test.hxml

Have a look at the detailed options.

To compile a nmml file, you have to fire up one of these commands. But the very basic is

haxelib run nme test my.nmml flash

The detailed options are here.

Hope that gives you the very basics of the language.

haXe

What is it all about ? Well its all about another language. Not really, if you know ECMA script like javascript or actionscript, haXe is just another home. It does not hurt to learn the simplicity of the language. That does not mean, its not capable! The capability of this language is, it compiles to a lot of platforms! Are you serious?! Yeah, you heard it right. It compiles to almost all the platforms we have now. Starting from AVM1 and AVM2 swfs to native windows, mac, linux applications.
The simplicity of a scripting language and the robustness of C, the best of both worlds! Awesome. For a quick overview of all the platforms, head over to the official page here.
Now haXe comes with a lot of libraries on top of the basic language, which makes it even interesting. And one of the such libraries is NME. After working in NME for a week, I am not kind of addicted to it. It simply allows the code to be compiled to HTML5 and iDevices like iPhone/iPad. The complete list of supported devices are listed here in the official page.
Hope that should already have been making you interested in haXe.

If you still need to see some hands on coding and examples, join me this sunday, where I am doing a workshop on haXe and NME for flash developers.
Happy haXe -ing.