From 6434f36f1af450b9c3d642369c41de6cacbd55e6 Mon Sep 17 00:00:00 2001
From: Godwin Asuquo <godilite@gmail.com>
Date: Tue, 10 Jan 2023 18:14:26 +0100
Subject: [PATCH] update webview permission implementation

---
 lib/main.dart                          |  2 --
 lib/src/screens/buy/onramper_page.dart | 16 +++++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/main.dart b/lib/main.dart
index f93eed545..056d7b1d7 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -11,7 +11,6 @@ import 'package:flutter/services.dart';
 import 'package:hive/hive.dart';
 import 'package:cake_wallet/di.dart';
 import 'package:path_provider/path_provider.dart';
-import 'package:permission_handler/permission_handler.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 import 'package:flutter_localizations/flutter_localizations.dart';
 import 'package:flutter_secure_storage/flutter_secure_storage.dart';
@@ -45,7 +44,6 @@ final rootKey = GlobalKey<RootState>();
 Future<void> main() async {
   try {
     WidgetsFlutterBinding.ensureInitialized();
-    await Permission.camera.request();
     final appDir = await getApplicationDocumentsDirectory();
     await Hive.close();
     Hive.init(appDir.path);
diff --git a/lib/src/screens/buy/onramper_page.dart b/lib/src/screens/buy/onramper_page.dart
index 1eb052f74..72fe59eee 100644
--- a/lib/src/screens/buy/onramper_page.dart
+++ b/lib/src/screens/buy/onramper_page.dart
@@ -1,4 +1,3 @@
-import 'dart:io';
 import 'package:cake_wallet/generated/i18n.dart';
 import 'package:cake_wallet/src/screens/base_page.dart';
 import 'package:cake_wallet/store/settings_store.dart';
@@ -73,12 +72,15 @@ class OnRamperPageBodyState extends State<OnRamperPageBody> {
   @override
   Widget build(BuildContext context) {
     return InAppWebView(
-          initialOptions: InAppWebViewGroupOptions(
-            crossPlatform: InAppWebViewOptions(transparentBackground: true),
-          ),
-          initialUrlRequest: URLRequest(url: Uri.tryParse(widget.uri.toString(),
-        ),
-      )
+      initialOptions: InAppWebViewGroupOptions(
+        crossPlatform: InAppWebViewOptions(transparentBackground: true),
+      ),
+      androidOnPermissionRequest: (_, __, resources) async {
+        return PermissionRequestResponse(
+          resources: resources,
+          action: PermissionRequestResponseAction.GRANT,
+        );
+      },
     );
   }
 }