laravel-push-notification return html 响应正文中的标记

laravel-push-notification return html tag in response body

我正在使用 davibennun/laravel-push-notification 发送通知。 当我从我的 api 调用通知方法和 return $push->getFeedback(); 时,我在响应正文中得到 <html></html> 标记并且在我的设备上没有收到任何通知。
这是我的 api 方法:

public function sendnotif(Request $request)
{
    $push = PushNotification::app('appNameIOS')
                    ->to($request['deviceToken'])
                    ->send('Hello World, i`m a push message');
    return $push->getFeedback();
}

在离子 app.js 文件中:

    $rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
    if(ionic.Platform.isIOS()){
      console.log('ios');
      if (notification.alert) {
        navigator.notification.alert(notification.alert);
      }
      if (notification.sound) {
        var snd = new Media(event.sound);
        snd.play();
      }
      if (notification.badge) {
        $cordovaPush.setBadgeNumber(notification.badge).then(function(result) {
          console.log('badgeResult');
          console.log(result);
        }, function(err) {
          console.log('badgeResult');
          console.log(err);
        });
      }
    }
    else if(ionic.Platform.isAndroid()){
      console.log('android');
      switch(notification.event) {
        case 'registered':
          if (notification.regid.length > 0 ) {
            alert('registration ID = ' + notification.regid);
          }
          break;
        case 'message':
          // this is the actual push notification. its format depends on the data model from the push server
          alert('message = ' + notification.message + ' msgCount = ' + notification.msgcnt);
          break;
        case 'error':
          alert('GCM error = ' + notification.msg);
          break;
        default:
          alert('An unknown GCM event has occurred');
          break;
      }
    }
    else{
      console.log('can not detect device');
    }
  });

经过数小时的搜索,我终于找到了解决方案。 现在在我的 api I return 通知结果 getAdapter()->getResponse() 和这行代码:

    foreach ($push->pushManager as $push) {
        $response = $push->getAdapter()->getResponse();
    }
    return var_dump($response);

此代码 return 您的设备令牌数组无效,因此如果您的结果数组为空,则表示已发送所有通知。
同样在我的 ionic 应用程序上,我遇到了一些 js 错误。修复它们后,我在设备上成功收到通知。