SQL Database Design For Developers at php[tek] 2024
Push Notification - Part 1 - Transcript.pdf
1. Push Notification - Part I
Push is one of the more challenging tasks on mobile, the first time around it’s an uphill battle because it’s just so darn confusing and alien. However, once you understand
the underlying logic and platform oddities it becomes simple.
2. We’ll start with GCM by going to https://developers.google.com/mobile/add where we need to be logged in with our google account. Here start by clicking pick a
platform for which we select Android. While GCM has some support for iOS it is not native support and we use the native iOS push servers directly instead.
3. Now we need to paste the package of the application so Android can properly identify the right caller. You are prompted to create the package if the app doesn’t exist
yet. Notice the term app in this case refers to the server side logical application in googles cloud not to the client side Android native application…
After we finish this we can press choose and configure services this opens a prompt after a “short” wait…
4. We can either share or not share service data that’s up to you and we can the proceed to the final stage of creation of the app which also entails some waiting
5. In the final stage we can activate cloud messaging this provides us with two important keys one a long string and the other numeric…
6. You need to keep both values for later as we will need them to send and receive push but first we need the value from the sender ID
7. We need to launch the Codename One Settings application and go to build hint.
8. Here we can add the gcm.sender_id build hint and place in the sender id that we got from Google. Once we do that the Android portion of registration is done, we’ll still
need some of these values in the code but we finished the configuration portion for Android
9. In the iOS side we need to run the certificate wizard because push needs special certificates of its own. But first you need to make sure you are logged in with a pro
account or higher within the preferences UI, otherwise you won’t be prompted for push details
10. Once we login to the Apple developer account we can move to the next step
11. We pick or add devices, I tinted the device list a bit for privacy and then we move to the next stage
12. This is a very important and confusing concept in the certificate wizard… If you don’t have a certificate or it’s the first time around you won’t see this dialog but if you
already have a certificate and it’s working for you should normally answer NO!
That’s important as revoking the certificate would mean it would stop working for your other apps and if you have more than one Codename One app on the same
account it’s probably not what you want.
If you already have a P12 certificate for iOS you need to reference it from this project. A provisioning profile will be generated with reference to the existing certificate so
it’s important to get all of these pieces right.
13. This is a very important and confusing concept in the certificate wizard… If you don’t have a certificate or it’s the first time around you won’t see this dialog but if you
already have a certificate and it’s working for you should normally answer NO!
That’s important as revoking the certificate would mean it would stop working for your other apps and if you have more than one Codename One app on the same
account it’s probably not what you want.
If you already have a P12 certificate for iOS you need to reference it from this project. A provisioning profile will be generated with reference to the existing certificate so
it’s important to get all of these pieces right.
14. Assuming this is the case you will probably get prompted again for the debug certificate as iOS has two certificates for debug and production. Everything we said about
the production certificate beforehand applies here in exactly the same way.
15. We now get this form, naturally I chose not to generate the certificates so it says so on top but the important piece here is the enable push checkbox that we must
activate. If this checkbox isn’t here then you aren’t logged in with a pro account!
Once we finish and press save the certificates should be generated, we should also receive an email with instructions and URLs explaining how we should integrate
push.
The email should contain URL’s in the cloud for 2 push certificates which are also generated to your local filesystem under iOS certs. These URL’s are important when we
need to send the push message.