activitree / meteor-push

Meteor Push Notifications for Cordova and Web/PWA with Firebase (FCM).
MIT License
27 stars 19 forks source link

Error: android.data must only contain string values #32

Closed tonymckendry closed 3 years ago

tonymckendry commented 3 years ago

Whenever I attempt to send a test notification I receive an error about Android data - I get the error below infinitely as the app attempts to send the notification over and over and over again until I stop the server or delete the record from the database.

I have noticed that I do not receive the error if there are no devices registered _push_app_tokens collection in the db, but if I register an iPhone, this is what happens.

What do I need to do differently here? I have followed the example fairly closely and do believe I have all the correct pieces in place, though there is lack of documentation to be sure.

App Token:

{
  "_id": "vTx4c9p23hJgJzKFw",
  "token": {
      "apn":"eWUoR1R3yEY:APA91bGqTgfHtOARjGP..."
   },
   "appName":"App Name",
   "userId":"5e207e5702dd88273aca77b4f",
   "enabled":true,
   "createdAt":"1611549799035.0",
   "updatedAt":"1611549807207.0"
 }

Notification send:

        Push.send({
            from: 'Test',
            title: 'TEST',
            body: 'this is a test',
            userId: this.userId 
        })

Notification in _push_notifications collection:

{
"_id":"EWus4L7GAwzevQjty",
"createdAt":{"$numberDouble":"1611595420575.0"},
"createdBy":"<SERVER>",
"sent":false,
"sending":{"$numberInt":"60000"},
"from":"App name",
"title":"TEST",
"body":"this is a test",
"userId":"5e207e5702dd88273ac08b4f"
}

Error:

Push: Could not send notification id: "BrhNkZ9hntLCHCMCM", Error: android.data must only contain string values
Push: Send message "TEST" to user: [ '5e207e5702dd88273ac08b4f' ]
Send to token {
 apn: 'eWUoR1R3yEY:APA91bGqTgfHt...'
}
Final notification right before shoot out: {
    "android": {
        "priority": "HIGH",
        "data": {
            "title": "TEST",
            "body": "this is a test",
            "color": "#337FAE",
            "tag": "undefined",
            "channel_id": "appName",
            "notification_priority": "PRIORITY_DEFAULT",
            "visibility": "PRIVATE"
        },
        "fcm_options": {
        "analytics_label": "activitreeSomething"
    }
 },
 "apns": {
    "headers": {
         "apns-priority": "10"
    },
    "payload": {
        "aps": {
            "alert": {
                "title": "TEST",
                 "body": "this is a test",
                "launch-image": ""
            },
            "badge": 1,
            "sound": "",
            "data": {}
        }
    },
    "fcm_options": {
        "analytics_label": "activitreeSomething"
    }
 },
 "webpush": {
    "headers": {
        "Urgency": "high",
        "TTL": "3600000"
    },
    "data": {},
    "notification": {
        "title": "TEST",
        "body": "this is a test"
    },
    "fcm_options": {}
 }
paulincai commented 3 years ago

In readme you can read:

"For a successful processing of Android, please have all defaults set (although you might not have a sound file or icon etc) or send the keys within your notification method. Defaults are set in startup/server/push.js. When Android keys are missing and debugging is set to true you may receive this error: 'android.data must only contain string values'."