I am developing an app that matches users in Kik based on interests. Kik users can chat with a bot that I wrote, and then the bot links them to a page in the web app based on their interests.
Kik provides us with this javascript (which I have documented here in coffeescript) to check if a user has authorized the app to access their user data, via the Kik api:
if kik.enabled
kik.getUser (user) ->
if user
This works, but it necessarily combines both features into one. That is, checking if a user is authorized and prompting a user to authorize both trigger when kik.getUser
runs.
This is problematic because my web app should have different features depending on whether or not the user has authorized, one of which is providing the user with a 'check-in' button that prompts them to authorize if they have not.
Does Kik provide separate methods of checking whether or not a user has authorized?
Furthermore is there any way of identifying the actual authorization event with JS (i.e. the user actually pressing the 'yes' button, which closes the window that asks for authorization)?
Can an already authorized user be 'unauthorized', and if so, is there a way to recognize when this happens?
A potential work around is to store an "authorized" boolean in my database of users (or, rather, only generate a user in the database if they have authorized), and only run kik.getUser for users that have flagged as authorized. This could, however, not work if a user can become 'unauthorized'.