Push, GUIDE: The "Push.appCollection" is empty
I looked at all the relevant issues and it seems all of them don't apply to me.
I know that the certificates are working fine because I am using NWPusher to test, and the push notifications seem to work.
It is just that when I do Push.send(..) I get the above error.
I started my server like this:
meteor run ios-device --mobile-server localhost:3000
and mobile config is set correctly. Is there anything that I am missing?
I was able to print the token by listening to token event, but it seems reportTokenToServer is just not called properly or for some other reason the token doesn't get registered.
Also, one weird thing is the app doesn't ask for push permissions when I first open it after a fresh install.
It seems that if I invoke raix:push-update manually with custom appName, it works. How do I debug why the method isn't getting called?
Try listening to the Push.on('token'); https://github.com/raix/push/blob/master/lib/client/client.js#L112 to see if the event gets triggered
@raix I confirmed that Push.addListener('token') gets triggered. Isn't it same as Push.on?
This is my temporary solution..
Meteor.startup(function() {
if (Meteor.isClient) {
console.log("new version");
Push.addListener('token', function (token) {
PUSH_TOKEN = token;
Meteor.call('raix:push-update', {
appName: "Toaster",
token: token,
userId: ""
});
});
Accounts.onLogin(function (user) {
console.log("Setting userId for Push setting");
Push.appCollection.update({
token: PUSH_TOKEN
}, {$set: { userId: user.user._id }});
});
@woniesong92 it is (just aliases)
So your code is working you say? I'm thinking that it might be due to you added the Meteor.startup - I suspect that the event is triggered before meteor is ready - Since your code is much similar to https://github.com/raix/push/blob/master/lib/client/client.js#L112
Please try 2.6.12 and verify if it fixes the issue
Thanks for being so responsive. I will check it as soon as I get home and let you know.
@raix Unfortunately, that didn't solve the problem. It seems it still returns an empty array if I don't call raix:push-update' manually.
EDIT: even worse, even the fix I used to have doesn't work anymore. I know my certificates are valid because they are working well with NWPusher. Do you know what debugging steps I can follow and whether I should keep calling raix:set... methods manually?
@raix Seems have same problem, did you find the solution yet?
+1
Mobile-server should not be localhost, the phone needs to be able to connect over lan
I'm experiencing this with Meteor 1.4.2
I can't see what I'm doing wrong, I have everything configured according to the guide and my certificates check out. When I start the app with
meteor run ios-device --mobile-server=http://app.site.com --production,
I get this in the Xcode logs:
appName [6527:1415610] Push Plugin register called
appName [6527:1415610] THREAD WARNING: ['PushNotification'] took '11.035889' ms. Plugin should use a background thread.
appName[6527:1415610] active
appName [6527:1415610] Push Plugin register success: <b2bc1742 7e4b5678 e90cb818 7fab5656 d296ebf3 ...>
But then I watch my server logs when I try to call the Send Message function:
Push: Setting enabled to "true" for app: u9Jz4Lz53yDKz2cYm
Push: Settings userId "qgsdQocjPNbBPjQc8" for app: u9Jz4Lz53yDKz2cYm
Sending a message...
Push: Send message "New Message" via query {}
Push: Sent message "New Message" to 0 ios apps 0 android apps
Push, GUIDE: The "Push.appCollection" is empty - No clients have registred on the server yet...
It's like it contacts the server just fine, but it won't actually register it. Any ideas @raix?
Thanks!
EDIT: I have also tried all other suggestions in issue from this repo. Like the Bundle Identifier and Provisioning Profile stuff.
@raix, i have also tried starting from scratch with new certificates and everything but still get the same thing. I see you added this to the v3.1.1 milestone, so is this a known bug?
Thanks.
Hello @gkrizek, have you added the push notifications entitlements to your app on xcode, sometimes it just not enabled and it will fail to register a new device.
Go to your project

Next select the capabilities tab and enable push notifications, both steps must be checked

Hope this helps you.
@indesignlatam, Thanks for the suggestion, but yes I have made sure that's enabled and both the Steps have the check mark by them.
I resolved this issue by adding the cordova-plugin-device plugin.
meteor add cordova:[email protected]
@gkrizek are you using the latest version of the push package?
@raix, Yes. I added it with just meteor add raix:push, and I even did a meteor update --all-packages before adding the cordova-plugin-device
@gkrizek You saved my life!!! I tried to debug for days. Adding cordova-plugin-device, finally did the job!
@raix, please add this in the doc, till you have a better solution. I find in the meteor forums here a lot of issues with not registering devices
@JWPapi I've added it on the main README.md - I'm wondering why it's needed - the packge.js specifies a dependency on cordova-plugin-device is it an issue with the meteor build tool?
@raix Yeah probably it is. I craved the Meteor documentation. Couldnt't find a hint though. Ill remove cordova plugin device now and will check if the build tool gives me an warning or sth
Ok I checked. So if i not manually add the plugin, it's not working. But couldnt find a hint why. Maybe contact the Meteor Devs. Im not that experienced as Dev, so I can't help any further