Commit 595e762e authored by Bob Easterday's avatar Bob Easterday
Browse files

Add cold-start functionality

parent 86bec0e7
Loading
Loading
Loading
Loading
+0 −2
Changes for Example/Sample_AndroidManifest.xml: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="5" android:versionName="1.1" android:windowSoftInputMode="adjustPan" package="com.adobe.pushtest" xmlns:android="http://schemas.android.com/apk/res/android"><supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /><uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.RECEIVE_SMS" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.RECORD_VIDEO" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><uses-permission android:name="android.permission.READ_CONTACTS" /><uses-permission android:name="android.permission.WRITE_CONTACTS" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.GET_ACCOUNTS" /><uses-permission android:name="android.permission.BROADCAST_STICKY" /><application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"><activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="pushtest" android:theme="@android:style/Theme.Black.NoTitleBar"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name="com.plugin.GCM.PushHandlerActivity" /><receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"><intent-filter><action android:name="com.google.android.c2dm.intent.RECEIVE" /><action android:name="com.google.android.c2dm.intent.REGISTRATION" /><category android:name="com.adobe.pushtest" /></intent-filter></receiver><service android:name="com.google.android.gcm.GCMIntentService" /></application><uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" /><uses-permission android:name="android.permission.GET_TASKS" /><uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /><permission android:name="com.adobe.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /><uses-permission android:name="com.adobe.pushtest.permission.C2D_MESSAGE" /><permission android:name="com.adobe.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /><uses-permission android:name="com.adobe.pushtest.permission.C2D_MESSAGE" /><permission android:name="com.adobe.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /><uses-permission android:name="com.adobe.pushtest.permission.C2D_MESSAGE" /></manifest>
 No newline at end of file

Example/Sample_config.xml

deleted100755 → 0
+0 −29
Changes for Example/Sample_config.xml: 0 added lines, 29 removed lines.
Original line number Diff line number Diff line
<?xml version='1.0' encoding='utf-8'?>
<cordova>
	<access origin="http://127.0.0.1*" />
	<access origin=".*" />
	<log level="DEBUG" />
	<preference name="useBrowserHistory" value="false" />
	<preference name="exit-on-suspend" value="false" />
	<plugins>
		<plugin name="App" value="org.apache.cordova.App" />
		<plugin name="Geolocation" value="org.apache.cordova.GeoBroker" />
		<plugin name="Device" value="org.apache.cordova.Device" />
		<plugin name="Accelerometer" value="org.apache.cordova.AccelListener" />
		<plugin name="Compass" value="org.apache.cordova.CompassListener" />
		<plugin name="Media" value="org.apache.cordova.AudioHandler" />
		<plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
		<plugin name="Contacts" value="org.apache.cordova.ContactManager" />
		<plugin name="File" value="org.apache.cordova.FileUtils" />
		<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
		<plugin name="Notification" value="org.apache.cordova.Notification" />
		<plugin name="Storage" value="org.apache.cordova.Storage" />
		<plugin name="Temperature" value="org.apache.cordova.TempListener" />
		<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer" />
		<plugin name="Capture" value="org.apache.cordova.Capture" />
		<plugin name="Battery" value="org.apache.cordova.BatteryListener" />
		<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen" />
		<plugin name="Echo" value="org.apache.cordova.Echo" />
		<plugin name="PushPlugin" value="com.plugin.GCM.PushPlugin" />
	</plugins>
</cordova>
 No newline at end of file
+48 −11
Changes for Example/www/PushNotification.js: 48 added lines, 11 removed lines.
Original line number Diff line number Diff line
(function(cordova) {
    var cordovaRef = window.PhoneGap || window.Cordova || window.cordova;

	function PushNotification() {}
var PushNotification = function() {
};


	// Call this to register for push notifications. Content of [options] depends on whether we are working with APNS (iOS) or GCM (Android)
	PushNotification.prototype.register = function(successCallback, errorCallback, options) {
		cordovaRef.exec(successCallback, errorCallback, "PushPlugin", "register", [options]);
    	if (errorCallback == null) { errorCallback = function() {}}

		if (typeof errorCallback != "function")  {
			console.log("PushNotification.register failure: failure parameter not a function");
			return;
		}

		if (typeof successCallback != "function") {
			console.log("PushNotification.register failure: success callback parameter must be a function");
			return;
		}

		cordova.exec(successCallback, errorCallback, "PushPlugin", "register", [options]);
	};

    // Call this to unregister for push notifications
    PushNotification.prototype.unregister = function(successCallback, errorCallback) {
        cordovaRef.exec(successCallback, errorCallback, "PushPlugin", "unregister", []);
		if (errorCallback == null) { errorCallback = function() {}}

		if (typeof errorCallback != "function")  {
			console.log("PushNotification.unregister failure: failure parameter not a function");
			return;
		}

		if (typeof successCallback != "function") {
			console.log("PushNotification.unregister failure: success callback parameter must be a function");
			return;
		}

		cordova.exec(successCallback, errorCallback, "PushPlugin", "unregister", []);
    };
 
 
    // Call this to set the application icon badge
    PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, badge) {
        cordovaRef.exec(successCallback, successCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]);
		if (errorCallback == null) { errorCallback = function() {}}

		if (typeof errorCallback != "function")  {
			console.log("PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function");
			return;
		}

		if (typeof successCallback != "function") {
			console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function");
			return;
		}

		cordova.exec(successCallback, successCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]);
    };

 cordova.addConstructor(function() {
		if(!window.plugins)
//-------------------------------------------------------------------

if(!window.plugins) {
	window.plugins = {};
}
if (!window.plugins.pushNotification) {
	window.plugins.pushNotification = new PushNotification();
	});

 })(window.cordova || window.Cordova || window.PhoneGap);
}
+14 −20
Changes for Example/www/index.html: 14 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -22,8 +22,9 @@
  					
      				if( $("#home").length > 0)
					{
						// call this to get a new token each time. don't call it to reuse existing token.
						//pushNotification.unregister(successHandler, errorHandler);
						e.preventDefault();
						pushNotification.unregister(successHandler, errorHandler);
						navigator.app.exitApp();
					}
					else
@@ -37,10 +38,10 @@
                	pushNotification = window.plugins.pushNotification;
                	if (device.platform == 'android' || device.platform == 'Android') {
						$("#app-status-ul").append('<li>registering android</li>');
                    	pushNotification.register(successHandler, errorHandler, {"senderID":"661780372179","ecb":"onNotificationGCM"});
                    	pushNotification.register(successHandler, errorHandler, {"senderID":"661780372179","ecb":"onNotificationGCM"});		// required!
					} else {
						$("#app-status-ul").append('<li>registering iOS</li>');
                    	pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"});
                    	pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"});	// required!
                	}
                }
				catch(err) 
@@ -53,25 +54,14 @@
            
            // handle APNS notifications for iOS
            function onNotificationAPN(e) {
               if (e.foreground) {
                    $("#app-status-ul").append('<li>--INLINE NOTIFICATION--' + '</li>');
                    
                    if (e.sound) {
                        var snd = new Media(e.sound);
                        snd.play();
                    }
                    
                if (e.alert) {
                     $("#app-status-ul").append('<li>push-notification: ' + e.alert + '</li>');
                     navigator.notification.alert(e.alert);
                }
                }
                else {
                    $("#app-status-ul").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');
                    
                    if (e.alert) {
                        $("#app-status-ul").append('<li>push-notification: ' + e.alert + '</li>');
                    }
                if (e.sound) {
                    var snd = new Media(e.sound);
                    snd.play();
                }
                
                if (e.badge) {
@@ -89,9 +79,9 @@
					if ( e.regid.length > 0 )
					{
						$("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>");
						console.log("regID = " + e.regID);
						// Your GCM push server needs to know the regID before it can push to this device
						// here is where you might want to send it the regID for later use.
						console.log("regID = " + e.regID);
					}
                    break;
                    
@@ -106,8 +96,13 @@
							var my_media = new Media("/android_asset/www/"+e.soundname);
							my_media.play();
						}
						else	// otherwise we were launched because the user touched a notification in the notification tray.
						else
						{	// otherwise we were launched because the user touched a notification in the notification tray.
							if (e.coldstart)
								$("#app-status-ul").append('<li>--COLDSTART NOTIFICATION--' + '</li>');
							else
							$("#app-status-ul").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');
						}
							
						$("#app-status-ul").append('<li>MESSAGE -> MSG: ' + e.payload.message + '</li>');
						$("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.payload.msgcnt + '</li>');
@@ -125,7 +120,6 @@
            
            function tokenHandler (result) {
                $("#app-status-ul").append('<li>token: '+ result +'</li>');
                console.log("token = " + result);
                // Your iOS push server needs to know the token before it can push to this device
                // here is where you might want to send it the token for later use.
            }
+1 −1
Changes for plugin.xml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="com.adobe.plugins.PushPlugin"
    version="1.1.3">
    version="1.2.0">

    <name>PushPlugin</name>

Loading