Commit 3cee78ab authored by Archana Naik's avatar Archana Naik
Browse files

Updated event names for the callback so existing sample code works with both...

Updated event names for the callback so existing sample code works with both android and amazon-fireos
parent 34b11b64
Loading
Loading
Loading
Loading
+6 −2
Changes for Example/www/index.html: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -36,8 +36,9 @@
				try 
				{ 
                	pushNotification = window.plugins.pushNotification;
                	if (device.platform == 'android' || device.platform == 'Android') {
						$("#app-status-ul").append('<li>registering android</li>');
                	if (device.platform == 'android' || device.platform == 'Android' ||
                            device.platform == 'amazon-fireos' ) {
						$("#app-status-ul").append('<li>registering ' + device.platform + '</li>');
                    	pushNotification.register(successHandler, errorHandler, {"senderID":"661780372179","ecb":"onNotificationGCM"});		// required!
					} else {
						$("#app-status-ul").append('<li>registering iOS</li>');
@@ -105,7 +106,10 @@
						}
							
						$("#app-status-ul").append('<li>MESSAGE -> MSG: ' + e.payload.message + '</li>');
                        //android only
						$("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.payload.msgcnt + '</li>');
                        //amazon-fireos only
                        $("#app-status-ul").append('<li>MESSAGE -> TIMESTAMP: ' + e.payload.timeStamp + '</li>');
                    break;
                    
                    case 'error':
+2 −2
Changes for src/amazon/ADMMessageHandler.java: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public class ADMMessageHandler extends ADMMessageHandlerBase {

        // we fire the register event in the web app, register handler should
        // fire to send the registration ID to your server via a header key/value pair over HTTP.(AJAX)
        PushPlugin.sendRegistrationIdWithEvent(PushPlugin.REGISTER,
        PushPlugin.sendRegistrationIdWithEvent(PushPlugin.REGISTER_EVENT,
            newRegistrationId);
    }

@@ -105,7 +105,7 @@ public class ADMMessageHandler extends ADMMessageHandlerBase {
    protected void onUnregistered(final String registrationId) {
        // If your app is unregistered on this device, inform your server that
        // this app instance is no longer a valid target for messages.
        PushPlugin.sendRegistrationIdWithEvent(PushPlugin.UNREGISTER,
        PushPlugin.sendRegistrationIdWithEvent(PushPlugin.UNREGISTER_EVENT,
            registrationId);
    }

+3 −1
Changes for src/amazon/PushPlugin.java: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ public class PushPlugin extends CordovaPlugin {
    
    public static final String REGISTER = "register";
    public static final String UNREGISTER = "unregister";
    public static final String REGISTER_EVENT = "registered";
    public static final String UNREGISTER_EVENT = "unregistered";
    public static final String MESSAGE = "message";
    public static final String ECB = "ecb";
    public static final String EVENT = "event";
@@ -185,7 +187,7 @@ public class PushPlugin extends CordovaPlugin {
                if (regId == null) {
                    adm.startRegister();
                } else {
                    sendRegistrationIdWithEvent(REGISTER, regId);
                    sendRegistrationIdWithEvent(REGISTER_EVENT, regId);
                }

                // see if there are any messages while app was in background and