Hi, I’m following this tutorial here and trying to use Pusher to send a notification to my app. I’ve followed all the steps and have the certificates (the images in the tutorial are somewhat out out date) and all works fine for the sandbox env, but when trying production I get:
Notification error: APN invalid token size
I’m guessing it’s because I don’t have a valid token for prod - where do I obtain this? Do i have to generate this myself on a running release instance and then get the token back to myself so I can use it to send a message??
Additionally, according to the tutorial:
handleNotification() callback function will be invoked whenever a user presses on a notification.
I don’t see this behaviour; for me, handleNotificationAction() gets triggered under this circumstance.
Looking at the code, handleNotification() should be called when receiving a local or remote notification, but this never seems to actually get called (nor the corresponding didReceiveRemoteNotification() or didReceiveLocalNotification() calls).
ok, i think i’ve misunderstood notifications. I assumed an app had an id and a notification could be sent to that id, but from reading Apple docs it seems that:
- each device has it’s own token for each app
- it’s our responsibility to store these tokens somewhere, e.g. in our own online db
- we have to develop our own software to then send a notification to all registered tokens
this seems crazy so I think I must have something wrong here…
bump. would be grateful if someone who has implemented push notifications on iOS could confirm/deny my appraisal above before I start implementing.
A token is generated by APNS and it is only valid either for development (testing) or production (release). One can not use the same token for both production and release. If you run debug builds, you will get development token which you can use with development certificate (sandbox
env). When you make a release build, you should get a different token, for which you need to use with production certification (not for sandbox env).
To send a notification you either write an app to do it yourself, or you have your own server to do it, or you use 3rd party service like Firebase. If you integrate Firebase SDK, then you can send notifications from Firebase console (or you can send HTTPS request to firebase endpoint directly).
Thx for the info.
I’ll look into firebase - this all seems like a hell of a lot of work to send a message to an app - still confused at the fact that an app doesn’t have an ID - don’t understand why the devs would expose us to having to manage multiple IDs when a single ID for an app would do…
A lot of the config has to do with user security, ensuring people don’t start receiving random spam. The two tokens/certificates are so that one can test the app while in production without bothering real users. There is some initial setup required, but then it
Does Firebase handle iOS and Android?