Today we will talk about push notification in Codename One. Push notification is a pro only feature and its currently only supported on Android devices with Google Play, iOS devices and blackberries. This tutorial will be limited to iOS/Android though.
Lets start with Android, we need to go to the Google Cloud Console at https://cloud.google.com/console if you haven't yet created an API project you will need to click create. From your project you should take this long number here representing your project id. You will also need the long alpha numeric server key.
On the iOS side of the fence please check out the tutorial on creating a provisioning profile, notice that for push to work you can't use the * notation in the app id. When creating the provisioning profile you will need to enable push as an option and you will need to create a specific push certificate. You will then need to export it as a P12 certificate just like the standard Codename One certificate used for signing.
The P12 certificates for push must be hosted somewhere on the web so our push server will find them. You can use dropbox or some other service and provide us with the links when pushing.
Lets create a new class to implement push, in our main class we must implement the PushCallback interface which will allow us to receive push messages.
We should also register to receive push messages by invoking registerPush. Notice that here we need to include the numeric google key that we mentioned earlier.
There is a utility class to send a push message which is rather simple to use you just need to provide the values to the server. You can also invoke this as a webservice from your server, there are more details on that in the developer guide. The key values are the google server key, the iOS certificate URL, certificate password and whether the push is to production or sandbox environment.
Last but not least you now need to define ios.includePush=true notice that this will break your install if your provisioning profile isn't configured for push.
I hope you found this tutorial useful for getting started with push.
Versioning is a pro feature that allows you to build against a point release of Codename One Read More
Crash protection is another pro feature that allows you to get logs from the devices when an error occurs Read More
Desktop app build target is yet another pro only feature that allows you to build "native" desktop bundles Read More