Thank you for the replies.
@owen.campbell The reason for this is two-fold, but related to the fact that I need access to the native device hardware:
- I need to access the device camera, to take a picture of a QR code when the user presses a button.
- I need better push notification integration with the app, for example to send notifications only to X user when Y action is taken. I am using OneSignal to manage client engagement, and how I integrate this with my app is as follows:
a) I wrap the Anvil PWA as a native app with PWABuilder, exporting the source code for both iOS and Android app.
b) I integrate the OneSignal API with each “native” app according to the OneSignal guide, in XCode and Android Studio.
c) I submit each “native” app the App Store.
The Android app is by default a TWA, which allows much tighter integration of push notifications between a PWA and the native app - for example, I could integrate web push into my Anvil app, and that would trigger a “native” ‘Grant permissions for this app to send notifications?’ popup in the native app, allowing me to send push notifications to the device.
The iOS side is more difficult, because in order to send true push notifications (that will work even when the app isn’t running, for example), you need to have an iOS developer account, create a key and certificate signed by you for the app, and this is not connected with the browser’s web push. (By default, a PWA wrapped as an Android app will run as a Trusted Web Activity, with more privileges than if it is a WebView. But iOS does not have something like a Trusted Web Activity, all PWAs wrapped as a native app would run in a WebView, and it is much more locked down than a TWA on Android - anyone with more knowledge than me is welcome to correct any inaccuracies I’ve stated here).
When I integrate OneSignal API with my wrapped “native” app, I am unable to engage with the user’s actions inside my Anvil-app-running-as-a-TWA/Webview. All I can do is make the native device prompt pop up when the user opens the app for the first time “Do you want to allow this app to send notifications?”. After that, if the user says “Yes”, I can send true native push notifications to that device from the OneSignal console, however they are very limited - I can only send a push notification with a message and image, and when the user clicks on it, the app opens. I cannot tell my Anvil PWA, “Hey, the user just clicked the push notification, so open up Form X, or display some text now.”… there is zero communication between the Anvil app and OneSignal. There are a lot of features in OneSignal that are/would be very useful to increase user engagement, like “in-app messages”, which are popups in the app that display some additional information, or suggest an action, like “Rate us in the app store” and then supply a Call To Action button that would open up the app store on that device, if available.
The other big problem is that I have no way of knowing which user of my app is which user in the OneSignal console. The OneSignal console shows me a list of all the devices/users that have opted in to receive push notifications, so I could send a mass push notification to everybody, “Hey, there’s a sale on, click here”, but I don’t know what registered user that is in my Anvil app (if it is a registered user) and thus I can’t target those devices appropriately.
So there’s a tremendous amount of opportunity here for increased user engagement, and there is a OneSignal SDK python library available in Anvil, but from what I can see it is only server-side calls, like programmatically sending push notifications to your users, which can already easily be done through the console. What we really need, I think, is a client-side OneSignal Python SDK, like the ones available for Android and iOS, that can communicate with the OneSignal service and respond to user actions and push notifications, do things like display their “in-app messages”, and be able to match the users in the Anvil PWA to the users in the OneSignal console. Then we’d get a really great native push notification integration with our Anvil apps and users who have installed wrapped PWAs on their devices.
Sorry for any inaccuracies in my description, this is the best of my understanding so far having worked with PWABuilder-wrapped Anvil apps and OneSignal for native push notification.