2

I have created an mobile application by using Delphi XE7. The program sends push notifications via Kinvey and GCM. Upon installation of the APK for the first time, it sends one push notification, which is working correctly. For the seconds time(same APP on the same device), it sends twice, and third time, three times and so on. I have discovered the problem is caused by adding more IDs under Kinvey/users. So if I manually delete all the IDs and install the APK again, it will work fine.

Therefore, I would really like to know if the IDs can be cleared by itself upon new installation of APK on the same device.

Thanks in advance!

enter image description here

Agustin Seifert
  • 1,938
  • 1
  • 16
  • 29
Alvin Lin
  • 199
  • 2
  • 5
  • 13

2 Answers2

1

It seems that you are using the TBackendPush component not as it is designed for.

The "Backend" in the component name is a strong indication that the component must be used in a server-side application, which can trigger broadcast messages to all registered devices.

Placing it on the client side could cause unexpected results. Also by including it in the mobile app, you include the Kinvey account credentials in the APK file. The credentials could be extracted by others and then used to send messages from your Kinvey account.

If you need a way to send push notifications, there are two ways - however I don't know if Kinvey supoorts both:

  • send a single HTTP(S) request from the device to your own back-end server, which triggers a broadcast request to Kinvey/GCM
  • send an upstream ("device to cloud") message from the device to your back-end server as described in https://developer.android.com/google/gcm/ccs.html
mjn
  • 36,362
  • 28
  • 176
  • 378
1

I had the same problem. AFAIK the answer is no, installing a new APK or uninstalling the application doesnt unregister your ID from your backend provider (Kinvey, Parse, Azure notification hub).

My solution was to add a collapse_key in the gcm payload

Ps: In my case, Notification Hub has an expiration for registrations (I dont know if Kinvey has it too) so the push is received the same time as registrations have BUT collapsed so you just "receive" one until the older registrations expires

Agustin Seifert
  • 1,938
  • 1
  • 16
  • 29
  • So these providers have multiple registration entries for the same device stored, and send every message n times instead of once (where n is the number of times the client app has registered itself with the provider)? – mjn Nov 27 '14 at 14:36
  • Yes, the provider send one notification for each registration (or dependes in your logic, but takes broadcast for the example) so your device will receive n notifications where n = registration count (with same device ID associated). Adding a collapse_key, notifications will collapse into one – Agustin Seifert Nov 27 '14 at 14:38
  • The Google GCM example back-end server does not show this strange (inefficient) behaviour. It checks for an existing registration id first before adding the id to the list of known devices, so there will only one message sent to GCM and the device instead, this meas no need to use collapse_key and far less bandwidth usage. (I would consider it a bug if Kinvey stores a device id more than once) – mjn Nov 27 '14 at 14:42
  • Yes but those providers (Azure Notification Hub in my case) do not check this and send all the notifications – Agustin Seifert Nov 27 '14 at 14:44