I am receiving a notification from CloudKit when a record with 'message' field is created. I would like to show to the user on the lock screen the content of the message. could you help me with that.
You have to deliver a Local Notification to the user. You should read the Apple's guide about this topic.
You could send this notification inside the didReceiveRemoteNotification function in AppDelegate class
The way to process the userInfo dictionary received as a parameter must be processed with CKNotification class initialiser.
Related
I would just like to receive the notification data via the OnMessageReceived method and then display a custom notification with Unity's MobileNotification or UTNotification.
Any information in the notification property of a message is automatically handled by the system when the app is not active. If you don't want the system to automatically display a notification, make sure that your message contains no notification property. Data only messages are not displayed by the system automatically.
For more on this, also see the Firebase documentation on message types.
While it is possible to add data properties to an FCM message that is sent through the Firebase console in the Custom data section of the Additional options, there is no way to send a data only message. Messages sent through the Firebase console will always have a notification property, which is what triggers the system to display them.
If you want to send data-only messages, the simplest way is through a CURL command as shown here: How can I send a Firebase Cloud Messaging notification without use the Firebase Console?
I call _firebaseMessaging.subscibeToTopic('topic-title'); to subscribe user to a topic on button click.
Some minutes after, the new topic showed at firebase cloud message console and i sent a message to the topic but I didn't received it. I don't understand why this is not working. I think there should be a option to add user's token to the subscribeToTopic('topic-title', token) or is the token automatically detected? Because am afraid the topic was only created with no token added.
Please i need help.
You don't need user token for topic notification
firebaseMessaging.subscribeToTopic('newJobs'); //you are doing it correctly.
Now I think all you need is to minimize your running app while sending the notification because notification will not appear, if your app is on the resume state.
I had read that not to add notification node in the body of the request, and I tried to send without notification node but it seems that the message not received but when I add the notification node it work well
So, what is the difference notification node and data node in Firebase cloud messaging?
{
"to": "/topics/some_topic",
"data": {
"key_1" : "some_value",
"key_2" : "some_value"
},
"notification":{
"body" : "some_message"
}
}
Is there any link to doc I can read ?
The data node is used for sending notification if the application is on the background/foreground and in some phones if it is also killed.
The notification node is used for sending notification if the application is on the foreground. If it is in the background you wont receive the notification.
The best option I found is to use data node alone.
Also it is explained very well in this link: The FCM messages types
Notification node (a.k.a Notification messages)
When sent, this will receive a notification on the device, regardless of whether the app is in foreground/background/terminated state, but the notification will be shown only when the app is not in foreground. You can bundle a data payload with this of upto 4 KB. The upside is that you do not have to worry about generating a notification every time, the libraries take care of that. The downside is that there is no way not to show the notifications, for eg when you want to do something silently.
Data node (a.k.a Data messages)
When sent, this will fire up all the same callbacks as a normal notification node would, the only difference being that a notification won't pop up on its own, you are the master of your own callback! This is useful for when you want to do something silently, like refresh the cache, update the database etc. As a data node will have the data payload and will fire up a callback at any state of the app, you can generate a notification on your own and fire it up. This gives you the freedom to design your notification however you want!
We need to use push notifications for many users, using watch Gmail API call.
The watch response we should get on the webhook does not contain any information about the user for which the webhook has been called.
The problem is that according to Users.history: list
I cannot get messages without user-id.
How am I supposed to get user-id from the watch webhook?
OR
Is it possible to call something similar to "Users.history: list" without the need to have user-id?
Thanks for your support,
Adrien
Edit from info in link in comment
If you check the Push Notifications you will see that the response from the server contains a data field.
// This is the actual notification data, as base64url-encoded JSON.
data: "eyJlbWFpbEFkZHJlc3MiOiAidXNlckBleGFtcGxlLmNvbSIsICJoaXN0b3J5SWQiOiAiMTIzNDU2Nzg5MCJ9",
The HTTP POST body is JSON and the actual Gmail notification payload is in the message.data field. That message.data field is a base64url-encoded string that decodes to a JSON object containing the email address and the new mailbox history ID for the user:
{"emailAddress": "user#example.com", "historyId": "9876543210"}
Data contains the email address of the user.
Note I don't have the power to test this I am just reading the documentation. I don't have a server set up to retrieve these notifications.
user-id is your email, which is used to subscribe push notification
Does some package or pattern for push notifications for users in Meteor already exist? So I would like to have some way for server to send a notification to the user which is then displayed to the user. Is there something already there? Or should I just create a collection of notifications and get client to subscribe to it, displaying anything which is there as it gets pushed?
At the moment as far as I know theres no way to subscribe to something thats not a collection so to push custom data like a push notification down to the user you would need to use a notification collection.
On your client side you can have an observer that listens for new notifications
Notifications.find().observe({
added:function(document): {
//Push notify your client
Notifications.remove(document._id); //Remove when viewed
}
});
A really nice library to display these on the client is : http://github.hubspot.com/messenger/ you could have it pop up as soon as you insert something into the notifications collection