Anvil PWA to Native App - asking for push notifications permission?

This is kind of a long shot, but I was wondering if there is a way to interface with the device’s (if the app is running on a device) native notifications permissions dialog?

Similar to how we do with navigator to open a Share menu if there is one available:

from anvil.js.window import navigator
...
      if hasattr(navigator,'share'):
        navigator.share(share_data)
...

My thinking is that this would be useful for those of us who have built PWAs using Anvil, and wrapped them into a native app via something like PWAbuilder.

It’s possible to bring up that dialog at runtime by modifying an iOS app’s AppDelegate file and calling requestPermission, however it would be nice to have the ability to trigger it based on some user action in the Anvil app, like after a user creates an account.

I suppose the question is whether it’s possible to call iOS (or Android) native API, if available, from the Anvil app?

2 Likes