1

I've been developing a chat app with Titanium and I'm facing some issues while sending push notifications when a user send a message.

If I simply call:

Cloud.PushNotifications.notify({
    channel : 'myChannel',
    to_ids : usersID.toString(),
    payload : {
        message : "message",
        from : myId,
        sound : "default",
        alert : "New message!",
    }
};, function(e) {
        if (e.success) {
            console.log('Success');
        } else {
            console.log('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });

I get the OK from the server

    {"push_notification":{"id": "xxx", "payload": "{\"message\":\"message\",\"from\":\"xxx\",\"sound\":\"default\",\"alert\":\"New message!\"}", "channel": "myChannel"}, "success": true,"error": false, "meta":{"code": 200, "status": "ok", "method_name": "Notify"}}

but the push notification is marked with the status Failure on the ArrowDB panel.

A different story if I set to_ids = "everyone", the push is sent (as long as you're an admin user).

The weird thing is that I get the same error if I try to send it from the ArrowDB panel.

Sending the push with specific IDs Sending the push with specific IDs

Sending the push to everone Sending the push to everone

I'm not sure what I'm doing wrong but I tried to stick to the basic examples provided by titanium.

Alberto M
  • 1,608
  • 1
  • 18
  • 42
  • Experiencing exactly the same thing. Server log returns successful push but the push logs are reporting failure with no further details – kenwen Apr 04 '16 at 11:32
  • I just remembered that I fixed this in another project, I will be updating with the answer later on. It was something to do with the method I was calling. – Alberto M Apr 04 '16 at 14:46

1 Answers1

1

The problem was that the devices didn't have an user associated:

user not associated to device

After a lot of tests I realized that after the Cloud.Users.login method I was wrongly calling the method Cloud.PushNotifications.subscribeToken instead of the Cloud.PushNotifications.subscribe. Changing that, after the login and subscribe, the device has an user associated to it:

user associated to device

And everything works as expected, push notifications are sent and received.

EDIT: I didn't notice that hovering the Failure label showed you the reason (a little weird way to show info), and the reason in fact was somewhat explained in there:

error message

Alberto M
  • 1,608
  • 1
  • 18
  • 42
  • Still experiencing issues but I think it's related to http://stackoverflow.com/questions/35557691/push-messages-for-ios-error-code-1001-remote-host-closed-connection-during-h/36053980 – kenwen Apr 06 '16 at 12:12
  • have you tried to hover on the Failure label? I found that out from your link and it would've been actually helpful to know that. – Alberto M Apr 06 '16 at 14:35