0

I got an app that only contains a webview, pointing to a site with a login screen. The users of the app should be able to get notifications, but only if they are authenticated (logged in to the site in the webview). Is there any way to tell if the user of the app is authenticated to the website in the webView? Any way for the app to know if the user clicks the login button in the webview?

I know that we can override OnReceivedHttpAuthRequest in a custom renderer, but this is not triggered by the login screen of this website so it doesn't work in this case.

Any suggestions?

SomethingElse
  • 97
  • 1
  • 12
  • Registering with FCM, you can do that even before you login using webform and get your FCM registration id/device ID. When submitting the webview form add more data like you are submitting the form from your app with your Device ID. If the login get success in backend, then backend should start sending the notification to that device ID that you logged in from. – N Subedi Sep 23 '19 at 13:25
  • If you create the website yourself, you can try [invoking-c-from-javascript](https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview#invoking-c-from-javascript). Look at [this](https://stackoverflow.com/questions/51430238/calling-a-c-sharp-function-through-javascript-onclick-event-in-webview-in-xamari) may help too. And the second option is to send the notification to those specific device who login successfully instead of all users. – nevermore Sep 24 '19 at 01:51
  • But if I have no control over the backend, is there any way to see what response I get in the webview, what content is currently shown in the webview etc, see if the authentication in the webview was successful? – SomethingElse Sep 24 '19 at 06:09
  • Can you get control of the website? If so, you can try my suggestion of invoking-c-from-javascript. – nevermore Sep 25 '19 at 07:40
  • @NirmalSubedi But how do the app know when the submit-button in the website, that is in the webview, is pressed? How do the app know if the login, after pressing the submit-button, is successful? That is the problem, if we solve these questions I can just subscribe to a topic when the login is successful – SomethingElse Oct 08 '19 at 07:44

0 Answers0