Commit 08783e43 authored by Bob Easterday's avatar Bob Easterday
Browse files

Dismiss notification from tray once it has been processed

parent a412c1c7
Loading
Loading
Loading
Loading
+1 −3
Changes for src/android/com/google/android/gcm/GCMIntentService.java: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import com.plugin.GCM.PushPlugin;
public class GCMIntentService extends GCMBaseIntentService {

  public static final String ME="GCMReceiver";
  public static final int notificationID = 237;

  public GCMIntentService() {
    super("GCMIntentService");
@@ -120,8 +119,7 @@ public class GCMIntentService extends GCMBaseIntentService {
			mBuilder.setNumber(Integer.parseInt(msgcnt));
		}
		
		mNotificationManager.notify(notificationID, mBuilder.build());
	
		mNotificationManager.notify((String) appName, PushHandlerActivity.NOTIFICATION_ID, mBuilder.build());
		try
		{
			Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+14 −0
Changes for src/android/com/plugin/GCM/PushHandlerActivity.java: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,12 +15,16 @@ import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class PushHandlerActivity extends Activity
{
	public static final int NOTIFICATION_ID = 237;
	
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
@@ -41,6 +45,16 @@ public class PushHandlerActivity extends Activity
    			PushHandlerActivity.sendToApp(originalExtras);
        }
        finish();

		// Now that we've processed the notification, remove it from the tray
		CharSequence appName = this.getPackageManager().getApplicationLabel(this.getApplicationInfo());
		if (null == appName)
			appName = "";
        
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        // use a combo of appName and id to insure uniqueness since this plugin may be running
        // in multiple apps on a particular device.
        mNotificationManager.cancel((String) appName, NOTIFICATION_ID);
	}
    
    public static void sendToApp(Bundle extras)