推送通知未交付,但从Zend / php应用程序中的FCM获得成功响应

时间:2019-03-02 16:54:29

标签: php zend-framework push-notification firebase-cloud-messaging

设备令牌注册正常。 FCM网址:SERVER_URI ='https://fcm.googleapis.com/fcm/send'; 以下是我用来发送Android推送通知的代码。我也尝试使用php / curl代码,消息未发送但获得成功响应。已启用设备以允许通知

邮政编码:

if($apppush['android_api_key']){ // Firebase app key
            $appuser = $appUsersForPush[0];
            require_once 'Zend/Mobile/Push/Gcm.php';
            require_once 'Zend/Mobile/Push/Fcm.php';
            require_once 'Zend/Mobile/Push/Message/Gcm.php';
            $gcm = new Zend_Mobile_Push_Gcm ();
                      if($apppush ['is_fcm'] == 1)
                      {
                          $gcm = new Zend_Mobile_Push_Fcm ();
                      }

          $gcm->setApiKey ( $apppush ['android_api_key'] );
          $message = new Zend_Mobile_Push_Message_Gcm ();
          $message->setData ( array ('Author name' => $prefix, 'AppName' => $prefix, 'title' => $prefix, 'message' => $push_message ) );
          $message->addToken ($test_device_token  ); // Adding the device token 
          try {
              $response = $gcm->send ( $message ); // Sending the message
              $logger->log ( 'Android Cronjob Push User Device sent to : ' . $test_device_token, Zend_Log::INFO );
          } catch ( Zend_Mobile_Push_Exception $e ) {
              $logger->log('got exception while sending messge to Android device'.$e->getMessage(). "   ".$e->getTraceAsString(), Zend_Log::INFO);
              throw $e;

          } catch (Exception $e) {
              $logger->log('got exception while sending messge to Android device'.$e->getMessage(). "   ".$e->getTraceAsString(), Zend_Log::INFO);
              throw $e;
          }

          }

示例响应: (     [message_id] => 0:1551531511719150%00000000f9fd7ecd )

如果有任何想法,请分享。

0 个答案:

没有答案