InvokeScript changes from WP8.0 to WP8.1

Posted by Matt Bryson on 12-Sep-2014 11:26:53
Find me on:

With the windows phone 8.1 release, lots of nice new features were added for a WebView control.

However, one of which was the deprecation of WebView.InvokeScript

According to this page, as of 8.2 (or 9.0?) it will no longer be available, and you should use WebView.InvokeScriptAsync



What it doesn't mention is the breaking change to existing WebView.InvokeScript.

Previously it was blocking, so you could run some JS similar to this...

var some_flag=false;
window.nativeCallbackToDoSomething=function() {
some_flag=true;
}
    
window.external.notify('doSomething');

//Now, if the native method doSomething immediately calls nativeCallbackToDoSomething,
//Then some_flag will be true at this point.

if(some_flag) {
alert("nativeCallbackToDoSomething was called");
}

But now it is not blocking, so the above example would never alert, regardless if the callback was triggered.

Probably very edge case, but it stuffed one of our apps up!

m

Topics: WP8

About the author

Matt Bryson is an experienced systems engineer with over 15 years Development and Systems Operations experience.

NEW - Free eBook

Transforming your eDetail process. Click below to download the eBook.

New Call-to-action

Subscribe to Email Updates

Recent Posts