I am rewriting an app from Xamarin to Flutter, I have been struggling with push notification for some time now.
I followed this guide: https://learn.microsoft.com/en-us/azure/developer/mobile-apps/notification-hubs-backend-service-flutter
I have implemented everything for Android and the cross platform code. Not yet started with IOS. The backend and notification hub is up and running for the Xamarin project, which I know is working.
When I register the device I get a 200 and it seems to be working. When I run a test push in Notification hub I get this:
Image of error code in Notification hub
When I try to send one more push I get nothing until I deregister and register again and I will get the error again.
When registering I use push channel, deviceId, platform, and a tag.
I have added the google-services.json file in the app folder of the android project.
Suggest you to check if the notification hub is configured correctly and tags or tag expressions are used correctly. Also, registration needs to be re-register everytime your app start-up.
You may refer to this article for troubleshoot: Diagnose dropped notifications in Azure Notification Hubs
I have developed a chat app using Xamarin, and the app receives push notification when a new chat arrives. The push notifications are delivered through OneSignal platform which uses Firebase for Android and APNS for iOS.
I would like to unsubscribe for push notification from the device itself when a user logouts, so that even if the server sends one, it wont be displayed. I can achieve this in iOS with the following code.
UIApplication.SharedApplication.UnregisterForRemoteNotifications();
What would be the equivalent for this in Android. I have searched a lot in documentation but no luck. Appreciate some help. Even it someone can tell the code in Java or Kotlin, that would do.
In Android you must delete that instance Id to avoid receiving push notifications but also disable auto init so that it doesn't generate a new token registration:
FirebaseMessaging.Instance.AutoInitEnabled = false;
FirebaseInstanceId.Instance.DeleteInstanceId();
So I just set up a Firebase function to send notifications to my devices and I added react-native-firebase to my project so I signin, get a token and receive notifications.
The notification is getting received by the device, but I dont know how to show it in the UI. I wanted to show that box with a message with some text and eventually an icon.
What library should I use now? I tried to install react-native-push-notifications to use the local notification feature. But there seems to be a conflict with versions of Google Services both libraries use
What should i do?
i am not receiving notification after sending it through firebase console , i tried sending many notification but received one or two from around 20 notifications, i followed this guide firebase messaging from github
,why am i not receiving notification, my app is installed in one emulator and in one of my phone but when i receive notification which i have sent through notification panel i get them either on phone or emulator never got them on both.
below is the screenshot of my console
check your android app configuration in firebase console
use a restful client to make the request, i suggest
chrome-extension://aejoelaoggembcahagimdiliamlcdmfm/dhc.html,
there you can see the response of the request, if your request are sent sucessfully or if you have error, and the response tells what kind of error you have
check android app , in the method onMessageReceived and print everything to see if you receive information, besides you can print the property "from" who is the id_number of your proyect, and you can see if the messages come from your firebase android app
check firebase documentation.
I've implemented everything just with the guides and its working pretty well
I solved the same problem.
The problem seems to be the browser compatibility/version. Mozilla Firefox could easily handle this.
Make sure your app is running in the background.
Open the Firebase notification console in the FireFox browser and send notifications.
Make sure token is generated
FirebaseInstanceId.getInstance().getToken();
in my case, the package name defined at firebase console isn't the same as defined on gradle and manifest of the app (i changed it one time in the app), so the app won't be able to receive notifications sent from firebase console.
They both have to be the same!
I did not add a new firebase project, just go to project settings at console and add new android app with another package name and have a look at the newly generated google-services.json and change some lines at you android studio project.
Besides the tips that Pavul Zavala said ، keep this in mind that just data message can received by FirebaseMessagingService even application closed or run in background and notification message can't handle(till this moment) when application run in background.
And all message that sent via FireBase console Contains , they always include a notification key
more detail at :
Push notification works incorrectly when app is on background or not running
In my case, what helped me is creating a new simulator in Android Studio
Few things to check:
in Firebase console https://console.firebase.google.com/ add/configure the project
in Android Studio connect to Firebase - Manu -> Tolls -> Firebase -> Cloud Messaging (Connect, Add FCM to your app)
Send notification from Firebase console
So, again, I recreated Virtual Device (open AVD manger and create the same device with the same API level)
I will be happy if somebody will save the time using this post :)
Ideally it shouldn't behave like that but it might be due to following reasons:
Check the notification priority of your app in the app settings of the device.
You might be sending the token of one particular device, Your target should be User segment.
i am using phonegap-plugin-push to receive notifications.
The very first part, the registration step, works fine on android and ios. I`m saving the registration token on my server and that part is pretty ok.
However, when my server generates an notification, only android version gets notified.
For each device i created a specific api key, as shown in the docs.
But what works for android isn't working for ios.
On android, if my app isn't open i get correctly the notification (vibration+notification)
Is there a way to achieve the same behavior on ios using GCM?
In the end there is no easy solution for that.
As pointed out by #Daniel, the better way to do it is to configure both GCM and APN. a brief discussion can be found here