Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ This plugin is for use with [Cordova](http://incubator.apache.org/cordova/), and

2) Modify your **AndroidManifest.xml** and add the following lines to your manifest tag:

<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down
1 change: 0 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down
22 changes: 4 additions & 18 deletions src/android/com/plugin/gcm/GCMIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ protected void onMessage(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null)
{
boolean foreground = this.isInForeground();
PushPlugin.sendExtras(extras);

extras.putBoolean("foreground", foreground);

if (foreground)
PushPlugin.sendExtras(extras);
else
// Send a notification if there is a message
if (extras.getString("message").length() != 0) {
createNotification(context, extras);
}
}
}

Expand Down Expand Up @@ -143,18 +141,6 @@ private static String getAppName(Context context)
return (String)appName;
}

public boolean isInForeground()
{
ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> services = activityManager
.getRunningTasks(Integer.MAX_VALUE);

if (services.get(0).topActivity.getPackageName().toString().equalsIgnoreCase(getApplicationContext().getPackageName().toString()))
return true;

return false;
}

@Override
public void onError(Context context, String errorId) {
Log.e(TAG, "onError - errorId: " + errorId);
Expand Down