sinch messaging APi Recieving duplicate messages - android

I am using the sinch.com's service for instant messaging but I recieve old messages anytime a user logs in or reinstall the app.
actually those messages have already been retrieved from their servers.. according to their documentation the messages are persisted only when the user is not online and also the persist the message for maximum of 30 days after when it will be deleted.

the issue might be the way you have implemented the sinch api. you can limit the IM retrieval only for certain time range. Can you share your code snippet or explain a bit more!

When you log out, our servers dont know that the messages have been delivered to that device. We keep messages for delivery for 30 days. AS a developer you will experience this more since you are wiping the install when you deploy.
If you just kill the app and launch it again you will see that its not delivered again.

Related

Push notifications arrive after a long time on some devices

On Android, I have been experiencing long push delay in some devices (minutes, half an hour). Seems like the device is asleep (but not for WhatsApp). Even on Pre-Marshmallow devices.
After a while they don't respond to push.
I have created a simple app (copied Google's Cloud Messaging client sample).
Tried to send push via The Firebase Console, setting priority to HIGH and made sure it works.
Experiment 1: After a while - tried to send. The device is not responding.
Experiment 2: Tried to use Telegram and WhatsApp. Message passes immediately on both.
Experiment 3: Tried the my test app again. Not working.
Experiment 4: Tried to downgrade from FCM to GCM and all the way to C2DM. Same thing, not working.
Any ideas?
To make it clear:
The token is okay. In most cases it works. It just falls asleep after a while.
It's a Lollipop device so no Power Saving exempts here or battery saving.
I use priority:high on the payload.
It is no server issue because I use FCM composer and it's just the same.
Waking the device does not necessarily fix it. It just begins to receive notifications minutes later and then all ok.
Other apps such as WhatsApp work without problem whatsoever, always.
I tried C2DM, GCM, FCM. I am using a printout on the C2DM receiver. They all behave the same.
I log everything. Every event, broadcast I get. I don't get push when I should.
Possible clue: some of my customers are using VMWare AirWatch. anybody know about any issues related to AirWatch and Push?
This is not a complete answer so I can't mark this question "Answered".
I found some alternative push mechanism called Pushy. It's mentioned quite a lot in Stack Overflow.
Pros:
I have made tests on a phone where FCM and GCM failed. Pushy succeeded to deliver all my messages, always.
It can work on devices with no Google Play Services enabled
It is also a workaround for the SERVICE_NOT_AVAILABLE issue.
They have a nice friendly console like in FCM, where you can send test messages.
You get a feedback when the message was delivered to Android devices.
Has topics like in FCM so you can send one message to a group.
Cons:
Money. It costs. Not too much. Last time I checked it was 0.5Cent per month for each active user. It may be a lot but my app is an emergency app so availability is a must in my case.
Does not have retries like FCM, as far as I understood. I may be wrong but it does not handle many things that FCM does. It may not do exponential back-off retries or Notification Messages A-la-Apple. I personally hate FCM behaviour on that so I am fine with this.

Firebase does not provide proof of the notifications been sent or delivered to the android app

When testing to the android app from the firebase console the status of the messages says completed and shows the delivery date. How do we check whether a message has sent to the receipts and delivered in an android app with fire-base: https://console.firebase.google.com?
I am working on a firebase quickstart app to test push notification message to my target users. Please help me.
#SaikCaskey have an insight of the solution of your question, though I do not agree on some points.
The push notification is not guaranteed to be received to your targeted user actually. Push notification might fail for several reason. But that's not the issue here. You might get notifications even if your application is in background or stopped. You need to start your FirebaseMessagingService with START_STICKY. This behaviour might differ in different devices too. Some devices allows/disallow this behaviour of receiving push notification when your app is stopped.
So, if you need to log when your user has received the push notification, you might get it in a bit complex way. When your device will come online you'll get the push and in your onMessageReceived function you can get the System.Clock for getting the time of notification received. Then create an instance of Firebase and then set the time to the reference node of the user's notification delivery time.
Hope that helps!

GCM duplicated messages

I have an app based on Google Cloud Messaging and it was working well. Now (today) all of a sudden it started having a problem we've never seen before. For each message sent between devices, the receiving device will get it twice. The first will arrive almost instantly (within less than 3 seconds of sending). The second arrives a few minutes later. There are two devices in the test, the problem is the same whichever one is the sender/receiver. So if a device sends a few message to the other, the other will get them pretty much instantly--but then at a later time, it will receive a barrage of messages which are the second copies of the messages it has received.
I have put in breakpoints to make sure that the sending device wasn't the culprit: the message was sent exactly once (i.e. the web service for sending was called exactly once--and the code for the backend, which runs on Google App Engine, hasn't changed for ages.) However, the message somehow gets delivered to the receiving device twice. By using breakpoints I also made sure our own code on receiving side isn't responsible: it is verified that GCMIntentService::onMessage() indeed gets invoked twice for each sent message.
We also made sure the registration id in our database is the latest. At this point I'm stumped and need ideas to make any further progress. So any ideas?
https://groups.google.com/forum/#!topic/android-gcm/EHZUTEJMeyw
Check the official GCM thread above. Everyone is experiencing this issue. Google's fault!
We also have the same problem, and we are sure we don't send the message twice.
It could be an issue related to what's explained here about "Canonical IDs": http://developer.android.com/google/gcm/adv.html
[...] However, if a bug in the application triggers multiple registrations for the same device, it can be hard to reconcile state and you might end up with duplicate messages.
Same problem here. We have many apps integraded with MyMalcom and Urban Airship and all of them are getting pushes twice since Monday. We have checked also the canonicalId changes as suggested by Ferran, but the delivered to GCM messages are ok (no cannonical Id changes).

C2DM to GCM code Migration

I have migrated my code for push notifications from C2DM to GCM. The only change I have made on client side is replacing the email account passed in the sender parameter of the registration intent with the project ID. The server side changes have been done too.
However, I experience a delay in receiving push while using GCM. The delay is like for 1 - 2 mins. I did not experience the same delay while using C2DM.
Please help!! Is this problem cause of GCM, or am I missing something.
I've set up GCM and pushes are almost instant. Couple things to check is that your server is sending it without a delay. And also that you are not spamming it, i noticed that after a certain amount of pushes in a small time period, and Google will start delaying pushes..
Other than that the only issue could be the GCM service and/also your phone. Make sure that your phone's radio is open at all times and you are using a stock OS. See if the problem is still happening in couple of hours so (in case there's a problem at the GCM servers)

Android :Get Online or Offline status through SERVER

I am creating a app in android 4.0.3 i.e ICS version, which connects to the server when client gets login into the app.I am trying to get status of an client when he gets online or offline through server & seen onto the app screen.I am unable to proceed. Can anyone say me:
Is it possible to get the status of an user through server?
1-- How to proceed for first step...?
2-- How should I get a response from the server that the client is connected & viewed to other client example - when we login into skype our status shows available with green radio button, In same way how can I get it.?
It ll be very help full, If anybody guide me.
Many Thanks..
I'm assuming you're trying to develop a chat app ?
If this is the case, try using an XMPP library. XMPP is widely used for chat apps, including Facebook chat (and Google talk I think) and there are plenty of open source libraries available.
Otherwise, if you only want real-time notifications as a part of a bigger picture, try using push notifications. Google supports Cloud to Device Messaging (C2DM) for android. It allows to have push notifications to a specific device without you having to deal with persistent connections, battery and CPU use .etc.
C2DM approach comes down to this. When a client connects to your server, get a list of his friends and their 'C2DM IDs' and fire a C2DM push to their devices. This push is delivered to your app, and you can respond to it by firing a notification, or update UI .etc. (Your app doesn't necessarily have to be running. Push notification is delivered via a specific broadcast, and your app can register a receiver for it to wake up.)
Keep in mind that there is a quota for C2DM messages per device, per app and also a limit for the payload per message. So you're not supposed to send massive files via this. Just a notification to your app, so it can call your server and get an updated list, instead of polling.
You can get more info on C2DM and code samples here. https://developers.google.com/android/c2dm/
Hope this helps.
You may have moved on, but I'm posting for anyone who would run into this one in the future.
Firebase is a good solution to use in this scenario, if the app is always running when you want communication to happen. (It will not wake up your app as C2DM/CDM does, unless you have a service running all the time and still wouldn't wake up if the device is asleep... AFAIK)
It may be useful for some scenarios, but may be not for a chat app as you want the device to wake up when a message arrives.
Note that they have limitations on the free subscription though.

Categories

Resources