title: Push Notifications when app is closed
body: <p>Do you know if is it possible to receive notifications from google cloud message when the application is fully closed? </p>
  
  <p>I know if it's open or in background yes, but can it be programmed any way in order to receive them? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I continue without receiving notifications when the app is closed. </p>
  
  <p>I attached the code in case I have an error and I am not watching it.</p>
  
  <p>MANIFEST</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.frab"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
  android:minSdkVersion="14"
  android:targetSdkVersion="19" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
  &lt;uses-permission android:name="com.frab.permission.C2D_MESSAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  &lt;permission
  android:name="com.frab.permission.C2D_MESSAGE"
  android:protectionLevel="signature" /&gt;
  
  &lt;meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" /&gt;
  
  &lt;application
  android:allowBackup="true"
  android:icon="@drawable/ic_launcher"
  android:label="@string/app_name"
  android:theme="@style/AppTheme" &gt;
  &lt;activity
  android:name="com.frab.MainActivity"
  android:label="@string/app_name" &gt;
  &lt;intent-filter&gt;
  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
  &lt;/intent-filter&gt;
  &lt;/activity&gt;
  
  &lt;receiver
  android:name=".GGMBroadcastReceiver"
  android:permission="com.google.android.c2dm.permission.SEND" &gt;
  &lt;intent-filter&gt;
  &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
  &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
  &lt;category android:name="com.something" /&gt;
  &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  
  &lt;service android:name=".GCMIntentService" /&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>BROADCAST RECEIVER</p>
  
  <pre><code>package com.something;
  
  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v4.app.NotificationCompat;
  import android.util.Log;
  
  import com.activities.SignIn;
  import com.google.android.gcm.GCMBaseIntentService;
  import com.objects.Globals;
  
  public class GCMIntentService extends GCMBaseIntentService {
  private static final String TAG = "GGM &lt;-----&gt; FRAB";
  private Bundle extras;
  
  public GCMIntentService() {
  super(Globals.SENDER_ID);
  }
  
  @Override
  public void onDestroy() {
  Log.d(TAG, "terminando servicio");
  }
  
  @Override
  protected void onRegistered(Context context, String registrationId) {
  Log.i(TAG, "onRegistered: registrationId=" + registrationId);
  }
  
  @Override
  protected void onUnregistered(Context context, String registrationId) {
  Log.i(TAG, "onUnregistered: registrationId = " + registrationId);
  }
  @Override
  protected void onMessage(Context context, Intent data) {
  extras = data.getExtras();
  String message = extras.getString("msg");
  Log.d("******", message);
  sendNotification(message);
  }
  
  @Override
  protected void onError(Context arg0, String errorId) {
  Log.e(TAG, "onError: errorId = " + errorId);
  }    
  }
  
  package com.something;
  
  import android.app.Activity;
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  import android.support.v4.content.WakefulBroadcastReceiver;
  
  public class GGMBroadcastReceiver extends WakefulBroadcastReceiver {
  
  @Override
  public void onReceive(Context context, Intent intent) {
  // Explicitly specify that GcmIntentService will handle the intent.
  ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
  // Start the service, keeping the device awake while it is launching.
  startWakefulService(context, (intent.setComponent(comp)));
  setResultCode(Activity.RESULT_OK);
  }
  }
  </code></pre>
  
  <p>When the app is open : <strong>OK</strong></p>
  
  <p>When the app is in background : <strong>Ok</strong></p>
  
  <p>When the app is closed forcefully by the user : <strong>notifications don't arrive</strong></p>
  
  <p>What is the problem?</p>
  
  <p>Thank you very much.</p>