Skip to content

Commit 2f633a3

Browse files
authored
Merge pull request #1 from lawale/master
Specifying targetSdkVersion
2 parents 2a0a761 + feeb72d commit 2f633a3

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

PaystackInline.Forms.Plugin/Renderer.android.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class PaystackWebViewRenderer : ViewRenderer<PaystackWebView, Android.Web
1919
private const string CallBackJavaScriptFunction = "function invokeCSharpAction(data){jsBridge.invokeCallbackAction(data);}";
2020
private const string CloseJavaScriptFunction = "function invokeCSharpCloseAction(){jsBridge.invokeCloseAction();}";
2121
private Context _context;
22-
22+
2323
public PaystackWebViewRenderer(Context context) : base(context)
2424
{
2525
_context = context;
@@ -46,13 +46,17 @@ protected override void OnElementChanged(ElementChangedEventArgs<PaystackWebView
4646
var webviewElement = Element;
4747
Control.AddJavascriptInterface(new JSBridge(this, _context), "jsBridge");
4848
string content = LoadHtmlString();
49-
Control.SetWebViewClient(new CustomWebViewClient(webviewElement.Data));
49+
var InjectJsAction = new Action(() =>
50+
{
51+
InjectJS(CallBackJavaScriptFunction);
52+
InjectJS(CloseJavaScriptFunction);
53+
});
54+
Control.SetWebViewClient(new CustomWebViewClient(webviewElement.Data, InjectJsAction));
5055
// Control.LoadUrl("file:///android_asset/paystack.html");
5156

5257

5358
Control.LoadDataWithBaseURL("", content, "text/html", "UTF-8", null);
54-
InjectJS(CallBackJavaScriptFunction);
55-
InjectJS(CloseJavaScriptFunction);
59+
5660
}
5761
}
5862

@@ -115,15 +119,18 @@ internal string LoadHtmlString()
115119
internal class CustomWebViewClient : WebViewClient
116120
{
117121
private string Record = "";
118-
public CustomWebViewClient(string record)
122+
public Action InjectJsAction = null;
123+
public CustomWebViewClient(string record, Action injectJsAction)
119124
{
120125
Record = record;
126+
injectJsAction = injectJsAction;
121127
}
122128
public override void OnPageFinished(Android.Webkit.WebView view, string url)
123129
{
124130
base.OnPageFinished(view, url);
125131

126132
view.LoadUrl(string.Format("javascript:payWithPaystack({0})", Record));
133+
InjectJsAction?.Invoke();
127134
}
128135
public override void OnPageStarted(Android.Webkit.WebView view, string url, Bitmap favicon)
129136
{
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
You need to add a reference to Mono.Android.Export.dll in your Android Project
2-
3-
4-
5-
Android:
6-
Set the Target Android Version: to Use Comple using SDK version

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Paystack Inline Payment Plugin for Xamarin Forms and Windows
2222

2323
## Android Requirements
2424
1. Add a reference to Mono.Android.Export, or a compiler error will result.
25-
2. On Android Oreo ensure that the Android manifest sets the Target Android version to Automatic. Otherwise, the iframe won't load.
2625

2726
## Usage
2827
### XAML

0 commit comments

Comments
 (0)