RocketChat / Rocket.Chat.Cordova

Rocket.Chat Cross-Platform Mobile Application via Cordova (DEPRECATED)
MIT License
104 stars 109 forks source link

Push Notifications not working #38

Closed Morgul closed 8 years ago

Morgul commented 8 years ago

I'm attempting to get push notifications working, and after figuring out what seems to be a correct setup, I still don't get push notifications. Checking the console when the cordova client connects, I see this in the logs:

rocketchat-1 | 2015-11-29T22:15:23.763943119Z CLIENT error [ { type: 'gcm.cordova', error: 'No value for senderID' } ]

For posterity, here is my configuration:

image

Is this a problem with the latest beta, or maybe my configuration?

pschonder commented 8 years ago

I got issues with push notification under iOS. When i have a look into mongo there is an token for my device in the collection "_raix_push_app_tokens", but no "userId" is assigned to it. It's null. It seems, there is no update to the device-token after login.

Possibly https://github.com/RocketChat/Rocket.Chat/commit/bf0008f820d7111906a738dcf14aa4b1fe27b37c broke it.

@morgul: Have you tried adding a file called "_www/js/android_sender_id.js_" to your Cordova-Project with content like

window.ANDROID_SENDER_ID = "XXXXXXXXXX";

I was getting an error that it was missing in my project after a _git pull_ and _cordova prepare_

Morgul commented 8 years ago

@pschonder I'm not building the Cordova app myself, I'm using the beta published on the Android Store. I strongly support a single application that can connect to any instance of Rocket.Chat, and as such have avoided building the app myself.

pschonder commented 8 years ago

@rodrigok have you seen my comment?

rodrigok commented 8 years ago

@Morgul we will investigate that.

@pschonder are you trying with iOS or Android?

pschonder commented 8 years ago

@rodrigok I'm using a self built iOS app with my own server. The iOS-App is built with my own Provisioning-Profile and my own Certificate added to the Server Push Settings for APN. If I update the collection-entry in "_raix_push_app_tokens" and change the field userId from "null" to my userId the Push-Notification is delivered to my device. It seems there's something broken when updating the registered device-Token with the user which is logging in.

Is it possible https://github.com/RocketChat/Rocket.Chat/commit/bf0008f820d7111906a738dcf14aa4b1fe27b37c broke it?

pschonder commented 8 years ago

After some further investigation i noticed some strange behavior:

After the App is synced with the server the Client-Token is saved in the collection:

Push: Settings userId "null" for app: sebjtoMBBysMYb3ej
CLIENT token [ { apn: '16cb78dee0f3849e9fdefc744f9523716e82246f4d670fc7d4310486e0078dfc' } ]
Push: Got push token from app: { id: 'sebjtoMBBysMYb3ej',
  token: { apn: '16cb78dee0f3849e9fdefc744f9523716e82246f4d670fc7d4310486e0078dfc' },
  appName: 'main',
  userId: null,
  metadata: {} }
Push: updated { token: { apn: '16cb78dee0f3849e9fdefc744f9523716e82246f4d670fc7d4310486e0078dfc' },
  appName: 'main',
  userId: null,
  enabled: true,
  createdAt: Wed Dec 02 2015 18:42:04 GMT+0100 (CET),
  updatedAt: Wed Dec 02 2015 18:42:04 GMT+0100 (CET),
  _id: 'sebjtoMBBysMYb3ej' }

When i finish the login the Client-Token is not updated. I stopped the App with x-code and startet it again:

Push: Settings userId "z8sLJTnuBY4b367jR" for app: sebjtoMBBysMYb3ej
CLIENT token [ { apn: '4a1ff3ed573953504d8c02d0c9162dc47c046049abf9e064459e1fc8baf5b0cc' } ]
Push: Got push token from app: { id: 'sebjtoMBBysMYb3ej',
  token: { apn: '4a1ff3ed573953504d8c02d0c9162dc47c046049abf9e064459e1fc8baf5b0cc' },
  appName: 'main',
  userId: 'z8sLJTnuBY4b367jR',
  metadata: {} }
Push: updated { _id: 'sebjtoMBBysMYb3ej',
  token: { apn: '16cb78dee0f3849e9fdefc744f9523716e82246f4d670fc7d4310486e0078dfc' },
  appName: 'main',
  userId: 'z8sLJTnuBY4b367jR',
  enabled: true,
  createdAt: Wed Dec 02 2015 18:42:04 GMT+0100 (CET),
  updatedAt: Wed Dec 02 2015 18:42:04 GMT+0100 (CET) }

The token is updated now. This is not the right behavior in my opinion.

pschonder commented 8 years ago

and there is another strange behavior: The badge "1" at the app icon is not cleared when all messages were read.

pschonder commented 8 years ago

@rodrigok is there any progress on this issue. Can you confirm the problems?

rodrigok commented 8 years ago

Yes, I did some changes 2 days ago, I need to do a new test.

@pschonder, can you test these changes too?

pschonder commented 8 years ago

@rodrigok seems to be working now. The Badge with "1" is still there, even when all messages are read or when there are more than one unread message.

rodrigok commented 8 years ago

Ok, I will take a look, thanks

rodrigok commented 8 years ago

@pschonder was fixed in our server code on branch develop.

russcalderon commented 7 years ago

@rodrigok how did you get this fixed? It is definately the biggest issue we have with iOS.

rodrigok commented 7 years ago

@russcalderon What is your issue? Which version are you using of mobile and server? Do you receive notifications when you click to test?

russcalderon commented 7 years ago

@rodrigok the rocketchat server ver. 0.35.0 and iOS 9.3.3. I do get the notifications just fine. We are just not able to get clear the 1 count message badge. If i exit the application it will clear it but them it will be ok until it gets stuck again. We are primarily iOS users but those with androids are clearing just fine.

russcalderon commented 7 years ago

@Rodrigok you know actually issue #3618 is more relevant than this ticket, i have posted a comment on it.

RichardFoxworthy commented 7 years ago

@russcalderon is this still an issue for you with the count on the app badge not resetting?