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.