I've been implementing Notification Channels in my android app to support recent android versions.
You can set the notification channel id when sending messages from the firebase web console, but I was not able to find out how to set the channel id when sending messages via fcm rest api.
Notification channels are not mentioned in the reference (https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages), but I am pretty sure there must be a way to set the channel id.
The key name I was missing is android_channel_id
I found the key name in the Legacy HTTP Server Protocol docs (https://firebase.google.com/docs/cloud-messaging/http-server-ref)
Related
I want to send push notifications from my PBX/SIP-Server (FreePBX 15/Asterisk 17)
to sip client apps that provide 'pn-provider', 'pn-param' and 'pn-prid' URI Parameters as specified in rfc8599/draft-ietf-sipcore-sip-push-29 during REGISTER sip request, e.g.
xyz#1xx.1xx.2xx.198:9926;transport=TLS;pn-provider=fcm;pn-param=com.mizuvoip.mizudroid.app;pn-prid=dcrpn1TbEW0:APA91bGgK3RV-s7AX-U2...HLoQL1UNgom
What I haven't managed/do NOT understand so far is how to successfully create a push notification with the device token in 'pn-prid' submitted by the sip client app (NOTE: This is a 3rd party(!) app, for which I neither possess a SenderID nor a ServerKey from its linked Firebase project. In my case, I use and tried before with MizuDroid sip client APP for Android.)
Attempts to send a PUSH notification via FCM HTTP REST API using a ServerKey from a Firebase project I have registered before all resulted in
{"multicast_id":2435751791125788205,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
My questions are:
Is it possible to send FCM PUSH notifications to 3rd party(!) apps from which you have already obtained a device token (here: in 'pn-prid' URI parameter)
If answer 1 is yes: What FCM API do I need to use, what data do I need to submit for the purpose and what are the further prerequisites
Is it possible to identify whether a particular push notification message was delivered to a particular token via Firebase Cloud Messaging? And, if so, is it possible to do so via an API call or by listening to some callback?
I know that I can look at aggregate statistics in the console and even segment those statistics through analytics tags, but cannot find a way to get more discrete information.
I also know that the API will synchronously respond if a token is invalid but the process by which Apple and Google invalidate tokens is a bit opaque (to me) and doesn't help if someone simply turned off push notifications for my app.
Thanks!
Jason
If someone turned off push notification – you can check it with code
Swift ios check if remote push notifications are enabled in ios9 and ios10
Android app - detect if app push notification is off
But user can be offline, or APNs / Firebase service – can get some problems and your notification will be drop. You can check delivery status with some code in iOS and Android applications.
If you need check, delivery status for some push you can make push notification extension (in iOS). For send status about delivered notification in your API. More info about push notification extension.
https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
It can be helpful
https://developer.apple.com/documentation/usernotifications
https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications
https://firebase.google.com/docs/cloud-messaging/understand-delivery
https://firebase.google.com/docs/cloud-messaging/android/receive#handling_messages About handling messages in Android (you can send status delivered too)
I hope this answer will help with your problem.
UPD:
https://firebase.google.com/docs/cloud-messaging/understand-delivery
Received (available only on Android devices) — The data message or
notification message has been received by the app. This data is
available when the receiving Android device has FCM SDK 18.0.1 or
higher installed.
I have an Azure Web Service which is using an Azure Notification Hub to push data notifications using FCM via Firebase to a Xamarin Android App. Initially the app is getting a token which is posted to the web service. The web service then sends it with the data to the notification hub which is sending it to Firebase. The response back from the hub is indicating a successful transfer it seems from the notification properties and the ReqID property. But the notification is not reaching the app. Is there a way to see individual notifications' status on the Firebase site? Currently I don't see anything under the "Cloud" report for Data.
[
Thanks for asking question! One of the notification failure point could be when sending it from FCM to user device. To confirm this, you may try getting a delivery receipt from FCM.
You may refer to this article Receive delivery receipts. It says for Android and Chrome client apps, you can get delivery receipts which can be sent from FCM to your app server. To enable this feature, the message your app server sends to FCM must include the field delivery_receipt_requested. When this field is set to true, FCM sends a delivery receipt when a device confirms that it received a particular message. Also check for firewall on the user's network.
We are developing a Xamarin UWP app that is supposed to receive Push Notifications using WNS. We are using Amazon SNS to send notifications. We made sure that the app is registering itself with proper channel URI to our backend, package name of the app is same as in the store and using Cognito credential put device token entry in Amazon application arn. I have sent raw message to device endpoint and message received in device properly. We couldn't send as Json format and tried as mentioned in below link.
https://anbu2016.wordpress.com/2016/03/17/push-notification-with-wns-and-aws-sns/
But didn't know where to receive notification from application.
For example, ReceivedRemoteNotification as override method present in iOS and it will help process the notification. In my process sent argument then based an argument, we can navigate to different page. How can we do this in UWP using JSON format.
Please help me on this.
Regards,
Cheran
Yesterday Google has announced a new set of tools for Firebase, one of them was Notifications the ability to send notifications from server to devices which are using my app.
But can we now notify users when they receive a new message?
And if not, is there a way around to achieve this?
Looking at the documentation, this doesn't seem currently possible automatically. Here is a possible way to accomplish it "manually" with another server:
Subscribe a user to it's own user ID
In android
FirebaseMessaging.getInstance().subscribeToTopic("InsertUserIDHere");
In IOS
[[FIRMessaging messaging] subscribeToTopic:#"/topics/InsertUserIDHere"];
Setup an outside server that checks every sent messages. When a message is sent, the server should create a notification that includes the recipient's user ID as the topic.
Look here for more info.
You can send messages to group of users (targeting a specific "topic") or to a single device (targeting a Firebase Cloud Messaging token).
To subscribe a device to a topic use:
FirebaseMessaging.getInstance().subscribeToTopic("topicName");
To obtain the device token use (*1) :
FirebaseInstanceId.getInstance().getToken();
Then you can use the Firebase Notificaitons web console, or the FCM server API if you want to send messages from your server.
See: https://firebase.google.com/docs/cloud-messaging/downstream#sending_topic_messages_from_the_server
Notes:
[1] getToken() can return null if the token is not yet available.
You can use the callback onTokenRefresh() to be notified when the token is available and when the token is rotated.
See: https://firebase.google.com/docs/cloud-messaging/android/client#sample-register