title: FCM push notification issue: "error":"NotRegistered"
body: <p>I am getting weird issue of sending push notification to Android using FCM.</p>
  <blockquote>
  <p><strong>Goal :- Having error while sending push notification</strong></p>
  </blockquote>
  <p>Below is the scenario I do have function for sending push notification to Android</p>
  <pre><code> public static function SendMultipleNotificationAndroid($groups)
      {
          //your api key SERVER API KEY
          $apiKey = Yii::$app-&gt;params['android_api_key'];
          $url = 'https://fcm.googleapis.com/fcm/send';    
          $headers = array(
              'Authorization:key=' . $apiKey,
              'Content-Type: application/json'
          );
          
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
          
          foreach($groups as $resG){
              $users  = $resG['users'];                        
              $msg    =   $resG['message'];
              $type    =   $resG['notification_type'];
              $notification_data    =   $resG['notification_data'];
  
              $deviceTokens = [];
              foreach($users as $resUser){
                  $deviceTokens[] = $resUser['device_token'];
                  //Add  Friend badge count +1
                  Common::AddRemoveBadgeCount($resUser['user_id']);
              }
              if(!empty($deviceTokens)){
                  $fields = array(
                      'registration_ids' =&gt; $deviceTokens,
                      'priority'     =&gt; 'high', 
                      'collapse_key' =&gt; $resG['notification_type'],   
                      'time_to_live' =&gt; 2419200,     
                      &quot;click_action&quot; =&gt;&quot;NotificationListingActivity&quot;,     
                      'data'         =&gt; [                  
                          &quot;title&quot;             =&gt; &quot;ProjectName&quot;,
                          &quot;body&quot;              =&gt; $resG['message'],
                          &quot;action_tag&quot;        =&gt; $resG['notification_type'],
                          &quot;message&quot;           =&gt; $resG['message'],
                          'notification_type' =&gt; $type,
                          'notification_data' =&gt; $notification_data,
                          'sound'             =&gt; 'default',
                      ]
                  );
                  //Print result 
                  p($ch,0);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
                  curl_exec($ch);
              }            
          }
          curl_close($ch);
      }
  </code></pre>
  <p>So the issue is when I send single notification it works fine but when I send multiple notification I got error every time</p>
  <pre><code>&lt;pre&gt;Resource id #5&lt;/pre&gt;{&quot;multicast_id&quot;:4818908994630396118,&quot;success&quot;:1,&quot;failure&quot;:1,&quot;canonical_ids&quot;:0,&quot;results&quot;:[{&quot;error&quot;:&quot;NotRegistered&quot;},{&quot;message_id&quot;:&quot;0:1487136045570022%c3bae3c6002e9358&quot;}]}
  
  &lt;pre&gt;Resource id #5&lt;/pre&gt;{&quot;multicast_id&quot;:5218359780835228544,&quot;success&quot;:1,&quot;failure&quot;:1,&quot;canonical_ids&quot;:0,&quot;results&quot;:[{&quot;error&quot;:&quot;NotRegistered&quot;},{&quot;message_id&quot;:&quot;0:1487136046618669%c3bae3c6002e9358&quot;}]}
  </code></pre>
  <p>As we debug the code we do have device token in our database no firewall which stops sending push notifications.</p>
  <p>Every time I call above function I get</p>
  <pre><code>&quot;error&quot;:&quot;NotRegistered&quot;
  </code></pre>