FCM push-Benachrichtigungs-Problem :- "error":"NotRegistered"

Bin ich immer seltsame Problem senden push-Benachrichtigung auf android mit FCM.

Ziel :- Mit Fehler beim senden der push-Benachrichtigung

Unten ist das Szenario, ich habe die Funktion für das senden von push-Benachrichtigungen an android -

 public static function SendMultipleNotificationAndroid($groups)
    {
        //your api key SERVER API KEY
        $apiKey = Yii::$app->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' => $deviceTokens,
                    'priority'     => 'high', 
                    'collapse_key' => $resG['notification_type'],   
                    'time_to_live' => 2419200,     
                    "click_action" =>"NotificationListingActivity",     
                    'data'         => [                  
                        "title"             => "ProjectName",
                        "body"              => $resG['message'],
                        "action_tag"        => $resG['notification_type'],
                        "message"           => $resG['message'],
                        'notification_type' => $type,
                        'notification_data' => $notification_data,
                        'sound'             => 'default',
                    ]
                );
                //Print result 
                p($ch,0);
                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
                curl_exec($ch);
            }            
        }
        curl_close($ch);
    }

Also das Problem ist, wenn ich senden Sie die Meldung auf es funktioniert gut, aber wenn ich senden mehrere notification bekam ich Fehler jedes mal

<pre>Resource id #5</pre>{"multicast_id":4818908994630396118,"success":1,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"message_id":"0:1487136045570022%c3bae3c6002e9358"}]}

<pre>Resource id #5</pre>{"multicast_id":5218359780835228544,"success":1,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"message_id":"0:1487136046618669%c3bae3c6002e9358"}]}

Als wir Debuggen Sie den code, den wir haben-device-token in unserer Datenbank keine firewall Stoppt das senden von push-Benachrichtigungen.

Jedes mal, wenn ich den Aufruf über die Funktion bekam ich

"error":"NotRegistered"

Jede mögliche Hilfe Würde geschätzt.

Vielen Dank im Voraus.

Schreibe einen Kommentar