Comments (17)
There are many factors in play that influence if a message on the client is actually displayed as a notification or not - while I don't immediately see an issue in the fields you're using (and the Firebase API is accepting it, so it's fine by itself), I also can't tell you what might cause the unwanted behavior.
My advice would be to try with the simplest possible message at first and then add the additional fields until it doesn't work as expected anymore.
If you're using an array, you pass it directly to Messaging::send()
(except, of course, there's a reason you're using RawMessageFromArray
instead of CloudMessage
)
$messaging->send([
'token' => $deviceToken,
'notification' => [
'title' => 'My title',
'body' => 'My body',
],
]);
One of the factors that might come into play: I'm testing FCM messages with Firefox on my computer. I receive messages as notification only if I'm on another tab - just having the browser minimized or hidden is not enough. I don't know what affects notifications on Android systems and when a message is delivered directly into the system tray or when an actual visual notification is triggered.
All in all, there's not much I can do from an SDK perspective, so I'm closing this issue - but feel free to continue the conversation or add your findings once you've figured it out to help others that might stumble upon this! 🙏
from laravel-firebase.
I guess i mispoke. Its working perfectly fine except its a silent notification. I want the heads up style. People say you need high priroty then they say you need sound. Its a mess. The they say omit the notification part. I was wondering if you own an android if you can send a sample message from kreit that confirm comes in as a heads up notification and not a silent notification. Otherwise i get them and your package is awesome. I was never faulting you.
from laravel-firebase.
Oh, I didn‘t think you did, but thank you so much for clearing this up anyway 🌺.
I unfortunately don‘t own an android device (and don‘t have an own application I could test this with), I only ever test with browser notifications 🙈.
What I do know is that a message definitely needs a notification with a title and a body to be displayed as a popular notification (I believe that’s what you mean with „heads up“ notification).
As I don‘t know for sure either, I can only ask questions as some kind of a „check list“ to clear possible issues - if you have already checked it, just ignore :)
- Is the phone in silent mode?
- Are notifications for your app fully enabled on your phone?
- Do notifications at least arrive in the system tray/notifications?
- Did you try with a very simple notification without „extra“ settings, as I suggested in my earlier comment?
- Have you tried uninstalling and reinstalling the application?
- Does the registration token you‘re sending to actually belong to the phone you expect it to arrive on?
I haven‘t more ideas at the moment, but if something comes to mind, I‘ll add it 🤞
from laravel-firebase.
Everything is tip top. All the answers to your questions is positive.
Not silent
Enabled
They arrive perfectly in all 3 situations running, bg, resume
Simple works but shows the same as silent notification
Yes reinstalled
Yes correct token. It fails if token is old or unregistered or fake
from laravel-firebase.
If you compose and send a notification from the Firebase Console (in the Browser), does it work as you would expect it?
from laravel-firebase.
that's my problem, i don't have a baseline as FCM console removed the priority option. People say to send the notification with priority in data portion but it does nothing. Where do we set priority in fcm in your sdk? can it be somewhere else than in the android section of the raw message?
from laravel-firebase.
also, how do i set thisin Kreit?
"webpush": {
"headers": {
"Urgency": "high"
}
}
from laravel-firebase.
Also i found this: https://developer.android.com/training/notify-user/build-notification#Priority
private fun createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val name = getString(R.string.channel_name)
val descriptionText = getString(R.string.channel_description)
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel(CHANNEL_ID, name, importance).apply {
description = descriptionText
}
// Register the channel with the system
val notificationManager: NotificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
How do i set this in kreit?
Thanks.
from laravel-firebase.
I don‘t know what the Android is all about, but from the backend we‘re limited/enabled to what the REST API supports, you can find the specification here:
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
If you find that the CloudMessage
doesn‘t support one of these, please let me know. However you should be able to use the full specification if you pass it to the RawMessageFromArray
class.
from laravel-firebase.
Ok will revert back. For enum types what do i type since it cannot detect the associated classes?
from laravel-firebase.
What do you mean by „revert“?
You can continue to use CloudMessage
or RawMessageFromArray
, but the message payload must match the specifications of the REST API.
As for the enums, you can use their values, I don‘t know how enums work with Java, but in the case of e.g. NotificationManager.IMPORTANCE_DEFAULT
, use either the string 'IMPORTANCE_DEFAULT'
, the value you find behind that enum or use the correspondent value in the docs.
from laravel-firebase.
I can't explain this, i am not using the most complete api rest call in the history of humanity and still nothing.
https://stackoverflow.com/questions/61166309/android-heads-up-firebase-notification-not-working
I have no idea why android is so backwards like this. It should be extremely simple but no dice.
from laravel-firebase.
I can't explain this, i am not using the most complete api rest call in the history of humanity and still nothing.
https://stackoverflow.com/questions/61166309/android-heads-up-firebase-notification-not-working
I have no idea why android is so backwards like this. It should be extremely simple but no dice.
Hey @nicolasvahidzein , on your SO post you left a comment saying you found the solution. Can you please post it here so others can benefit.
Thanks,
from laravel-firebase.
Ping me on skype please nzein19. Ill show you and you can paste it here to help everyone. My time is too limited.
from laravel-firebase.
Hey everyone,
I struggled with this issue for a long time - turns out the issue isn't truly related to kreait/laravel-firebase
.
The issue is documented pretty well here: https://developer.android.com/develop/ui/views/notifications#ManageChannels
TL;DR - newer versions of Android require you to declare a notification channel to use if you want to use heads-up notifications, as the default channel that gets set up isn't capable of things like heads-up notification, or vibrate, or flashing light.
Set up a channel in MainApplication.java, like the following comment outlines: invertase/react-native-firebase#2791 (comment)
From there, just make sure to push your Notification to that channel on Android:
new FcmMessage(
notification: [
'title' => $title
],
custom: [
'android' => [
'notification' => [
'title' => $title,
'channel_id' => 'YOUR_CHANNEL_NAME',
]
],
Thanks to @nicolasvahidzein to pairing with me on this
Hope it helps
from laravel-firebase.
Thanks to both of you enabling others who might stumble upon this, four years (!) later! 🙏🏻
from laravel-firebase.
This is what makes this community amazing.
from laravel-firebase.
Related Issues (20)
- Next release HOT 2
- No publishable resources for tag []. Publishing complete. HOT 5
- Callable functions
- SenderId mismatch HOT 7
- Laravel error HOT 2
- getting error HOT 1
- Incompatibility with Eloquent Resources? HOT 1
- Confirm email verification Support
- Its not supported php 8. Please fix this
- Push notifications are not getting displayed in IOS and Android randomly HOT 1
- Be able to override FirestoreClient::DEFAULT_DATABASE HOT 7
- Support PHP8.3 HOT 2
- Firestore insert or update problem when using laravel-octane HOT 3
- Auto discovery not working similar to v4.x HOT 5
- Cannot mock final class for phpunit tests as it's return type is other final class HOT 1
- Support symfony/cache version 7 HOT 3
- Make Support For Laravel 11 HOT 2
- Curl error on Laravel 11 HOT 9
- laravel publish issue HOT 1
- Unable to install kreait/laravel-firebase on Laravel 11 project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-firebase.