8

मुझे एफसीएम का उपयोग करके एंड्रॉइड को पुश अधिसूचना भेजने का अजीब मुद्दा मिल रहा है।एफसीएम पुश अधिसूचना समस्या: - "त्रुटि": "नहीं पंजीकरण"

लक्ष्य: - जब पुश अधिसूचना

नीचे भेजने त्रुटि होने परिदृश्य मैं पुश अधिसूचना भेजने के लिए समारोह

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); 
    } 

Android के लिए है तो मुद्दा है जब मैं है एकल अधिसूचना भेजें यह ठीक काम करता है लेकिन जब मैं एकाधिक अधिसूचना भेजता हूं तो मुझे हर बार त्रुटि मिली है

<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"}]} 

जैसा कि हम कोड डीबग करते हैं, हमारे पास हमारे डेटाबेस में डिवाइस टोकन नहीं है फ़ायरवॉल जो पुश नोटिफिकेशन भेजना बंद कर देता है। "NotRegistered"

किसी भी मदद की सराहना की हैं:

हर बार जब मैं समारोह ऊपर फोन मैं

"त्रुटि" मिला है।

अग्रिम धन्यवाद।

उत्तर

5

php बारे में ज्यादा पता नहीं है, लेकिन हाल ही में मैं एक अन्य परियोजना में एक ही मुद्दा सामना करना पड़ा है और मैं इस तरह से समाधान किया:

refere यह पहली: Where can I find the API KEY for Firebase Cloud Messaging?

और के रूप में अद्यतन API कुंजी प्राप्त नीचे स्नैपशॉट enter image description here

+0

मामला हो सकता है कि मुझे इस मुद्दे को देखने दें और कोशिश करें! मैं शीघ्र तुम्हारे पास आऊंगा! धन्यवाद! –

+0

ब्रावो! काम कर रहे! –

+0

@maddy यह मेरे लिए काम नहीं किया। अनुरोध करते समय मैंने सर्वर कुंजी बदल दी है लेकिन फिर भी मुझे एक ही त्रुटि मिल रही है। – AIon

संबंधित मुद्दे