0

Я использую пакет https://github.com/davibennun/laravel-push-notification для моего push-уведомления в приложении laravel. Он работает на iOS, но на андроиде я столкнулся с этой проблемой. Заголовок и значок отсутствуют, когда я открываю панель уведомлений.Android push message message значок и заголовок, не отображающий

Помогите мне понять, почему название не отображается на 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) 

ответ

1

Просто понял, что я могу передать любую полезную нагрузку, необходимую. Таким образом, вы можете добавить название, субтитры, 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