This document discusses how to implement push notifications in an ADF Mobile application. It covers setting up push notification services on both Android and iOS, creating a provider application to send notifications, and using listeners in the ADF Mobile application to handle receiving notifications and passing data to features. The key aspects are registering for push notifications, handling the notification payload in onMessage(), and activating features with the payload data. Configuration involves setting up cloud services and integrating multiple listener classes to route notifications throughout the application.
7. Push Notifications
• Subscribe to Messaging Service
• Receive token
• Register with Enterprise app
• Enterprise app Pushes message
to Messaging Service
• Messaging Service delegates
message to device(s)
9. Setup GCM
• Google Cloud Project
• Google Cloud Messaging API is
enabled
• API key
10. Setup APNS
• iOS Developer account
• App Id and Provisioning profile
– Make sure to check the Push Notification Service when you create the new App Id
• SSL Certificate
13. Code Behind the Button
• Class to push a message to a device.
public void pushNow(ActionEvent actionEvent) {
….. Logic to get selected row…
String target = (String)curr.getAttribute("DeviceToken");
String type = (String)curr.getAttribute("DeviceType");
if (type.equalsIgnoreCase("Android")) {
pushMsgAmdroid(target, this.message);
} else {
pushMsgIos(target, this.message);
}
14. Server Side for Android
• Sending the message
String sound = "default";
Message message =
new Message.Builder()
.delayWhileIdle(true)
.addData("alert", msg)
.addData("sound",sound)
.addData("FeatureName", "Sessions")
.addData("SessionId", "12")
.build();
Result result;
try {
result = sender.sendNoRetry(message, regId);
}
15. Server Side for iOS
• Sending the message
/* Build a blank payload to customize */
PushNotificationPayload payload = PushNotificationPayload.complex();
/* Custom the payload */
payload.addAlert(msg);
payload.addBadge(1);
payload.addCustomDictionary("FeatureName", "Sessions");
payload.addCustomDictionary("SessionId", "12");
Push.payload(payload, KEYSTORE_LOCATION, KEYSTORE_PASSWORD, false,
target);
16. Preparing ADF Mobile
• Register Application Life Cycle Listener
• LifeCycleListener must implement
oracle.adfmf.application.PushNotificationConfig interface.
– This interface provides the registration configuration for push notifications
17. ApplicationLifeCycleListener
• ApplicationLifeCycleListener
– In the Start() Method create a new PushNotificationListener()
public void start() {
// Add code here...
EventSource evtSource =
EventSourceFactory.getEventSource(
NativePushNotificationEventSource.
NATIVE_PUSH_NOTIFICATION_REMOTE_EVENT_SOURCE_NAME);
evtSource.addListener(new PushNotificationListener());
}
18. The PushNotificationListener
• In the PushNotificationListener
– OnOpen() // receive token
– OnMessage() // handle notification
– OnError()
public void onOpen(String token) {
// Invoked during the Push Notification registration process.
// The parameter "token" contains the token received from APNs or GCMs
// that uniquely identifies a specific device-application combination.
ValueExpression ve = AdfmfJavaUtilities.getValueExpression(
"#{applicationScope.deviceToken}", String.class);
if (token != null){
ve.setValue(AdfmfJavaUtilities.getAdfELContext(), token);
}
else{
ve.setValue(AdfmfJavaUtilities.getAdfELContext(), "dummy Token");
}
}
19. Token Registration
• Use a webservice to send the Token to the provider Application
• Provider stores token and uses it when sending notifications (remember
the “code behind the button”
public void pushNow(ActionEvent actionEvent) {
….. Logic to get selected row…
String target = (String)curr.getAttribute("DeviceToken");
String type = (String)curr.getAttribute("DeviceType");
if (type.equalsIgnoreCase("Android")) {
pushMsgAmdroid(target, this.message);
} else {
pushMsgIos(target, this.message);
}
20. All is there.
• Cloud Services are setup
• Provider app is created
• Device Token can be sent to and stored at provider app
• LETS PUSH ! And work with the notification