title: Parse receiving notifications on Android
body: <p>In my android app I'm getting this error when I try to receive push notification in logcat:</p>
  
  <blockquote>
    <p>6-22 14:38:16.016    6570-6570/com.tekinarslan.material.sample
    E/com.parse.ManifestInfo﹕ Cannot use GCM for push because the app
    manifest is missing some required declarations. Please make sure that
    these permissions are declared as children of the root 
    element:
        
        
        
        
        
        
        
        
        Also, please make sure that these services and broadcast receivers are declared as children of the  element:
        
        
        
        
        
        
        
         06-22 14:38:16.021    6570-6570/com.tekinarslan.material.sample E/com.parse.PushService﹕
    Tried to use push, but this app is not configured for push due to:
    Push is not configured for this app because the app manifest is
    missing required declarations. Please add the following declarations
    to your app manifest to support either GCM or PPNS for push (or both).
    To enable GCM support, please make sure that these permissions are
    declared as children of the root  element:
        
        
        
        
        
        
        
        
        Also, please make sure that these services and broadcast receivers are declared as children of the  element:
        
        
        
        
        
        
        
        
        To enable PPNS support, please make sure that these permissions are declared as children of the root  element:
        
        
        
        
        
        Also, please make sure that these services and broadcast receivers are declared as children of the  element:
        
        
        
        
        
        
        </p>
  </blockquote>
  
  <p>I think that I have all I need in my manifest, here it is:</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.tekinarslan.material.sample"
      android:versionCode="1"
      android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="9"/&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.MANAGE_DOCUMENTS" /&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&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.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;!-- Permissions required for parse.com notifications --&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.RECEIVE_BOOT_COMPLETED" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt;
      &lt;!-- END Parse permissions --&gt;
  
      &lt;!--
        IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
        to match your app's package name + ".permission.C2D_MESSAGE".
      --&gt;
      &lt;permission android:protectionLevel="signature"
          android:name="com.tekinarslan.material.sample.permission.C2D_MESSAGE" /&gt;
      &lt;uses-permission android:name="com.tekinarslan.material.sample.permission.C2D_MESSAGE" /&gt;
  
      &lt;application
          android:name=".App"
          android:allowBackup="true"
          android:label="DONUT"
          android:theme="@style/AppTheme" &gt;
          &lt;meta-data
              android:name="com.facebook.sdk.ApplicationId"
              android:value="@string/facebook_app_id"/&gt;
          &lt;activity
              android:name=".SampleActivity"
              android:label="@string/app_name" &gt;
  
          &lt;/activity&gt;
          &lt;activity
              android:name=".FbLoginActivity" &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;activity
              android:name="com.facebook.FacebookActivity"
              android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.Translucent.NoTitleBar"/&gt;
  
          &lt;!-- My custom receiver --&gt;
          &lt;receiver android:name=".ParseReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.tekinarslan.material.sample.RECEIVE_PUSH" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;!-- END my custom receiver --&gt;
  
  
          &lt;!-- Required for Parse.com notifications --&gt;
          &lt;service android:name="com.parse.PushService" /&gt;
  
          &lt;receiver android:name="com.parse.ParseBroadcastReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                  &lt;action android:name="android.intent.action.USER_PRESENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;!-- END Parse.com requirements --&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>**MY ParseReceiver - ** </p>
  
  <pre><code>package com.tekinarslan.material.sample;
  
  import java.util.Iterator;
  
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.Notification;
  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.support.v4.app.NotificationCompat;
  import android.util.Log;
  /*****************************
   * This class will receive custom push notifications
   * from parse.com. These are different than the "plain"
   * message push notifications. 
   * 
   * There must be an action defined within the Intent-Filter
   * for this receiver in the manifest.xml file. And the same
   * action must be specified on the notification when it is
   * pushed.
   * 
   * You can optionally pass JSON data from parse.com which will
   * be avaialable in the onReceive() method here.
   *****************************/
  public class ParseReceiver extends BroadcastReceiver {
      private final String TAG = "Parse Notification";
      private String msg = "";
      @Override
      public void onReceive(Context ctx, Intent intent) {
          Log.i(TAG, "PUSH RECEIVED!!!");
  
          try {
              String action = intent.getAction();
              String channel = intent.getExtras().getString("com.parse.Channel");
              JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
  
              Log.d(TAG, "got action " + action + " on channel " + channel + " with:");
              Iterator itr = json.keys();
              while (itr.hasNext()) {
                  String key = (String) itr.next();
                  Log.d(TAG, "..." + key + " =&gt; " + json.getString(key));
                  if(key.equals("string")){
                      msg = json.getString(key);
                  }
              }
          } catch (JSONException e) {
              Log.d(TAG, "JSONException: " + e.getMessage());
          }
  
  
          Bitmap icon = BitmapFactory.decodeResource(ctx.getResources(),
                  R.drawable.ic_launcher);
  
          Intent launchActivity = new Intent(ctx, SampleActivity.class);
          PendingIntent pi = PendingIntent.getActivity(ctx, 0, launchActivity, 0);
  
          Notification noti = new NotificationCompat.Builder(ctx)
          .setContentTitle("PUSH RECEIVED")
          .setContentText(msg)
          .setSmallIcon(R.drawable.ic_launcher)
          .setLargeIcon(icon)
          .setContentIntent(pi)
          .setAutoCancel(true)
          .build();
  
          NotificationManager nm = (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
          nm.notify(0, noti);
  
      }
  
  }
  </code></pre>