OneSignal push registration prompt flow
Back to All

OneSignal push registration prompt flow

After I have prompted iOS app user for their consent to send them push notifications, I would like to save to my websites database their subscription details, including whether they granted permission or not.

In an ideal world I could provide gonative.onesignal.register() a callback function, which would receive user's decision as a parameter. However this function does not seem to support callbacks.

If gonative.onesignal.register() function was blocking (as for example window.alert is in browser), I could add some code after it, knowing that user has answered the prompt (e.g reload the page and from gonative_onesignal_info see user's subscription status). However it is not blocking, so any Javascript code following calling this function is executed immediately.

Do you have any recommendations how to best solve this problem? Could I somehow use gonative://nativebridge/multi command to chain my custom function, that would be called only after user has answered the prompt? Any other ideas?

Thank you