Commit 585a84c6 authored by Bob Easterday's avatar Bob Easterday
Browse files

Merge pull request #69 from rubennorte/master

Fixes Cordova error when trying to open the app from the notification bar
parents d2680f1f 82606aca
Loading
Loading
Loading
Loading
+2 −16
Changes for src/android/com/plugin/gcm/GCMIntentService.java: 2 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -9,13 +9,11 @@ import org.json.JSONObject;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@@ -93,6 +91,7 @@ public class GCMIntentService extends GCMBaseIntentService {
		
		NotificationCompat.Builder mBuilder =
			new NotificationCompat.Builder(context)
				.setDefaults(Notification.DEFAULT_ALL)
				.setSmallIcon(context.getApplicationInfo().icon)
				.setWhen(System.currentTimeMillis())
				.setContentTitle(appName)
@@ -112,19 +111,6 @@ public class GCMIntentService extends GCMBaseIntentService {
		}
		
		mNotificationManager.notify((String) appName, NOTIFICATION_ID, mBuilder.build());
		tryPlayRingtone();
	}

	private void tryPlayRingtone() 
	{
		try {
			Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
			Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
			r.play();
		} 
		catch (Exception e) {
			Log.e(TAG, "failed to play notification ringtone");
		}
	}
	
	public static void cancelNotification(Context context)
+4 −3
Changes for src/android/com/plugin/gcm/PushHandlerActivity.java: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -23,14 +23,15 @@ public class PushHandlerActivity extends Activity
		Log.v(TAG, "onCreate");

		boolean isPushPluginActive = PushPlugin.isActive();
		if (!isPushPluginActive) {
			forceMainActivityReload();
		}
		processPushBundle(isPushPluginActive);

		GCMIntentService.cancelNotification(this);

		finish();

		if (!isPushPluginActive) {
			forceMainActivityReload();
		}
	}

	/**