I'm trying to implement APNS notification where i want to maintain single latest notification for all my incoming notification.
I'm using apns-collapse-id which should be supported by FCM as described here
https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages
However when i send multiple notification with single collapse-id the end use is still getting multiple notification
Below is the receiver end payload, which has "gcm.notification.apns-collapse-id" which i'm guessing is being sent by google.
I'm trying to understand if i need to make any changes to make it work.
Original Sender Payload:
{
"to" : "xyz",
"notification": {
"title" : "title_here",
"body" : "body_here",
},
"data" : {
"message" : "Message_Here"
},
"apns-collapse-id" : "STRING_ID_HERE"
"content_available" : true
}
Receiver side Payload:
{
aps = {
alert = {
body = "body_Here";
title = "title_here";
};
"content-available" = 1;
};
"gcm.message_id" = "0:123456789ae";
"gcm.notification.apns-collapse-id" = STRING_ID_HERE;
"google.c.a.e" = 1;
message = "Message_Here";
}
I recommend using the latest send function from the firebase-admin lib, usage described here.
It seems to work fine.
Related
rpc CreateBook(CreateBookRequest) returns (Book) {
option (google.api.http) = {
post: "/v1/{parent=publishers/*}/books"
body: "book"
};
}
message CreateBookRequest {
// The publisher who will publish this book.
// When using HTTP/JSON, this field is automatically populated based
// on the URI, because of the `{parent=publishers/*}` syntax.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
child_type: "library.googleapis.com/Book"
}];
Book book = 2 [(google.api.field_behavior) = REQUIRED];
string book_id = 3;
}
I don't understand post: "/v1/{parent=publishers/*}/books"
I thought publishers was a field in CreateBookRequest, then it populates to http, so it is something like this
post: "/v1/parent=publishers_field_value/books"
But publishers is not a field in CreateBookRequest
No, publishers is part of the expected value of the parent field. So suppose you have a protobuf request like this:
{
"parent": "publishers/pub1",
"book_id": "xyz"
"book": {
"author": "Stacy"
}
}
That can be transcoded by a client into an HTTP request with:
Method: POST
URI: /v1/publishers/pub1/books?bookId=xyz (with the appropriate host name)
Body:
{
"author": "Stacy"
}
If you try to specify a request with a parent that doesn't match publishers/*, I'd expect transcoding to fail.
That's in terms of transcoding from protobuf to HTTP, in the request. (That's the direction I'm most familiar with, having been coding it in C# just this week...)
In the server, it should just be the opposite - so given the HTTP request above, the server should come up with the original protobuf request including parent="publishers/pub1".
For a lot more information on all of this, see the proto defining HttpRule.
I have created a hub client and I want to pass the custom template in the CreateAppleTemplateRegistrationAsync method. I want to pass the below template payload
{ alert: '$(message)', badge: '#(count)', sound: 'default' }
How to pass the above template as a string in the method.
The template payload has to be a valid json string and abide by Apple's documentation.
This is an example of doing it with literal strings in C#.
var apnsTemplate = #"{
""aps"" : {
""alert"" : {
""title"" : ""$(title)"",
""subtitle"" : ""$(subtitle)"",
""body"" : ""$(message)""
},
""category"" : ""GAME_INVITATION""
},
""gameID"" : ""12345678""
}";
This snippet can be adapted for your desired payload and programming language of choice.
sails.sockets.rooms() and sails.sockets.socketRooms() are both deprecated
In the doc:
This method is deprecated. Please keep track of your rooms in app-level code.
I am new to SailsJS.
Question 1: How could I get started with that? Where should I declare my room array or hash?
Question 2: How do I get the list of the clients connected?
Here the way I did it. Hope this helps a little, although I am not confident it's perfect, BUT it worked for me. Feel free to suggest corrections, enhancements.
I declared a sails.rooms = {}; in the controller (Question 1) where I needed it most. (You can name it whatever you want.)
sails. gives it access across the application.
In the controller
/**
* Socket connection
*/
connect: function(req, res) {
// Check if it's socket connection
if (!req.isSocket) { return res.badRequest(); }
// label the room to ROOM_NAME
sails.sockets.join(req, ROOM_NAME);
/**
* Manage my `sails.rooms` HERE
* e.g.
*/
if (!sails.rooms[ROOM_NAME]) {
sails.rooms[ROOM_NAME] = {};
}
sails.rooms[ROOM_NAME][req.socket.id] = HUMAN_FRIENDLY_LABEL;
}
I end up with a JSON that looks like this:
{
{ "room1" :
{
"ksadj1234clkjnelckjna" : "john",
"eroiucnw934cneo3vra09" : "marie"
}
},
{ "room2" :
{
"kslaksdjfnasjdkfa9jna" : "antoine",
"qweuiqcnw934cne3vra09" : "michelle"
}
}
}
In config/sockets.js, I manage disconnections
afterDisconnect: function(session, socket, cb) {
console.log(socket.id + " disconnected");
/**
* Manage sails.rooms HERE
* e.g.
*/
for (r in sails.rooms) {
delete sails.rooms[r][socket.id];
//
// YOUR CODE
//
}
return cb();
},
NOTE: that you can list the WebSockets in a certain room using sails.io.sockets.in(ROOM_NAME). This should also help to purge the sails.rooms from disconnected sockets.
I'm currently testing kendoUI and developping a little webapp.
For some reason I need to pass my dataSource.datas from a view to another. In order to do this I use sessionStorage and when I try to put my dataSource.data() in sessionStorage, the return is empty.
See here when I put a log to test if my dataSource.data() is correctly inserted/returned
However, when I put a log to test ma dataSource I can clearly see that _data is not empty as it is showed in the follow picture :
Did someone know the origin of my problem ?
EDIT
here is the code that shows how I add my dataSource to sessionStorage :
var qui = (e.view.params.qui) ? e.view.params.qui : "";
var quoi = (e.view.params.quoi) ? e.view.params.quoi : "";
dataSourceFournisseurs = new kendo.data.DataSource({
transport : {
read : {
url:"annuaire.json",
dataType:"json"
}
},
schema : {
data : "data",
model : {
DISTANCE: function() {
var lat = this.get("LATITUDE");
var lng = this.get("LONGITUDE");
var distance = APP.distanceBetweenCoords(lat, lng);
return "à " + distance + "km";
}
}
},
sort : {
field : "LIBELLE",
dir : "asc"
},
filter: [
{ field: "LIBELLE", operator: "contains", value: qui },
{ field: "NAFLIBELLE", operator: "contains", value: quoi }
]
});
console.log(dataSourceFournisseurs);
session.setValueObject("liste", dataSourceFournisseurs.data());
And here is how I retrieve it :
var datas = session.getValueObject("liste");
console.log(datas);
PS :
setValueObject and getValueObject are two methods I wrote in order to Stringify the datas I set and Parse the retrieved datas (there are fully functionnal I use them for over a year)
the two console.log are those that represent the picture above (picture 1 with second log and picture 2 with first log)
EDIT END
Try using dataSourceFournisseurs.view(). This should give you the all of the data. Using data is meant for initial configuration, and is not meant to be used as a method for retrieving data.
Bonne chance!
I am trying to work Ember with Parse.com using
ember-model-parse-adapter by samharnack.
I add added a function to make multiple work search(like search engine) for which I have defined a function on cloud using Parse.Cloud.define and run from client.
The problem is the Array that my cloud response returns is not compatible with Ember Model because of two attributes they are __type and className. how can I modify the response to get response similar to that i get when I run a find query from client. i.e without __type and className
Example responses
for App.List.find() = {
"results":[
{
"text":"zzz",
"words":[
"zzz"
],
"createdAt":"2013-06-25T16:19:04.120Z",
"updatedAt":"2013-06-25T16:19:04.120Z",
"objectId":"L1X55krC8x"
}
]
}
for App.List.cloudFunction("sliptSearch",{"text" : this.get("searchText")})
{
"results":[
{
"text":"zzz",
"words":[
"zzz"
],
"createdAt":"2013-06-25T16:19:04.120Z",
"updatedAt":"2013-06-25T16:19:04.120Z",
"objectId":"L1X55krC8x",
"__type" : Object, //undesired
"className" : "Lists" //undesired
}
]
}
Thanks Vlad something like this worked for me for array
resultobj = [];
searchListQuery.find({
success: function(results) {
for( var i=0, l=results.length; i<l; i++ ) {
temp = results.pop();
resultobj.push({
text: temp.get("text"),
createdAt: temp.createdAt,
updatedAt: temp.updatedAt,
objectId: temp.id,
words: "",
hashtags: ""
});
}
In your cloud code before you make any response, create and object and extract from it the attributes/members you need and then response it. like so:
//lets say result is some Parse.User or any other Parse.Object
function(result)
{
var responseObj = {};
responseObj.name = responseObj.get("name");
responseObj.age = responseObj.get("age");
responseObj.id = responseObj.id;
response.success(responseObj);
}
on the response side you will get {"result": {"name": "jhon", "age": "26", "id": "zxc123s21"}}
Hope this would help you