Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Not calling override method on EvaluateJavascript when window.method is placed inside Angular code

$
0
0

I am trying to inject Javascript to the webivew which was designed using Angular2. Now on button click they wrote a function as shown below

this.nativeAppService.sendToNative({eventName: 'SomeMethod'});
sendToNative(event: NativeEvent) {
if (this._cookieService.get('NativeAppKey') === 'true') {
const window = this.windowRef.nativeWindow;
if (window.messageToNative) {
window.messageToNative(event);
} else if (window.external && window.external.NativeDispatch) {
window.external.NativeDispatch(event.eventName, JSON.stringify(event.parameters));
} else {
console.warn(Not posting event to native app - neither window.messageToNative or window.external.NativeDispatch is not defined.);
}
}
}

now I am writing evaluate javascript as shown below

            Control.EvaluateJavascript("function messageToNative(toast){Android.showToast(toast);}", null);

Here "messageToNative" is the function in aboive script so once I click the button my "showToast" should call but it is not happening

If I am loading samplehtml file with a button and on button click it is calling showToast method but If I am trying to implement the above script its not working fine

Please help me on this.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>