Android推送通知消息应用程序图标和标题未显示


Android push notification message app icon and title not showing

我正在使用https://github.com/davibennun/laravel-push-notification我在laravel应用程序上的推送通知包。它在iOS上工作,但在android上我遇到了这个问题。当我打开通知栏时,标题和图标不见了。

你能帮我弄清楚为什么这个标题没有在android上显示吗。谢谢

代码:

 $notification_message = PushNotification::Message( $message->message, array(
        'badge' => 1,
        'actionLocKey' => 'Read new message: '. $message->subject,
        'locKey' => $message->subject,
        'launchImage' =>  url($message->image)
    ));
foreach ($target_devices as $platform => $devices) {
        $collection = PushNotification::app($platform)
            ->to( PushNotification::DeviceCollection($devices) )
            ->send($notification_message);
        // get response for each device push
        foreach ($collection->pushManager as $push) {
            $response = $push->getAdapter()->getResponse();
          // dd($response);
        }
    }

日志:

object(ZendService'Google'Gcm'Response)[367]
  protected 'id' => int 5820913987510378862
  protected 'cntSuccess' => int 2
  protected 'cntFailure' => int 1
  protected 'cntCanonical' => int 1
  protected 'message' => 
    object(ZendService'Google'Gcm'Message)[357]
      protected 'registrationIds' => 
        array (size=3)
          0 => string 'xxxxx' (length=140)
          1 => string 'yyyyy' (length=152)
          2 => string 'zzzz' (length=140)
      protected 'collapseKey' => null
      protected 'data' => 
        array (size=4)
          'badge' => int 1
          'actionLocKey' => string 'Read new message: android test' (length=30)
          'locKey' => string 'android test' (length=12)
          'message' => string 'android testandroid testandroid testandroid test' (length=48)
      protected 'delayWhileIdle' => boolean false
      protected 'timeToLive' => int 600
      protected 'restrictedPackageName' => null
      protected 'dryRun' => boolean false
  protected 'results' => 
    array (size=3)
      0 => 
        array (size=1)
          'error' => string 'NotRegistered' (length=13)
      1 => 
        array (size=1)
          'message_id' => string '0:1452069848335048%e158bc73f9fd7ecd' (length=35)
      2 => 
        array (size=2)
          'registration_id' => string 'xxxxx' (length=152)
          'message_id' => string '0:1452069848336639%e158bc73f9fd7ecd' (length=35)
  protected 'response' => 
    array (size=5)
      'multicast_id' => int 5820913987510378862
      'success' => int 2
      'failure' => int 1
      'canonical_ids' => int 1
      'results' => 
        array (size=3)
          0 => 
            array (size=1)
              ...
          1 => 
            array (size=1)
              ...
          2 => 
            array (size=2)

刚刚意识到我可以传递任何需要的有效负载。所以你可以添加标题,字幕,tickerTitle为android。

$notification_message = PushNotification::Message( $message->message, array(
            'badge' => 1,
            'actionLocKey' => 'Read new message: '. $message->subject,
            'locKey' => $message->subject,
            'message'   => $message->message,
            'title'     => $message->subject,
            'subtitle'  => $message->message,
            'tickerText'    => 'Read new message: '. $message->subject,
            'largeIcon' => 'ionic',
            'smallIcon' => 'ionic',
            'launchImage' => 'ionic'
        ));

参考:https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md


推送通知的Android示例