OneSignal / onesignal-php-api

The official OneSignal API client for PHP
Other
23 stars 10 forks source link

[Bug]: StringMap not found #18

Open daveHT opened 1 year ago

daveHT commented 1 year ago

What happened?

When I try to follow the tutorial for the basic set up I'm getting an internal error

include(StringMap.php): Failed to open stream: No such file or directory

Note that the code from the tutorial works totally fine (I am able to create the StringMap and dispatch the notification) as per the snippet below

function createNotification($enContent): Notification { $content = new StringMap(); $content->setEn($enContent); $notification = new Notification(); $notification->setAppId(APP_ID); $notification->setContents($content); $notification->setIncludedSegments(['Subscribed Users']); return $notification; }

The error is happening deep inside the OneSignal SDK code inside ObjectSerializer.php.
vendor/onesignal/onesignal-php-api/lib/ObjectSerializer.php(93): is_callable()

The call to is_callable() is failing (can't find StringMap).

Interestingly I have no problems including and creating my own StringMaps (along with other OneSignal types) so it's not a dependency issue that I can see. (I'm not ruling out an issue with my composer setup but all else seems to be working).

In ObjectSerializer.php there one line before the offending line there is long list of allowable types that it checks that skip the call to is_callable(). I added StringMap to that list, and everything works perfectly after that. Obviously this solution is a bit of a hack, but it's interesting that everything works after I do that small change (I can get notifications to show up on devices and there are no errors).

if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void', 'StringMap'], true)) { $callable = [$openAPIType, 'getAllowableEnumValues']; if (is_callable($callable)) { ......

I talked to support and they advised that they are forwarding to the dev team but also said that I should post here to understand what is happening and see whether this is a bug or issue with my setup.

Thanks!

Steps to reproduce?

1. follow tutorial for basic setup. 2 app crashes with error above

What did you expect to happen?

I expected there to be no error that it couldn't find StringMap.php

Relevant log output

No response

Code of Conduct

emawby commented 1 year ago

@daveHT Interesting issue thank you for reaching out. We will investigate!

daveHT commented 1 year ago

Any resolution on this? Every time I do a composer update my simple fix above gets overwritten so it would be nice to get this in (or addressed some other way)

tinora commented 8 months ago

@daveHT do you still experience this issue? For me it seems to work without your "hack". Regards Tino

LowKey1998 commented 2 months ago

@tinora @emawby where can i find the user key token and app key token