raix-push icon indicating copy to clipboard operation
raix-push copied to clipboard

Push, GUIDE: The "Push.appCollection" is empty

Open woniesong92 opened this issue 10 years ago • 22 comments

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.

woniesong92 avatar Aug 08 '15 06:08 woniesong92

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?

woniesong92 avatar Aug 08 '15 19:08 woniesong92

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 avatar Aug 08 '15 20:08 raix

@raix I confirmed that Push.addListener('token') gets triggered. Isn't it same as Push.on?

woniesong92 avatar Aug 08 '15 20:08 woniesong92

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 avatar Aug 08 '15 20:08 woniesong92

@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

raix avatar Aug 09 '15 05:08 raix

Please try 2.6.12 and verify if it fixes the issue

raix avatar Aug 09 '15 06:08 raix

Thanks for being so responsive. I will check it as soon as I get home and let you know.

woniesong92 avatar Aug 09 '15 06:08 woniesong92

@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?

woniesong92 avatar Aug 09 '15 18:08 woniesong92

@raix Seems have same problem, did you find the solution yet?

maxtor3569 avatar Aug 11 '15 21:08 maxtor3569

+1

gumyn avatar Aug 26 '15 13:08 gumyn

Mobile-server should not be localhost, the phone needs to be able to connect over lan

raix avatar Aug 26 '15 19:08 raix

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.

gkrizek avatar Oct 30 '16 00:10 gkrizek

@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.

gkrizek avatar Nov 07 '16 12:11 gkrizek

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 screen shot 2016-11-07 at 9 08 59 am

Next select the capabilities tab and enable push notifications, both steps must be checked screen shot 2016-11-07 at 9 10 00 am

Hope this helps you.

indesignlatam avatar Nov 07 '16 14:11 indesignlatam

@indesignlatam, Thanks for the suggestion, but yes I have made sure that's enabled and both the Steps have the check mark by them.

gkrizek avatar Nov 07 '16 14:11 gkrizek

I resolved this issue by adding the cordova-plugin-device plugin.

meteor add cordova:[email protected]

gkrizek avatar Nov 12 '16 01:11 gkrizek

@gkrizek are you using the latest version of the push package?

raix avatar Nov 12 '16 06:11 raix

@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 avatar Nov 12 '16 15:11 gkrizek

@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 avatar Dec 12 '16 16:12 JWPapi

@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 avatar Dec 12 '16 19:12 raix

@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

JWPapi avatar Dec 14 '16 08:12 JWPapi

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

JWPapi avatar Dec 14 '16 09:12 JWPapi