laravel-onesignal icon indicating copy to clipboard operation
laravel-onesignal copied to clipboard

Send parameters on root level

Open bastienuh opened this issue 3 years ago • 0 comments

Hi,

How to add some parameters on root level, and not in data, buttons, etc. ?

The only way I found is to add one more parameter to sendNotificationToExternalUser, for example and then make an array_merge to have a $param variable with, for example, the following information :

array:6 [
  "app_id" => "a1cc617b-1f11-487d-84f2-07f8d35bd055"
  "contents" => array:1 [
    "en" => "HuffingtonPost – Un projet d'attentat néonazi contre une loge maçonnique déjoué"
  ]
  "include_external_user_ids" => array:4 [
    0 => "1"
    1 => "2"
    2 => "3"
    3 => "4"
  ]
  "web_url" => "https://www.my-link.com",
  "app_url" => "MY LINK",
  "ios_attachments" => "https://my-image-link.fr",
  "chrome_web_image" => "https://my-image-link.fr",
  "chrome_web_icon" => ""https://my-image-link.fr""
]

See web_url, chrome_web_image and chrome_web_icon, for example.

What do you think about adding a $body variable at the end of the method, like this :

public function sendNotificationToExternalUser($message, $userId, $url = null, $data = null, $buttons = null, $schedule = null, $headings = null, $subtitle = null, $body = null)

and, at the end of the functions, make this :

if(isset($body)){
    $params = array_merge($params, $body);
}

This way, the lib could become gorgeous and can give us a lot of possibilities.

Thanks for your feedbacks,

bastienuh avatar May 07 '21 19:05 bastienuh