I already have a working Ionic 2 app with a PHP backend on my own server.
I recently added the Ionic.io Cloud framework to enable the Deploy functionality. Since I’m now working with Ionic.io anyways I thought I would use this as well to implement Push for my app.
Now I’m wondering if it is possible to send push notifications to a specific subset of users without authorising them with Ionics Auth first? Since I already have authorisation via my PHP backend I don’t really see the point why authorising twice.
But I don’t find a way how to store user details like a user ID or email address in another way than via Auth. Is there any chance?
I didn’t find any good way to do this through the ionic.io API so I had to handle it on my end.
The Ionic IO cloud framework allows sending push notifications to a targeted set of tokens. If you look at the POST format, it takes string token, which is the device tokens of the users you want to send to, otherwise you can use send_to_all.
When the user logs in to your application, use the push.token service on the device to snag the token, and the username, and send them to your own backend, then you have their device token and username associated together. When you go to do a push notification, just send a list of tokens to the push service for the users you’d like to get the push.
This is very unfortunate. But using the API to send those notifications seems like a good idea. Thank you very much.
I also had another idea. Basically after login through my own backend I use the email address of the user with a standard password (same for all users or a hash of the email or so) to “authorise” with the ionic.io service. Then I store user specific data like the user ID in that dummy user just to locate the correct push ID.
What do you think?
If you were going to go through all that, you may as well setup their custom authentication, and just authenticate the user with the Ionic.IO services, through their integration service. It can use your database / authentication scheme without trying to work “around” it.
Awesome! I didn’t know that there is a custom authentication service. Seems a bit of work though. But definitely a good option. Most likely better than the work around I came up with