GCM replies success to server, device not getting message - ios

I am developing a sample app for iPhone to receive GCM messages. It registers successfully, getting a registration token. Using this token I submit a message to GCM server with it replying success. This has no visible effect on the phone or in the app.
This is true if phone is on, access code entered, both with app running or not running.
What I already checked/tried:
SenderID, registration token, server auth key are correct. Also tried to reinstall app to get new registration token, problem persists.
Put trace logs into all callback functions, the ones about registration are called how I expect them to be called, the ones about receiving messages are silent.
Tried it on wifi and GSM network too, same.
Attempted to find a solution here on stackoverflow.
I couldn't check but I am quite confident that there are no ports blocked on wifi.
What can possibly be wrong? Any ideas what else I am to check?

Related

Retrying firebase token in Swift

I come bringing a query about Firebase in Swift. My app configures Firebase and thus gets the firebase token upon launching. I store the token with no issues and go ahead.
But... What happens if the user launches the app when his device is offline? The app tries to retrieve the token, but fails because there's no internet connection. It tries up to five time and then stops trying.
The app is also locked in the login screen because to be logged you need to have Internet.
Imagine if after the five tries, the device finally gets a connection, and the user logins and enters the app. But I don't have a firebase token and I can't send notifications to the user until he restarts the app!
Can I somehow retry the firebase registration if the user logins without a token?
Thanks a lot in advance.
You don't have to solve a problem that isn't actually a problem. A push token won't always get refreshed. Here's the description of Firebase's didReceiveRegistrationToken.
This method will be called once a token is available, or has been
refreshed. Typically it will be called once per app start, but may be
called more often, if token is invalidated or updated.
Furthermore, like Firebase said, once you this method gets invoked, take advantage of it and store the token in your server! When the user starts your app without internet connection, don't worry about it. The user has probably saved the token onto your server. And if the user starts your app for the first time, and without the internet connection, don't worry about it too. He'll get a new one in the next run.
I hope this helps.
After googling more further, I've found that calling InstanceID.instanceID().token() does trigger a new retry to get a FCM token if your current token is empty, and returns your current token if you have one.
I've added that call when the user successfully logins, so that the app can atleast try to get a FCM token again.

Twilio incoming calls not working for iOS

I'm really lost here.
At first, all calls between iOS-Android, Android-iOS, Android-Android and iOS-iOS, was working. Even so I still was getting errors like:
52143 - The push notification was rejected by APNs
52134 - Invalid APNs device token
But since was woking I ignored those errors.
Now, I had to change the client app to a new account - Apple and Google. And all start to fall apart.
I've already lost how many times that I deleted and create all the Apple Certificates and upload them to my Twilio account.
Right now, I have VoIP Apple Certificate working on production only from iOS to Android calls, but still getting those creepy erros.
And, if I run my APP and API all in LOCALHOST with the same Twilio Config and Apple Certificates, it all work beautiful except for those erros (52143,52134) that keep coming.
So... what could I be missing here?
This could be related:
https://github.com/twilio/voice-quickstart-objc/issues/33
https://github.com/twilio/voice-quickstart-swift/issues/34
https://github.com/twilio/voice-quickstart-objc/issues/115
https://github.com/twilio/voice-quickstart-swift/issues/142
https://community.clevertap.com/t/ios-error-apnsdevice-token-not-for-topic/545/3

Ejabberd offline messages

I have set up a chat server with Ejabberd, It is working fine. Messages are getting sent from one user to another user. Problem is that when the receiving user is offline, Sender messages should get stored and get delivered to receiver when he comes back to online. But offline messages are not getting delivered. I have not changed anything in configuration file because it looks already configured for the offline storage and offline message delivery. Do I need to make any other changes apart from the below lines?
ejabberd.cfg:
{access, max_user_offline_messages, [{5000, admin}, {100, all}]}.
{mod_offline, [{access_max_user_messages, max_user_offline_messages}]}
Please update your ejabberd from 2.1.10 to 16.10, as you using the older version certain func. may not work as expected.

push notification DB managment

Im about to use GCM for android and APNS for ios in my app.
on my server side I save in my DB the device id and account id each login.
When the user logs out I delete that entry, so the user wont receive it any more (and even if it logs in with a different account on the same device)
The scenario im thinking about is when the user uninstalls the app while he is still logged in. That means the user didnt go through the logout request, which is the request that deletes the device id entry on my DB.
Now the user installs the app again but logs in with a different account.
In my DB i'll have the same device id with 2 account ids, which means the user will get push notifications that does not belong to him (his device will keep getting notifications for the previous logged account).
To my knowledge android got device id for each app "instance" so I dont have a problem here (even though a message will be sent to a ghost device which is weird), but on ios I know the device Id you send to apns is unique to each device...
Bottom line -
Did I get anything wrong?
Solution I thought about is setting timeout for device same as the login timeout (still the interlaced time will get notifications from 2 accounts)
Still this problem look very trivial and that must be a cleaner solution.
For iOS, an approach would be to add a key to NSUserDefaults to check if the app is on its first run or not.
On successive runs, if the above key is present, you do nothing since it isn't your first run. If the key is not present yet ( first run after install ) you send a request with the deviceid, which removes the current deviceid from your server DB with all its logged in entries. You set the key to true, then you can proceed to normal login.
This will only work if the deviceid doesn't change between installs.
I guess there is a similar mechanic for Android too.

XMPP client network failure and Openfire offline message

I have configured XMPP client (iOS) and Openfire , everything works just fine except that i am not able to handle the following situation.
iOS client disconnects because of network failure.
User is still logged in on the server because there is no way to disconnect(no network).
Further messages are not stored in server because server thinks that the user is still logged in. Hence the messages are lost.
Unable to send push notification by sender because the receiver(User) status is still online ( no network to send presence ).
How can i solve this issue?
I found a solution, not sure if it is efficient.
In Openfire admin portal, under Client Connection Settings->Idle Connections Policy, there is an option to disconnect the client if it is idle for x seconds. By default it is 360 seconds, i have changed it to 5 seconds so that the messages won't get lost.
I am not sure if its a good idea to ping the clients every 5 seconds.

Resources