Meteor-Community-Packages / Meteor-Community-Packages/raix-push

Push.setMetadata working?

Open
#171 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
505
Forks
191
PR merge metrics
No merged PRs in 30d

Description

Hi I'm trying to attach some metadata to my tokens but not sure if it's my fault or a bug
I want to filter messages by channels and channels could be changed by the app user
In my code

```
Meteor.startup(function () {
Push.addListener('message', function(notification) {
// Called on every message
console.log(JSON.stringify(notification));
});
Push.setMetadata({channels: ['all', 'news', 'events', 'alerts', 'advises']});
});
```

log

```
20151219-23:04:22.930(1)? Push: Got push token from app: { id: 'xRb8wSmbbfRmtChCT',
I20151219-23:04:22.931(1)? token: { gcm: 'xxx' },
I20151219-23:04:22.931(1)? appName: 'main',
I20151219-23:04:22.931(1)? userId: null,
I20151219-23:04:22.931(1)? metadata: { channels: [ 'all', 'news', 'events', 'alerts', 'advises' ] } }
I20151219-23:04:22.936(1)? Push: updated { _id: 'xRb8wSmbbfRmtChCT',
I20151219-23:04:22.936(1)? token: { gcm: 'xxx },
I20151219-23:04:22.936(1)? appName: 'main',
I20151219-23:04:22.936(1)? userId: null,
I20151219-23:04:22.936(1)? enabled: true,
I20151219-23:04:22.936(1)? createdAt: Sat Dec 19 2015 22:38:26 GMT+0100 (CET),
I20151219-23:04:22.937(1)? updatedAt: Sat Dec 19 2015 22:58:50 GMT+0100 (CET) }
```

In mongo

```
{
"_id" : "sRb8wSmbafRmtChCT",
"token" : {
"gcm" : "xxx"
},
"appName" : "main",
"userId" : null,
"enabled" : true,
"createdAt" : ISODate("2015-12-19T21:38:26.423Z"),
"updatedAt" : ISODate("2015-12-19T22:04:22.932Z")
}
```

Contributor guide

Open the contributing guide

Research direction

Start at the Push.setMetadata call and trace how the token record is updated after the metadata appears in the log. Compare that update with the Mongo document shown; done means the metadata is persisted on the token record and remains usable for channel filtering.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.