Account created on 18 July 2018, over 6 years ago
#

Recent comments

Hi Ana Bozhilova,

thanks for your response. Installing "google/cloud-firestore" and applying your latest patch worked for me.
The push messages are sent without any errors.

Hi everyone,
I have installed the latest patch (#32) and updated the new configuration page accordingly.
I've uploaded a .json file which I was given from the Firebase, but it's not working.

Here is the structure of the .json file I received:

type
project_id
private_key_id
private_key
client_email
client_id
auth_uri
token_uri
auth_provider_x509_cert_url
client_x509_cert_url
universe_domain

For the "Project ID" field in the "Firebase Push Notification Configuration" page, I've used the "project_id" from the .json file.
For "Credentials" field, I have uploaded the provided .json file.

The old code is:

function _eutb_firebase_push_message($topic, $val) {
  /** @var FirebaseMessageService $messageService */
  $messageService = \Drupal::service('firebase.message');
  $messageService->setTopics($topic);

  // Notification
  $notification = new Notification($val['title']);
  $notification->setBody($val['body']);

  // Message data
  $messageData = MessageData::fromArray([
    'type' => 'axp-content',
    'url'  => $val['url'],
  ]);

  // Message
  $message = new Message($notification);
  $message->setData($messageData);
  $messageService->setMessage($message);

  // Android config
  $android_config = new AndroidConfig();
  $android_config->setPriority('normal');
  $message->setAndroidConfig($android_config);

  // Apple config
  $apns_config = new ApnsConfig();
  $apns_config->setHeaders(['apns-priority' => '5']);
  $apns_config->setPayload([
    'aps' => [
      'mutable-content' => 1,
      'content-available' => 1
    ]
  ]);
  $message->setApnsConfig($apns_config);

  try {
    $messageService->sendToTopic();
    }
  } catch (Exception $e) {
    $error = 'Push-Message failed: ' . $val['title'] . ' - ' . $val['body'] . ' URL: ' . $val['url'] . ' Error: ' . $e->getMessage();
  }
}

The new code is:

/** @var FirebaseMessageService $messageService */
  $messageService = \Drupal::service('firebase.message');
  $messageService->setTopics($topic);

  // Notification
  $notification = new Notification($val['title']);
  $notification->setBody($val['body']);

  // Message data
  $messageData = MessageData::fromArray([
    'type' => 'axp-content',
    'url'  => $val['url'],
  ]);

  // Message
  $message = new Message($notification);
  $message->setData($messageData);
  $messageService->setMessage($message);

  // Android config
  $android_config = new AndroidConfig();
  $android_config->setPriority('normal');
  $message->setAndroidConfig($android_config);

  // Apple config
  $apns_config = new ApnsConfig();
  $apns_config->setHeaders(['apns-priority' => '5']);
  $apns_config->setPayload([
    'aps' => [
      'mutable-content' => 1,
      'content-available' => 1
    ]
  ]);
  $message->setApnsConfig($apns_config);

  try {
    $messageService->sendToTopic();
  
  } catch (Exception $e) {
    $error = 'Push-Message failed: ' . $val['title'] . ' - ' . $val['body'] . ' URL: ' . $val['url'] . ' Error: ' . $e->getMessage();
  }

After I try to send a push message, I get this error:
Error: Class "Google\Auth\ApplicationDefaultCredentials" not found in Drupal\firebase\Service\FirebaseServiceBase->getHandler()

I saw that mieg (#8) reported the same issue, but this dependancy is already integrated in the latest patch and I have it locally and on my DEV system, but it still complains about it.
Does anyone can help with ideas what might be wrong?

I also tried the example from Tri Tran (#29) with the $messageService->sendToTokens();, but then I have another error: Error: The message should contain target.

Any ideas/thoughts would be highly appreciated!

Regards,
Daniela

Hello, I'm uploading a patch for this issue for version "drupal/endroid_qr_code": "4.0.x-dev@dev", where the problem is still there.

I'm using the DEV version, because the latest 4.0 version is throwing the following error: ValueError: Path cannot be empty in file_get_contents() (Line 24 in /var/www/html/project/vendor/endroid/qr-code/src/ImageData/LogoImageData.php).

Actually this patch is not working with version 3.4
I manually made the changes on my local file and I thought that the patch is going to work, but in this version the modified line is a little bit bellow and the patch is failing.

Anyway, I made a new patch which is working with the 3.4 version.

Thanks for the patch, @yojohnyo!
I had the same error and this patch fixed it.

Production build 0.71.5 2024