I have application which receives APNs from my server periodically. It calls registerForRemoteNotificationTypes at start and then reasking it periodically (while working). It correctly receives device token and sending it to backstage server for later use.
But there is a problem:
- after app is started, it correctly recieves all apns sent from my server via device token generated by iphone at app start.
- but when app stays in background (without any restarts) for like 8-12 hours it stops to recieve anything
- by checking app/server logs i see that app properly reasks for new token via registerForRemoteNotificationTypes periodically, properly receives exactly the same token it has from very start, backstage server continue to use it for sending apns and sending them to apple without any errors via socket
- but messages simply not showing on device any more, didReceiveRemoteNotification not called at all
- Exiting app manually and restarting it helps - registerForRemoteNotificationTypes return another token, which works very well - server uses it for sending apns and device immediately receives them, as expected.
so it seems like iphone reasking apple server for token only at app start and then hard-caching it. but token still have something like a ttl period.
is there any way to force iphone return fresh, actual device token every time app asking for it? how to force iphone to recheck device token on apple server to be sure it is really ok and healthy?
please help!
UPD: managed to narrow down problem
- app in question using sandbox apn environment (since we are developing it)
- i changed APN sending procedure to extended protocol and now see that after some time aplle sandbox server starting to reply with error 8 - invalid token. at the same time device receiving the same old token from registerForRemoteNotification. so there is definitely a problem with refreshing token by iOS
after switching from sandbox environment to production one - problem is gone.
so there is a difference between sandbox and production gates: device token ttl in sandbox environment is much shorter than in production. still, device token on the phone itself is the same for both environments. so using sandbox environment makes this problem - phone returns invalid (already invalidated on server) device token for application
Related
I followed the instructions in the Rocket.chat documentation:
Removed the check mark from the gateway
added GCM keys from firebase
rebooted the server
Pushs seem to come, but the listener "pushnotificationreceived" is triggered only if I open the application immediately after the push should come or I am in the application during the push, if I have minimized the application and send myself a message, then there is no push.
If I throw the push myself through the firebase API, then the push works out as needed.
There is a suspicion that this is due to the fact that Rocket.chat sends push data in the data key, not notification (https://github.com/RocketChat/Rocket.Chat/blob/develop/app/push/server/gcm.js).
I also have an error in the Rocket logs.Chat:
"For devices running Android 8.0 or later, you need to specify the android_channel_id identifier. See https://github.com/raix/push/issues/341 for more information", but even with this error, push writes that it was sent successfully.
Please, checkout this post:
https://forums.rocket.chat/t/apple-push-notification-service-update-from-legacy-binary-protocol/12425/4
Also, consider asking dev questions at:
https://open.rocket.chat/channel/dev
I am sending Push notification messages from my asp.net web site to Android and iPhone.I am using push-sharp version is 2.1.2.0-beta lib.I can send push notification messages successfully and having status log for each message along with there Device ID.
I found more that 100 device which was having DeviceSubscriptionExpired(PushSharp Event). I check those devices on my database, i found those same device id was successfully on the same day.I am suspecting that those devices are not expired but DeviceSubscriptionExpired event is fired for some reason or apple and google server responding with Subcription expired.
I can't figure it out why it is happening. Can anyone please suggest?
Note: My apps are designed such a way that it will request device id on each application start and update the latest device id if it is changed.
Maybe you are using a developer certificate, you should check you are using the production if you are sending push to production apps.
We have a table containing apns device tokens on our servers and due to unforeseen circumstances lost all data, including backups. In order to send push notifications we need to send device tokens along with message, since we lost all the tokens, is there any way to get them through apple/ application ? I'm pretty clueless on how to proceed further, any help is really appreciated
There is no API that gives you the device tokens for which your app registered to APNS.
Assuming that your app doesn't send the device token to your server every time it is launched, you'll have to release a new version that would send the device token to the server. Then you'll get the device token of every user who installs the updated version and launches the app. You won't recover the tokens of users who don't install the update, but there's nothing you can do about it.
I hope you have better backups next time.
once i submitted app to app store by enabling push notifications for that particular app id and i generated the certificate fro production and i saved in my server.
now i want to test my push notifications are working or not,now my doubt is if i use the same bundle id for my another project and keeping the same certificate which i generated for production apns on my server. if i send notifications now to that certificate will notifications work or won't work. i was confused totally after having lot of discussion with my friend.
in my point of view they won't work,but i am unable to clarify him clearly,let me know what is process once we send a notification to apple server by using particular certificate. whether it looks fro bundle identifiers or any thing
thankyou......
The process of push notification is that your server send message with the attachment of device token you added in the server end.
On apple server apple fetch the device token and send the message to the device token you send.
Now when the message received in iPhone, iphone check the bundle identifier that was registered with the certificate you have created at server level while enabling push notification.
And if that identifier matches with any of the app you have in your iPhone whether it`s the same app you have registered your push or other. It will only check the bundle identifier and show the notification on your device.
Now both the production and developer certificates are different so it will not show the notification if you are sending push from certificates generated with developer mode and checking on production application.
Regards
Abhishek Goyal
I have an app set up to generate passbook passes. The successfully install on the device and I can do manual (pull-down) updates.
Next I began to implement APNS. I'm using the enhanced request method to connect to the production environment, sending in an empty payload (as required) and it returns no error codes when I request a push notification, but my pass never updates and I see no requests hitting my server. I'm using my own device to test until I can get see an update for myself. No pass updates are received.
I then implemented the Feedback service in the hope that it might tell me something. I noticed this. If I pass in the push token, I receive a response which indicates that the device is not receiving notifications (even though the pass is set for automatic updates). The pass is not updated.
I'd appreciate any info into why the the push notifications do not seem to be arriving.
Thanks.
-Erich
One gotcha to check is that you are not using the sandbox APNS server. All Passbook push requests should be sent to the live APNS server.
Try enabling the additional logging option from the PassKit section of the Developer Settings on your device then connecting your device to Xcode and monitoring the console as you send the push. If the push is received, then you should be able to see your device requesting the serials to be updated from your webservice and you should also see your server's response.
Assuming you send a serial and that it matches the serial installed on your device, you should then see the device requesting the updated .pkpass bundle.
If no push is received, try toggling automatic updates on and off while monitoring the device console. It could be that the device is not receiving a valid registration (201) response or that you are using a stale token - you'll be able to see these via the console.