ADF Mobile Push notifications demo on Apple iOS

After the webcast on ADF Mobile, delivered on the 29th of August 2013, I’m going to post the source code for the demos in the next few weeks. 

Starting with the "ADF Mobile Push notifications" demo on Apple iOS.

What do you need

1. JDeveloper with ADF Mobile extension

2. A Mac, Xcode and access to the Apple developer portal

3. Apple push notifications certificate and deployment profile

4. A physical iOS device, as push notification service does not work with the simulator

Documenting how to obtain Apple push notifications certificate is out of scope of this post, but if you search for “apple push notification services certificate” you should find some tutorials that describe the process.

Starting with the mobile application

  1. Create a new ADF Mobile application
  2. In application resources, open Descriptors->ADF META-INF -> adfmf-application.xml
  3. Match the id to your deployment profile application id
  4. While in adfmf-application.xml, you can also select LifeCycleListenerImpl as your application’s Lifecycle Event Listener.
  5. In ApplicationController project, open LifeCycleListenerImpl and implement PushNotificationConfig interface
  6. Add new Java class which implements EventListener interface
  7. Implement onOpen method as:
  8. ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{applicationScope.token}", String.class);
    ve.setValue(AdfmfJavaUtilities.getAdfELContext(), token);

    This will store device token, received from the APNS service into the application scope. In real life, we would send this token to our backend (server) app using a Web/REST service.

  9. Return to LifeCycleListenerImpl and implement start() method as:

                  EventSource eventSource=EventSourceFactory.getEventSource(


eventSource.addListener(new PushNotificationListener());

This will register the application for notifications and configure the listener.

8. The only thing left to do is implementing a feature with a simple amx page that displays the device token stored in #{applicationScope.token}". I’ll leave that part of the exercise to you.

Pushing notifications.

APNS protocol is a bit tricky to handle from scratch, but thankfully there is a java wrapper for it.

Using it implementing a swing application that sends notifications is a breeze. We only need a swing form with 2 input boxes and 2 buttons, potentially we could another one for device token(s).

Implementing the code behind the two buttons is straight forward:

private void jButton1_actionPerformed(ActionEvent e) {

try {

Push.badge(Integer.parseInt(jTextField1.getText()), "/Users/jernej/repo/devservice-ateam_adfmobilewebcast2/ApplePushNotificationTest/pushdemo.p12", "testing123", false,


} catch (KeystoreException ex) {

JOptionPane.showMessageDialog(null, ex.getMessage());

} catch (CommunicationException ex) {

JOptionPane.showMessageDialog(null, ex.getMessage());



private void jButton2_actionPerformed(ActionEvent e) {

try {

Push.alert(jTextField2.getText(), "/Users/jernej/repo/devservice-ateam_adfmobilewebcast2/ApplePushNotificationTest/pushdemo.p12", "testing123", false,


} catch (KeystoreException ex) {

JOptionPane.showMessageDialog(null, ex.getMessage());

} catch (CommunicationException ex) {

JOptionPane.showMessageDialog(null, ex.getMessage());



The only special thing here is the certificate .p12 file. You get this file through the APNS SSL certificate process. The second parameter (here “testing123”) is the certificate password.

You’ll need to change these two parameters to your file and password in order for the demo to work.

One last note

APNS infrastructure requires a bit liberal network restrictions on the device and on the server. If you are behind a firewall, it might be blocking your outgoing (from the swing application) or incoming (from APNS to the device) connection(s).

Getting the source code

To get the source code for this demo, you need to have git installed on your computer. Once it's up and running simply execute "git clone git://" statement from the command line / shell. 

You can see the demo in action here

Happy ADF Mobile coding! 

Stay Connected

Blog Facebook Google Plus YouTube
Twitter Delicious slideshare rss
Oracle Newsletters

Bookmark and Share


Thank You Jernej Kaše.

This is the most complete blog post on the Push Notification process. Your GitHUB link doesn't work for me? Can you provide more information on how I can get the complete code for the 2nd JAVA App please? This is part of the process which is too ambiguous for a newbee developer like me.

Working Hard to Figure this Out!

Posted by TreeStrepek on August 20, 2014 at 05:06 PM CEST #

2nd of 2: Here's the error I am getting.

MacBook-Pro-3$ git clone git://
Cloning into 'imc-demos~source'...
fatal: Unable to look up (port 9418) (nodename nor servname provided, or not known)

Posted by TreeStrepek on August 20, 2014 at 05:14 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed

Oracle ECEMEA Partner Hubs
Migration Center Team

We share our skills to maximize your revenue!
Adopt and implement the latest of Oracle Technology in your solutions.

Stay Connected
Google+ Subscribe


« July 2016