Skip to content

Commit e79a471

Browse files
committed
fix iOS browser issue
1 parent 876dfd9 commit e79a471

15 files changed

+174
-60
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33

44

55
## [1.0.1] - September 14, 2021.
6-
* Fix bug where response is not returned to initiating screen when user cancels transaction.
6+
* Fix bug where response is not returned to initiating screen when user cancels transaction.
7+
8+
## [1.0.2] - September 23, 2021.
9+
* Fix bug where cancel payment buttons are not clickable on iOS devices.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Flutterwave version 3 API keys
4141

4242
In your `pubspec.yaml` file add:
4343

44-
1. `flutterwave_standard: 1.0.1`
44+
1. `flutterwave_standard: 1.0.2`
4545
2. run `flutter pub get`
4646

4747
<a id="usage"></a>
@@ -130,7 +130,7 @@ Create a `Flutterwave` instance by calling the constructor `Flutterwave` The con
130130
## Built Using
131131
- [flutter](https://flutter.dev/)
132132
- [http](https://pub.dev/packages/http)
133-
- [webview_flutter](https://pub.dev/packages/webview_flutter)
133+
- [flutter_inappwebview](https://pub.dev/packages/flutter_inappwebview)
134134
- [fluttertoast](https://pub.dev/packages/fluttertoast)
135135

136136
<a id="references"></a>

example/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.50'
2+
ext.kotlin_version = '1.4.32'
33
repositories {
44
google()
55
jcenter()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:4.0.1'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

example/ios/Podfile.lock

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
11
PODS:
22
- Flutter (1.0.0)
3+
- flutter_inappwebview (0.0.1):
4+
- Flutter
5+
- flutter_inappwebview/Core (= 0.0.1)
6+
- OrderedSet (~> 5.0)
7+
- flutter_inappwebview/Core (0.0.1):
8+
- Flutter
9+
- OrderedSet (~> 5.0)
10+
- fluttertoast (0.0.2):
11+
- Flutter
12+
- Toast
13+
- OrderedSet (5.0.0)
14+
- Toast (4.0.0)
315
- webview_flutter (0.0.1):
416
- Flutter
517

618
DEPENDENCIES:
719
- Flutter (from `Flutter`)
20+
- flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`)
21+
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
822
- webview_flutter (from `.symlinks/plugins/webview_flutter/ios`)
923

24+
SPEC REPOS:
25+
trunk:
26+
- OrderedSet
27+
- Toast
28+
1029
EXTERNAL SOURCES:
1130
Flutter:
1231
:path: Flutter
32+
flutter_inappwebview:
33+
:path: ".symlinks/plugins/flutter_inappwebview/ios"
34+
fluttertoast:
35+
:path: ".symlinks/plugins/fluttertoast/ios"
1336
webview_flutter:
1437
:path: ".symlinks/plugins/webview_flutter/ios"
1538

1639
SPEC CHECKSUMS:
1740
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
18-
webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b
41+
flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721
42+
fluttertoast: 6122fa75143e992b1d3470f61000f591a798cc58
43+
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
44+
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
45+
webview_flutter: 3603125dfd3bcbc9d8d418c3f80aeecf331c068b
1946

2047
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
2148

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,18 @@
241241
);
242242
inputPaths = (
243243
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
244+
"${BUILT_PRODUCTS_DIR}/OrderedSet/OrderedSet.framework",
245+
"${BUILT_PRODUCTS_DIR}/Toast/Toast.framework",
246+
"${BUILT_PRODUCTS_DIR}/flutter_inappwebview/flutter_inappwebview.framework",
247+
"${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
244248
"${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework",
245249
);
246250
name = "[CP] Embed Pods Frameworks";
247251
outputPaths = (
252+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OrderedSet.framework",
253+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Toast.framework",
254+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_inappwebview.framework",
255+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
248256
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework",
249257
);
250258
runOnlyForDeploymentPostprocessing = 0;

example/lib/main.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class _MyHomePageState extends State<MyHomePage> {
228228
subAccounts: subAccounts,
229229
paymentOptions: "card, payattitude",
230230
customization: Customization(title: "Test Payment"),
231+
redirectUrl: "https://www.google.com",
231232
isTestMode: isTestMode);
232233
final ChargeResponse response = await flutterwave.charge();
233234
if (response != null) {
@@ -239,7 +240,7 @@ class _MyHomePageState extends State<MyHomePage> {
239240
}
240241

241242
String getPublicKey() {
242-
if (isTestMode) return "FLWPUBK_TEST-X";
243+
if (isTestMode) return "FLWPUBK_TEST--X";
243244
return "FLWPUBK-X";
244245
}
245246

example/pubspec.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ packages:
6969
description: flutter
7070
source: sdk
7171
version: "0.0.0"
72+
flutter_inappwebview:
73+
dependency: transitive
74+
description:
75+
name: flutter_inappwebview
76+
url: "https://pub.dartlang.org"
77+
source: hosted
78+
version: "5.3.2"
7279
flutter_test:
7380
dependency: "direct dev"
7481
description: flutter
@@ -92,7 +99,7 @@ packages:
9299
path: ".."
93100
relative: true
94101
source: path
95-
version: "1.0.0"
102+
version: "1.0.1"
96103
http:
97104
dependency: transitive
98105
description:

lib/core/TransactionCallBack.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
abstract class TransactionCallBack {
2+
onTransactionSuccess(String id, String txRef);
3+
onTransactionError();
4+
onCancelled();
5+
}

lib/core/navigation_controller.dart

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,50 @@
1-
import 'package:flutter/material.dart';
2-
import 'package:flutter/widgets.dart';
3-
import 'package:flutterwave_standard/core/transaction_status.dart';
1+
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
2+
import 'package:flutterwave_standard/core/TransactionCallBack.dart';
3+
import 'package:flutterwave_standard/view/FlutterwaveWebView.dart';
44
import 'package:flutterwave_standard/view/flutterwave_style.dart';
5-
import 'package:flutterwave_standard/view/webview.dart';
65
import 'package:http/http.dart';
76

87
import '../models/TransactionError.dart';
98
import '../models/requests/standard_request.dart';
10-
import '../models/responses/charge_response.dart';
119
import '../models/responses/standard_response.dart';
1210

1311
class NavigationController {
14-
BuildContext _buildContext;
1512
Client client;
1613
final FlutterwaveStyle? style;
14+
final TransactionCallBack _callBack;
1715

18-
NavigationController(this._buildContext, this.client, this.style);
19-
16+
NavigationController(this.client, this.style, this._callBack);
2017

2118
/// Initiates initial transaction to get web url
22-
Future<ChargeResponse> startTransaction(final StandardRequest request) async {
19+
startTransaction(final StandardRequest request) async {
2320
try {
2421
final StandardResponse standardResponse =
25-
await request.execute(this.client);
22+
await request.execute(this.client);
2623
if (standardResponse.status == "error") {
2724
throw (TransactionError(standardResponse.message!));
2825
}
29-
final Map response = await openBrowser(
26+
openBrowser(
3027
standardResponse.data?.link ?? "", request.redirectUrl);
31-
return _handleResponse(response);
3228
} catch (error) {
3329
throw (error);
3430
}
3531
}
3632

37-
38-
ChargeResponse _handleResponse(response) {
39-
final status = response["status"];
40-
if (TransactionStatus.CANCELLED.toString() == status) {
41-
throw (TransactionError("Transaction cancelled"));
42-
}
43-
return ChargeResponse.fromJson(response);
44-
}
45-
46-
4733
/// Opens browser with URL returned from startTransaction()
48-
Future<Map<String, dynamic>> openBrowser(
49-
final String url,
50-
final String redirectUrl,
51-
[final bool isTestMode = false]
52-
) async {
53-
var response = await Navigator.push(
54-
_buildContext,
55-
MaterialPageRoute(
56-
builder: (context) => FlutterwaveWebview(url, redirectUrl, isTestMode)),
34+
openBrowser(
35+
final String url, final String redirectUrl,
36+
[final bool isTestMode = false]) async {
37+
final FlutterwaveInAppBrowser browser =
38+
FlutterwaveInAppBrowser(callBack: _callBack);
39+
40+
var options = InAppBrowserClassOptions(
41+
crossPlatform: InAppBrowserOptions(hideUrlBar: true),
42+
inAppWebViewGroupOptions: InAppWebViewGroupOptions(
43+
crossPlatform: InAppWebViewOptions(javaScriptEnabled: true),
44+
),
5745
);
58-
if (response == null) {
59-
Map<String, dynamic> errorResponse = {
60-
"status": TransactionStatus.CANCELLED
61-
};
62-
return errorResponse;
63-
}
64-
return response;
46+
47+
await browser.openUrlRequest(
48+
urlRequest: URLRequest(url: Uri.parse(url)), options: options);
6549
}
6650
}

0 commit comments

Comments
 (0)