Meteor-Community-Packages / raix-push

DEPRECATED: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)
https://atmospherejs.com/raix/push
MIT License
513 stars 197 forks source link

Android Client no longer registering after upgrade #127

Open otech-nl opened 8 years ago

otech-nl commented 8 years ago

After upgrading from Push 2.6.12 to 3.0.0 my Push notifications stopped working on Android.

When I run my app in a browser, the logging (with Push.debug=true) shows:

Push: Settings userId "qwertyuiopasdfghj" for app: mnbvcxzlkjhgfdsap

When I run my app on Android no such message is shown.

In both cases (logged in on Android or in Browser) when I Push.send I get:

Push: Send message "blablabla" via query { userId: 'qwertyuiopasdfghj' }
Push: Sent message "blablabla" to 0 ios apps 0 android apps
Push, GUIDE: The "Push.appCollection" is empty - No clients have registred on the server yet...

This is intended when logged in on the browser, but not when logged in via the Android app.

The upgrade to Push 3.0.0 included an upgrade from Meteor 1.1 to 1.2 and the inclusion of Crosswalk. Removing Crosswalk didn't help.

What keeps my Android client from registering?

raix commented 8 years ago

could it be a network issue?

otech-nl commented 8 years ago

Hello Raix,

Thanks for your response.

A network problem doesn't seem likely. It used to work just fine and when I connect through a browser (from the same device), Push registers the app as expected.

It is only my Android app that doesn't register with Push.

I have added the following to my Meteor.startup client-side:

if (Meteor.isCordova){
    Push.debug = true

    Push.addListener('token', function(token) {
        alert('(Test) Push token received: ' + JSON.stringify(token));
    });

    Push.addListener('error', function(err) {
        alert('(Test) Push error: '+err);
    });

    Push.addListener('message', function(notification) {
        alert('(Test) Push message: '+notification.message);
    });

    Push.addListener('alert', function(notification) {
        alert('(Test) Push alert: '+notification.message);
    });

    alert('(Test) Registered Push events');
} else {
    console.warn('NOT registering Push events');
}

I do get the message that the Push events have been registered (the final alert), so alert works, but nothing after that.

Any help would be greatly appreciated. For instance, where to put a breakpoint server-side to see if the client calls any server method?

What information would you need to be able to tell me more?

raix commented 8 years ago

What does your config look like?

otech-nl commented 8 years ago

Here's my config (credentials changed for security):

{
  "gcm": {
    "apiKey": "IESW8Ojfp12FY5Pj7GHzR1EJ6unYTZK27LqIpW2",
    "projectNumber": 245021215735
  },
  "apn-dev": {
    "passphrase": "ip57EZoa7",
    "key": "key.pem",
    "cert": "cert.pem"
  },
  "production": false,
  "sound": true,
  "alert": true,
  "vibrate": true
}

Push reports:

Push: APN configured
GCM configured

Before that, it also prints the PEM file contents, so does that mean my config is correct?

otech-nl commented 8 years ago

I just tried the following:

$ meteor remove raix:push

Changes to your project's package version selections:

raix:eventemitter  removed from your project
raix:eventstate    removed from your project
raix:push          removed from your project

raix:push: removed dependency

$ meteor show raix:push
Package: raix:push@3.0.1
Maintainers: raix
Git: https://github.com/raix/push.git
Exports: Push

[................ snip ....................]

Recent versions:
  2.6.10  May 4th, 2015
  2.6.11  June 29th, 2015
  2.6.12  August 9th, 2015      installed
  3.0.0   October 1st, 2015     installed
  3.0.1   October 6th, 2015

Older and pre-release versions of raix:push have been hidden. To see all 49 versions, run
'meteor show --show-all raix:push'.

Notice the double installed (even after meteor remove raix:push). Does this mean that I have two versions of Push installed on top of each other?

When I start the app that uses the package, it crashes (as it should), with:

ReferenceError: Push is not defined

But why does meteor show still report two installed versions?

raix commented 8 years ago

installed just mean that it's in the local package registry / cached

otech-nl commented 8 years ago

Dear @raix

I just downgraded to raix:push@2.6.12 to able to give my users working push notifications again.

This lead to a number of observations:

I am completely stuck here. Any help would be greatly appreciated. If the above is not clear enough, please let me know.

raix commented 8 years ago

@otech-nl I'll look into it

otech-nl commented 8 years ago

Thanks, that would be great!

nizulzaim commented 8 years ago

+1

otech-nl commented 8 years ago

Hello @raix

I noticed the new version v3.0.2 with a fix of the clone function. Could this fix be in any way related to my problems?

Please let me know if I can assist you in any way.

otech-nl commented 8 years ago

Oops. Didn't mean to close this issue.

If I understand correctly, you need commit access to re-open a closed issue. Could you do that, @raix ?

Apologies for the inconvenience :(

otech-nl commented 8 years ago

I rolled back to v2.6.12 to get push notifications working again.

Met vriendelijke groet,

René Steetskamp

2015-11-24 14:29 GMT+01:00 bitworkz notifications@github.com:

Hello, i'm truggeling a few days now to send push messages. I always get the following output: I20151124-14:26:48.016(1)? Push: Send message "Congratulations" via query {} I20151124-14:26:48.018(1)? send to token { apn: 'my device token' } I20151124-14:26:48.018(1)? Push: Sent message "Congratulations" to 1 ios apps 0 android apps I20151124-14:26:48.028(1)? Push, GUIDE: The "Push.appCollection" - No GCM clients have registred on the server yet... I20151124-14:26:49.111(1)? Got error code 8 for token [my device token]

can anyone please help me a bit with this?

thanks in advance

— Reply to this email directly or view it on GitHub https://github.com/raix/push/issues/127#issuecomment-159267250.

ddguevara commented 8 years ago

+1

Having the same issue, 3.0.+ doesn't seem to register tokens from android, they work perfect with iOS tho.

raix commented 8 years ago

so to recap this issue is only occurring after 2.6.1 to 3.x.x upgrade - and only on android. One issue could be that clients might use the old cordova plugin withe the new cordova js code. I haven't been able to replicate so far

otech-nl commented 8 years ago

I have moved on to other projects, after the workaround with 2.6.12, so I can't verify for you. Sorry.

adam-hanna commented 8 years ago

@raix "One issue could be that clients might use the old cordova plugin withe the new cordova js code."

So if I understand this statement, essentially a hot code push would push the new js to the browser, but not update the cordova packages? The users would need to update the app through the app store before the cordova packages would get updated?

I ask because I'm having the same issues. I'll try to recreate the above if I've understood you correctly.

adamgins commented 8 years ago

Hi, just upgraded to 3.0.2 and having this issue too. Basically the _raix_push_notifications is empty. This is after I see Push: Settings userId "TfshveJNQviENZjm5" for app: kNdZuXZJmveBP6Z5a on the server log.

This is after I have deleted the app off my phone and then deployed the app to both my test server and phone (via XCode). An "yes" I say "ok" to get notifications when I install the app.

I am yet to try all the listener debug examples above... thought I'd check in to see if anyone had a solution.

Is there somewhere I can see if an "old cordova plugin" is installed?

BTW, I noticed https://github.com/phonegap/phonegap-plugin-push is up v1.6.1 ... I was going to fork and see if worth trying the later version - thoughts?

adam-hanna commented 8 years ago
Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id
    at check (packages/check.js:138:15)
    at [object Object].raixPushUpdate (packages/raix:push/lib/server/server.js:19:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

How could id be an object? Does this have to do with mongo sometimes saving _id as an object??

EDIT - a long with lots of other errors

adamgins commented 8 years ago

@raix Hi ya... FYI, I am getting this issue on iOS, this seems I never get the callbacks for the debug options above

  Push.addListener('token', function(token) {
            alert('(Test) Push token received: ' + JSON.stringify(token));
        });

        Push.addListener('error', function(err) {
            alert('(Test) Push error: '+err);
        });

        Push.addListener('message', function(notification) {
            alert('(Test) Push message: '+notification.message);
        });

        Push.addListener('alert', function(notification) {
            alert('(Test) Push alert: '+notification.message);
        });

@raix I am still getting issues as per a while back https://github.com/raix/push/issues/140 with v 2.6.2, so I finally tried to give the upgrade raix:Push v3+ a go , together with upgrading to Meteor 1.3.

The alert('(Test) Registered Push events'); that @otech-nl defined above shows, none of the other call backs fire.

adam-hanna commented 8 years ago

Just to provide an update. The update to 3.0.2 is still working for me. Two new users (one iOS and one Android) just joined my app and both received tokens. Push is also still working for old users.

There is, however, some issue that causes errors to be thrown when upgrading to v3.0.2. It appears to be happening in two cases: (1) when a user has not logged in, and therefore the userId is set to null; and (2) when an old user tries to log-in.

1 is pretty easy to understand.

For #2, took a quick look at the code, and it looks like it's loading information from localstorage. Maybe something was saved with the old version that the new version doesn't like.

Here are my logs, if it helps. For now, this is working for me, and I'm considering these more of as warnings than errors.

EDIT - Looking at this more closely. All of the id's, below, are objects. The id is being set equal to stored.id. Why would stored.id be an object??? See lines 112-127 of /lib/client/client.js

Exception while invoking method 'raix:push-setuser' Error: Match error: Expected string, got object
    at check (packages/check.js:138:15)
    at [object Object].raixPushSetuser (packages/raix:push/lib/server/server.js:115:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

Push: Got push token from app: { id: 
   { _id: '[some long string]',
     token: { gcm: '[some long string]' },
     appName: 'main',
     userId: '[some long string]',
     createdAt: '2016-04-02T19:14:52.400Z',
     updatedAt: '2016-04-03T11:50:59.085Z' },
  token: { gcm: '[some long string]' },
  appName: 'main',
  userId: '[some long string]',
  metadata: {} }
Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id
    at check (packages/check.js:138:15)
    at [object Object].raixPushUpdate (packages/raix:push/lib/server/server.js:19:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

Push: Settings userId "[some long string]" for app: [some long string]
Push: Got push token from app: { id: '[some long string]',
  token: { gcm: '[some long string]' },
  appName: 'main',
  userId: '[some long string]',
  metadata: {} }
Push: updated { _id: '[some long string]',
  token: { gcm: '[some long string]' },
  appName: 'main',
  userId: '[some long string]',
  createdAt: Mon Feb 22 2016 05:23:19 GMT+0000 (UTC),
  updatedAt: Thu Apr 07 2016 05:05:27 GMT+0000 (UTC) }
Exception while invoking method 'raix:push-setuser' Error: Match error: Expected string, got object
    at check (packages/check.js:138:15)
    at [object Object].raixPushSetuser (packages/raix:push/lib/server/server.js:115:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

Push: Got push token from app: { id: 
   { _id: '[some long string]',
     token: { gcm: '[some long string]' },
     appName: 'main',
     userId: '[some long string]',
     createdAt: '2016-04-02T19:14:52.400Z',
     updatedAt: '2016-04-03T11:50:59.085Z' },
  token: { gcm: '[some long string]' },
  appName: 'main',
  userId: '[some long string]',
  metadata: {} }
Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id
    at check (packages/check.js:138:15)
    at [object Object].raixPushUpdate (packages/raix:push/lib/server/server.js:19:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

Exception while invoking method 'raix:push-setuser' Error: Match error: Expected string, got object
    at check (packages/check.js:138:15)
    at [object Object].raixPushSetuser (packages/raix:push/lib/server/server.js:115:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

Push: Got push token from app: { id: 
   { token: { gcm: '[some long string]' },
     appName: 'main',
     userId: '[some long string]',
     enabled: true,
     createdAt: '2016-04-05T14:27:10.804Z',
     updatedAt: '2016-04-05T14:27:10.804Z',
     _id: '[some long string]' },
  token: { gcm: '[some long string]' },
  appName: 'main',
  userId: '[some long string]',
  metadata: {} }
Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id
    at check (packages/check.js:138:15)
    at [object Object].raixPushUpdate (packages/raix:push/lib/server/server.js:19:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]
raix commented 8 years ago

can you investigate what the id contains? - wondering if we need to convert the id to string

adam-hanna commented 8 years ago

There are a couple in the log, from above. Here's the first one, for example:

 {
     _id: '[some long string]',
     token: { gcm: '[some long string]' },
     appName: 'main',
     userId: '[some long string]',
     createdAt: '2016-04-02T19:14:52.400Z',
     updatedAt: '2016-04-03T11:50:59.085Z'
}

The above was taken from one of the first errors in the log:

Push: Got push token from app: { id: 
   { _id: '[some long string]',
     token: { gcm: '[some long string]' },
     appName: 'main',
     userId: '[some long string]',
     createdAt: '2016-04-02T19:14:52.400Z',
     updatedAt: '2016-04-03T11:50:59.085Z' },
  token: { gcm: '[some long string]' },
  appName: 'main',
  userId: '[some long string]',
  metadata: {} }
Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id
    at check (packages/check.js:138:15)
    at [object Object].raixPushUpdate (packages/raix:push/lib/server/server.js:19:5)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (packages/meteor.js:1100:17)
    at packages/ddp-server/livedata_server.js:707:46
    at tryCallTwo (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
    at doResolve (/mnt/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
Sanitized and reported to the client as: Match failed [400]

So strange...

willemserik commented 8 years ago

i have version 3.0.2. when i send a notification than my logs say sent to an android device with a very long key but i don't receive the notification on my android device. my config file looks like this

{ "apn": { "passphrase": "sxcq2bws", "key": "key.pem", "cert": "cert.pem", "gateway" : "gateway.sandbox.push.apple.com" }, "gcm": { "apikey": "AIzaSyAr_IxhP7okneqvYEmjsmrJRDzGOPXBXP8", "projectNumber": 398165784871 }, "production": false, "badge": true, "sound": true, "alert": true, "vibrate": true }

does anyone have the same problem?

thanks in advance

adam-hanna commented 8 years ago

@bitworkz try changing production to true? Also, impossible to tell without more info. Is there a record with your user ID in the push tokens collection?

willemserik commented 8 years ago

@adam-hanna how can i output the token collection?

adam-hanna commented 8 years ago

@bitworkz I think we should take this offline. Do you have an email or another way I can contact you?

willemserik commented 8 years ago

@adam-hanna you can contact me at contact@bitworkz.com. thanks in advance

gaboxv commented 8 years ago

Hi @adam-hanna am working on android and I have almost the same problem, I have Meteor 1.3.1 and raix:push@3.0.2, also added: cordova:cordova-plugin-device@1.1.1 cordova:phonegap-plugin-push@1.5.2 manually.

I have the app hosted in a remote server, generate the APK and log in. O get Push: Settings userId "STX2SzQi2hsBrLREh" for app: Dgxzh8npT9RSsZNdE But when I try to send push notifications the server tells me: Push: Sent message "Hello" to 0 ios apps 0 android apps Push, GUIDE: The "Push.appCollection" is empty - No clients have registred on the server yet...

It seems I am not getting the token,

Thoughts? Thanks!

adam-hanna commented 8 years ago

@gaboxv what's your email?

adamgins commented 8 years ago

Just in the process of trying out Android - will let you know how I go.

adamgins commented 8 years ago

This is working for me on Android. So my config is - I don't use the JSON config, I use Push.configure on both the server and the client. I added the missing plugin (meteor add cordova:cordova-plugin-device@1.1.1 ) as per https://github.com/raix/push/issues/140#issuecomment-207597011

gaboxv commented 8 years ago

Ok, @adamgins @adam-hanna I made it work with Meteor 1.3.1and raix:push@2.6.12including meteor add cordova:cordova-plugin-device@1.1.1 I am using Push.Configure both in server and client server/helpers/pushConfig.js has the Push.Configure with API key for GCM client/helpers/pushConfig.js has the Push.Configure with Project key only and Push.Id()

I use mupx to deploy the server and then build the APK using meteor build <location> --server=<server>

However, If then I remove raix:push@2.6.12 and add raix:push@3.0.2 it stop working, I use the same procedure to generate the APK and mupx deploy and I cannot see the token database, on server logs I see the registration ID.

I tried adding manually the phonegap plugin 1.5.2, which is an internal dependency of raix:push but the result is the same.

I also used the listener functions to display alerts on the client, it works on raix:push@2.6.12 but when I upgrade to raix:push3.0.2 it does not work, no alerts come forth:

(registration, token, foregroung, background, etc)

am I missing something?

@raix

adamgins commented 8 years ago

@raix @adam-hanna @gaboxv wondering if you have found a solution to the Exception while invoking method 'raix:push-setuser' Error: Match error: Expected string, got object error.

in general my push messages work mostly. Some times I get the following error (see below).

any ideas pls?

Exception while invoking method 'raix:push-setuser' Error: Match error: Expected string, got object
h2vk
2016-05-09 14:27:27+10:00Sanitized and reported to the client as: Match failed [400]
h2vk
2016-05-09 14:27:27+10:00
h2vk
2016-05-09 14:27:27+10:00 at exports.check (packages/check/match.js:34:1)
h2vk
2016-05-09 14:27:27+10:00 at [object Object].raixPushSetuser (packages/buzzy-buzz:push/lib/server/server.js:115:5)
h2vk
2016-05-09 14:27:27+10:00 at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)
h2vk
2016-05-09 14:27:27+10:00 at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
h2vk
2016-05-09 14:27:27+10:00 at packages/ddp-server/livedata_server.js:711:19
h2vk
2016-05-09 14:27:27+10:00 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
h2vk
2016-05-09 14:27:27+10:00 at packages/ddp-server/livedata_server.js:709:40
h2vk
2016-05-09 14:27:27+10:00 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
h2vk
2016-05-09 14:27:27+10:00 at packages/ddp-server/livedata_server.js:707:46
h2vk
2016-05-09 14:27:27+10:00 at tryCallTwo (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
h2vk
2016-05-09 14:27:27+10:00 at doResolve (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
h2vk
2016-05-09 14:27:27+10:00 at new Promise (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:66:3)
h2vk
2016-05-09 14:27:27+10:00 at Session.method (packages/ddp-server/livedata_server.js:681:23)
h2vk
2016-05-09 14:27:27+10:00 at packages/meteorhacks_kadira/lib/hijack/wrap_session.js:52:1
h2vk
2016-05-09 14:27:27+10:00 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
h2vk
2016-05-09 14:27:27+10:00 at Session.sessionProto.protocol_handlers.method (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:51:1)
h2vk
2016-05-09 14:27:27+10:00Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id
h2vk
2016-05-09 14:27:27+10:00Sanitized and reported to the client as: Match failed [400]
h2vk
2016-05-09 14:27:27+10:00 at exports.check (packages/check/match.js:34:1)
h2vk
2016-05-09 14:27:27+10:00 at [object Object].raixPushUpdate (packages/buzzy-buzz:push/lib/server/server.js:19:5)
h2vk
2016-05-09 14:27:27+10:00 at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)
h2vk
2016-05-09 14:27:27+10:00 at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
h2vk
2016-05-09 14:27:27+10:00 at packages/ddp-server/livedata_server.js:711:19
h2vk
2016-05-09 14:27:27+10:00 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
h2vk
2016-05-09 14:27:27+10:00 at packages/ddp-server/livedata_server.js:709:40
h2vk
2016-05-09 14:27:27+10:00 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
h2vk
2016-05-09 14:27:27+10:00 at packages/ddp-server/livedata_server.js:707:46
h2vk
2016-05-09 14:27:27+10:00 at tryCallTwo (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
h2vk
2016-05-09 14:27:27+10:00 at doResolve (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:200:13)
h2vk
2016-05-09 14:27:27+10:00 at new Promise (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:66:3)
h2vk
2016-05-09 14:27:27+10:00 at Session.method (packages/ddp-server/livedata_server.js:681:23)
h2vk
2016-05-09 14:27:27+10:00 at packages/meteorhacks_kadira/lib/hijack/wrap_session.js:52:1
h2vk
2016-05-09 14:27:27+10:00 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
h2vk
2016-05-09 14:27:27+10:00 at Session.sessionProto.protocol_handlers.method (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:51:1)

Ah additionally, I see the following in the logs:

Push: Got push token from app: { id:
h2vk
2016-05-09 16:02:59+10:00 { _id: '<someid>',
h2vk
2016-05-09 16:02:59+10:00 token: { apn: '<some token>' },
h2vk
2016-05-09 16:02:59+10:00 appName: 'main',
h2vk
2016-05-09 16:02:59+10:00 userId: '<some id>',
h2vk
2016-05-09 16:02:59+10:00 createdAt: '2015-11-03T06:21:51.509Z',
h2vk
2016-05-09 16:02:59+10:00 updatedAt: '2016-04-02T05:51:56.321Z' },
h2vk
2016-05-09 16:02:59+10:00 token: { apn: '<some token>' },
h2vk
2016-05-09 16:02:59+10:00 appName: 'main',
h2vk
2016-05-09 16:02:59+10:00 userId: '<some user ID>',
h2vk
2016-05-09 16:02:59+10:00 metadata: {} }
h2vk
2016-05-09 16:02:59+10:00Exception while invoking method 'raix:push-update' Error: Match error: Expected string, got object in field id

So it seems like the issue is the id actually does have an object in it, not a string. The above is the output of 'raix:push-update'

 if (Push.debug) {
      console.log('Push: Got push token from app:', options);
    }

so why would the options id have a full object in it?

it seems like it's populated from stored.id via

var data = {
    id: stored.id,
    token: token,
    appName: appName,
    userId: (addUserId) ? Meteor.userId() : null,
    metadata: stored.metadata
  };

is it seems like there's a nested object stored in the id field in the localStorage. ie the id contains

{ _id: '<id>',
 token: { apn: '<token>' }

I had a look at saveLocalstorage to see if I could see how it was nesting a complete object in the id but nothing jumped out.

thoughts?

raix commented 8 years ago

@adamgins Could it be a case of mongoID - that would be an id in object format? (wondering why that would be the case though)

adamgins commented 8 years ago

@raix it looks like it's set id to { _id: '<id>', token: { apn: '<token>' } so it's nested the full object inside id is there a place in the code where it queries to get the token object and then does not actually get the field but gets the whole object?

I had a look around but could not seem to see it

raix commented 8 years ago

@adamgins thats strange - I'll check

raix commented 8 years ago

The only place id is set on the client is ref is Push.id() returning { _id, token }?

adamgins commented 8 years ago

@raix thanks. I may have found it!!!

See https://github.com/raix/push/blob/fix-device-dependency-deprecate-json-format/lib/server/server.js#L74 doc._id = Push.appCollection.insert(doc);

In Mongo 2.6 this insert changed what it returns see https://docs.mongodb.com/manual/reference/method/db.collection.insert/ Changed in version 2.6: The insert() returns an object that contains the status of the operation.

So I think you'd just need to set the ID with something like new Meteor.Collection.ObjectID()._str,

raix commented 8 years ago

Im tempted to say this is a meteor issue. I could test for .str and ._id though

raix commented 8 years ago

Good catch @adamgins

adamgins commented 8 years ago

Something like this would do it:

 } else {
        // Get the id from insert
        doc._id = new Meteor.Collection.ObjectID()._str;
        Push.appCollection.insert(doc);
      }
raix commented 8 years ago

It seems like the WriteResult contains _id not _str (ObjectID) ref EDIT: Nevermind :)

madc0w commented 8 years ago

We are seeing the same issue here.

We used to have a _raix_push_app_tokens collection containing the tokens for each user, but after resetting our test database, this collection stays empty when we recreate our users. We dropped this collection, and now it is no longer even being created. We do, however, see _raix_push_notifications.

Here is the debug output from the server:

2016-05-30 17:52:03+02:00 { keyData: 'Bag Attributes\n friendlyName: XXX\n localKeyID: XXX \nKey Attributes: <No Attributes>\n-----BEGIN ENCRYPTED PRIVATE KEY-----\nXXX\n-----END ENCRYPTED PRIVATE KEY-----\n',
2016-05-30 17:52:03+02:00 certData: '-----BEGIN CERTIFICATE-----\nXXX\n-----END CERTIFICATE-----\n',
2016-05-30 17:52:03+02:00 passphrase: 'XXX' },
2016-05-30 17:52:03+02:00 gcm: { apiKey: 'XXX' },
2016-05-30 17:52:03+02:00 production: true,
2016-05-30 17:52:03+02:00 sound: true,
2016-05-30 17:52:03+02:00 badge: true,
2016-05-30 17:52:03+02:00 alert: true,
2016-05-30 17:52:03+02:00 vibrate: true }
2016-05-30 17:52:03+02:00Push: APN configured
2016-05-30 17:52:03+02:00GCM configured
2016-05-30 17:52:08+02:00Push: Settings userId "null" for app: dFSYk9b7wMvQ9WtHW
2016-05-30 17:52:18+02:00Push: Send message "global push title" via query {}
2016-05-30 17:52:18+02:00Push: Sent message "global push title" to 0 ios apps 0 android apps
2016-05-30 17:52:18+02:00Push, GUIDE: The "Push.appCollection" is empty - No clients have registred on the server yet...
2016-05-30 17:52:33+02:00Push: Send message "push title" via query { userId: '7aafpYgpiynmGw4A5' }
2016-05-30 17:52:33+02:00Push: Sent message "push title" to 0 ios apps 0 android apps
2016-05-30 17:52:33+02:00Push, GUIDE: The "Push.appCollection" is empty - No clients have registred on the server yet...

We are using the latest version of raix:push, 3.0.2, which is the same version we've been using for many months and that used to work fine.... so, we're not sure what has changed to break this. Downgrading to 2.6.12, as suggested above, would be our next step, but we can't figure out why 3.0.2 would suddenly break.

Is there any fix for this?

thegizzada commented 6 years ago

Good day, we are experiencing the same issue with versions 3+, I have read through all the issues on this package referencing the empty app collections, and have the same output on server as @madc0w, has anyone found an actual solution?

raix commented 6 years ago

@rodrigok do you guys have an issue with GCM? (related to FCM?)

rodrigok commented 6 years ago

@raix nothing that I'm aware of