braze-inc / braze-expo-plugin

Other
11 stars 10 forks source link

[Feature]: Return a promise and success or push token from Braze.requestPushPermission(); #24

Open Mikiah opened 11 months ago

Mikiah commented 11 months ago

What problem are you facing?

Working on a React Native Expo Go app for Walmart. Using my personal account here since Walmart uses on-prem github. We have onboarding flow where the user is push primed then given the OS-level prompt from Braze.requestPushPermission(), and once that's completed, sent along the onboarding flow.

Without Braze.requestPushPermission() returning a promise, we can't wait for it. so the user is shown the next onboaring screen prematurely.

Workarounds

The only way around this that I've found is a a setTimeout of about 5000 ms. Super hacky and obv bad UX. I thought you might have listeners I could subscribe to. Something like Braze.addListener('pushPermissionChange', onPermissionChange); but that doesn't seem to be the case either.

Ideal Solution

Either return a promise and success message (or the token) or some kind of listener we can use.

Other Information

No response

jerielng commented 11 months ago

Hey @Mikiah, thanks for raising this! Could you file your feature request here, and our product team will take a look into how we can support this? Thank you!

Mikiah commented 11 months ago

Done. Thank you for the quick response!

jerielng commented 11 months ago

Sure thing. By the way, since push permissions are at the app level, you should also be able to do this at the native layer without having to set a timeout in your JavaScript code.

For example, in Android, you can request for the current permission settings at runtime, and likewise for iOS as well.