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

Can't send notification to External User ID #166

Open
ibnuhalimm opened this issue Apr 15, 2022 · 2 comments
Open

Can't send notification to External User ID #166

ibnuhalimm opened this issue Apr 15, 2022 · 2 comments

Comments

@ibnuhalimm
Copy link

ibnuhalimm commented Apr 15, 2022

Laravel Version

6.20.44

PHP Version

7.3.27

Laravel-Onesignal Version

1.0.7

Description

I was implemented OneSignal::sendNotificationToExternalUser method to send notification for my users. But, then I'm getting an error like this

Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` response:
{"errors":["include_external_user_ids must be an array of non empty strings"]}
 {"exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 400): Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` response:
{\"errors\":[\"include_external_user_ids must be an array of non empty strings\"]}
 at /var/www/html/application/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)

I was looking for the root cause, then I realized that the problem is because of my $userId variable is an integer data type.
Then I cast my $userId variable as a string

OneSignal::sendNotificationToExternalUser("Notification message here", (string)$user->id);
@emmadedayo
Copy link

the error says "nclude_external_user_ids must be an array of non empty strings", can you paste the full code

@Ch-Kashif171
Copy link

Ch-Kashif171 commented May 17, 2023

You can set channel_for_external_user_ids as a param like this

OneSignal::sendNotificationToExternalUser(
    'message',
    '43'.  // external id
    'url',
    'data'
)

->setParameter('channel_for_external_user_ids', 'push')

then this function will work.

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

3 participants