Hi
I try to add push notifications for my app and added raix:push. Unfortunately I got stuck in an error. I cannot register a device. Wether Android nor iOS. When starting meteor on my local machine following output appears:
=> Started proxy.
I20160406-21:38:18.528(2)? Push.Configure { apn:
I20160406-21:38:18.529(2)? { keyData: … },
I20160406-21:38:18.529(2)? gcm: { apiKey: …},
I20160406-21:38:18.530(2)? production: false,
I20160406-21:38:18.530(2)? sound: true,
I20160406-21:38:18.530(2)? badge: true,
I20160406-21:38:18.530(2)? alert: true,
I20160406-21:38:18.530(2)? vibrate: true }
I20160406-21:38:18.530(2)? Push: APN configured
W20160406-21:38:18.531(2)? (STDERR) WARNING: Push APN is in development mode
I20160406-21:38:18.654(2)? GCM configured
=> Started your app.
=> App running at: http://localhost:3000/
I20160406-21:38:36.620(2)? Push: Settings userId “oaSEiGfrdcjzmJ7P9” for app: zB3L5mm9P3icCo9rJ
I20160406-21:42:40.461(2)? Push: Settings userId “oaSEiGfrdcjzmJ7P9” for app: DcfSFow64uB6wKYbg
How I am calling from Chrome console:
Push.send({
from: ‘Test’,
title: ‘Hello’,
text: ‘World’,
badge: 12,
query: {}
});
And from meteor server I get the following output:
I20160406-21:43:06.256(2)? Push: Send message “Hello” via query {}
I20160406-21:43:06.374(2)? Push: Sent message “Hello” to 0 ios apps 0 android apps
I20160406-21:43:06.493(2)? Push, GUIDE: The “Push.appCollection” is empty - No clients have registred on the server yet…
I have set-up:
- Apple APN (certificate etc.)
- Google API key
- config.push.json in my app (in root folder)
- Push methods on server (see below)
- Added listener on client on Meteor.startup (see below)
server/lib/pushMethods.js:
Push.debug = true;
Push.allow({
send: function(userId, notification) {
return true; // Allow all users to send
}
});
Meteor.methods({
serverNotification: function(text,title) {
var badge = 1;
Push.send({
from: ‘push’,
title: title,
text: text,
badge: badge,
payload: {
title: title,
text:text
},
query: {
// this will send to all users
}
});
},
userNotification: function(text,title,userId) {
var badge = 1;
Push.send({
from: ‘push’,
title: title,
text: text,
badge: badge,
payload: {
title: title
},
query: {
userId: userId //this will send to a specific Meteor.user()._id
}
});
},
removeHistory: function() {
NotificationHistory.remove({}, function(error) {
if (!error) {
console.log(“All history removed”);
}
});
}
});
client/lib/startup.js:
Meteor.startup(function () {
Push.addListener(‘token’, function(token) {
alert(JSON.stringify(token));
Meteor.call(‘raix:push-update’, token, function(err, result){
if (err) {
alert("ERROR: I am inside raix:push-update call " +err);
} else {
alert("Succesfully added: " + result)
}
});
});
Push.addListener('message', function(notification) { alert("message"); }); ... //some other geolocation stuff follows, which is working, that's why I know the startup.js is executed. ...
However, it seems that the code in startup on the client is never called (the listeners). Because they should display an alert. I also had a look at logcat from Android too see if anything here is executed on startup but its not.
EDIT: I also deployed my app to AWS, to see if there is a local problem (somewhere I read that push notifications is not working on local server…) I get the same error message as above (No clients have registred on the server yet…) I tried also to call again from Chrome console of my AWS deployed app:
Meteor.call(“serverNotification”, “text”, “title”)
Output:
undefined
I looked at the following solutions on GitHub, but no success so far:
Any ideas? Or did I forgot anything to configure? How can I register a device? Or a problem with Meteor 1.3?