Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging sendAll() does not return correct feedback when there's an errorneous request #15

Closed
bds-viktoras opened this issue Oct 21, 2019 · 3 comments

Comments

@bds-viktoras
Copy link

When using messaging component's sendAll() method to attempt sending multiple messages at once, if at least one of those messages bounces or there's an issue with FCM token, then the returned MulticastSendReport object is always empty.

In case there are no issues with any of sub-requests, the returned MulticastSendReport object contains all the feedback correctly.

@jeromegamez
Copy link
Member

The sendAll() method currently needs to return a MulticastSendReport because of backward compatibility reasons, so it might be that not everything is included there, but could you be more specific on what's missing exactly?

I just tried with the following and got what I expected

$factory = (new Factory())->withServiceAccount('/path/to/firebase_service_account.json');
$messaging = $factory->createMessaging();

$messages = [
    ['token' => $androidToken, 'notification' => ['title' => 'Android title']],
    ['token' => 'failure', 'notification' => ['title' => 'Failed title']],
    ['token' => $testToken, 'notification' => ['title' => 'Test title']],
];

try {
    $report = $messaging->sendAll($messages);
} catch (MessagingException $e) {
    echo $e->getMessage();
    exit;
}


print_r([
    'failures' => $report->failures()->count(),
    'successes' => $report->successes()->count(),
]);

foreach ($report->failures()->getItems() as $failure) {
    echo $failure->error()->getMessage().PHP_EOL;
}

⬇️

❯ php test.php
Array
(
    [failures] => 1
    [successes] => 2
)
The registration token is not a valid FCM registration token

@bds-viktoras
Copy link
Author

Running the exact same code as in your example returns an empty feedback list:

MulticastSendReport {#914
  -items: []
}

If the line with incorrect token is removed, then feedback array returns two items with their information.

In both cases two notifications are being delivered. so middle line failure does affect status reporting, but not the actual send process.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants