Unable to create the messaging service without a project ID #554
-
I got this Error, when i wan't to send a CloudMessage: I think my project ID is in the firebase_credentials.json file, witch seems to be accessable. My code: use Kreait\Firebase\Factory; $factory = (new Factory)->withServiceAccount('../../firebase/firebase_credentials.json'); $factory = (new Factory()) $messaging = $factory->createMessaging(); $deviceToken = "12345"; $notification = [ $message = CloudMessage::withTarget('token', $deviceToken) $messaging->send($message); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Can you confirm that the JSON file has a |
Beta Was this translation helpful? Give feedback.
-
Now I see it! You are creating the factory twice! The first time you have a service account but no database url, the second time you have a database url but no service account. Since you overwrite the first one with the second one, that's the one you're using. $factory = (new Factory())
->withServiceAccount('...')
->withDatabaseUri('...'); will work 😅 |
Beta Was this translation helpful? Give feedback.
Now I see it! You are creating the factory twice! The first time you have a service account but no database url, the second time you have a database url but no service account. Since you overwrite the first one with the second one, that's the one you're using.
will work 😅