Google Cloud Messaging using PHP

Google Cloud Messaging

Using PHP to send a message to a Google Cloud Messaging registered device is quite simple. In this example we'll be using curl to create a message request to send to the Google GCM server.

The code shown in this example is just going to demonstrate how to send a message to a registered device ID.
Continue reading Google Cloud Messaging using PHP

Google Cloud Messaging using C#

Google Cloud Messaging

Sending a notification to an Android device just keeps getting simpler and simpler. The current implementation of Google Cloud Messaging provides developers with a very simple way to send push notifications to a particular device.

What I'm going to show here is how to send a notification to a device once it's registered with your server.
Continue reading Google Cloud Messaging using C#

Native Extension Tip // Finding an Android Resource ID

Often when writing native extensions we've been faced with the problem of retrieving resources from the library. The official way to do this is to use the FREContext instance and the getResourceById() function. However there are several times when you'll want to access a resource packaged in your extension when the application has not been initialised (for example, onReceive events with a BroadcastReceiver), which initially seems impossible as you won't have access to your FREContext as yet.

There is however a simple workaround using the code below. You'll still need to be able to determine the package name of your application, which you can generally get from the Android Context.getPackageName().
Continue reading Native Extension Tip // Finding an Android Resource ID

Native Extension Tip // ld: unknown option

When packaging an iOS AIR application you may encounter the following error:

Error occurred while packaging the application:
ld: unknown option: -ios_version_min
Compilation failed while executing: ld64

As in the following screenshot:

This error simply indicates that the native extension you are attempting to package requires some features from the iOS SDK or a version greater than the one you are currently using. To remedy this, make sure you are using a recent version of the iOS SDK and correctly including it in your packaging options.

Native Extension Tip // ld: framework not found …

Continuing our series of help tips with using ANE's a very common error you'll come across is the one shown below, a linker error:

ld: framework not found ...
Compilation failed while executing : ld64

Continue reading Native Extension Tip // ld: framework not found …

Objective-C // List methods of a class

This simple Objective-C code excerpt prints the methods and arguments of a class instance using the NSLog functionality.

  1. //
  2. // List the methods of the class instance "myClass"
  3. methods = class_copyMethodList([myClass class], &methodCount);
  4. for (int i=0; i<methodCount; i++)
  5. {
  6. char buffer[256];
  7. SEL name = method_getName(methods[i]);
  8. NSLog(@"Method: %@", NSStringFromSelector(name));
  9. char *returnType = method_copyReturnType(methods[i]);
  10. NSLog(@"The return type is %s", returnType);
  11. free(returnType);
  12. // self, _cmd + any others
  13. unsigned int numberOfArguments = method_getNumberOfArguments(methods[i]);
  14. for(int j=0; j<numberOfArguments; j++)
  15. {
  16. method_getArgumentType(methods[i], j, buffer, 256);
  17. NSLog(@"The type of argument %d is %s", j, buffer);
  18. }
  19. }
  20. free(methods);

Objective-C // Runtime Method Injection

While building our Actionscript Native Extensions we've had to learn a lot about Objective C for the iOS versions. One trick that we'd like to share is how to inject a method into an instance of a class at runtime. This is necessary for several of the extensions we've done and it took me a while to figure out how to do this so I thought I'd share.

Quick Links:

Continue reading Objective-C // Runtime Method Injection

Launching Multiple Instances of Eclipse

I've been a fan of Eclipse for a long time now, even before FDT and Flash Builder were built around it. The use of workspaces, once you get your head around them, is powerful for focusing your head on the work at hand, keeping all associated projects within the one space.

However there are times when I wish I was able to have multiple workspaces open. And too the rescue comes the command line.
Continue reading Launching Multiple Instances of Eclipse

Native Extensions: A Simple Guide

We've been doing a lot with Native Extensions for AIR lately, both in Android and iOS, and I just wanted to put together a quick "how to" on using other people's Actionscript Native Extensions (ANE) in Flash Builder 4.6.

I'm going to assume you already understand the process of developing and deploying mobile applications using AIR.

The process is quite simple, you'll need the supplied ANE for the extension. In your mobile project you want to add it into, open up the project properties (Right click / Properties) and find the "Actionscript Build Path" (or "Flex Build Path" if it's a Flex project).

You'll see a tab up the top labeled "Native Extensions" in which you can "Add ANE...". Click on this and select the ANE extension file. Once it's added in, you can expand out the details of the extension to see the target platforms supported by the extension. Below I'm showing the details on our Android Camera Extension.

Continue reading Native Extensions: A Simple Guide