I’m working on a Remember the Milk application for the BlackBerry PlayBook, and am trying to get familiar with building against the RTM API. One of the security measures they take in order to use their API is requiring all applications to authenticate against a page on their site, and give permission to the calling application. It’s a pretty common pattern these days.
To do this in an AIR application, you can use StageWebView, which allows you to open a browser display within your applications. It has limitations, but works perfectly for this use case.
So you load up the page you want in the StageWebView, listen for the locationChange event, see if permission was granted, and go about your way. Simple? Right?
It failed for RTM. Why?
The location didn’t change. It was doing one of those “Let’s be cool and not reload the page” things.
At first glance the work around was to add a close button that the user would hit when the RTM page was done. But that’s inelegant, and frankly lazy.
So, I poked around some more, and found out, that despite not firing a locationChange event, it was firing a complete event when it was done. And luckily, RTM changes the title to reflect that the user gave permission.
So, all I had to do was add a check for the title to the processor for complete as displayed below:
Simple, easy, straightforward – hopefully I save someone else an afternoon of trial and error with this post.
7 thoughts on “StageWebView Location Changing without a Page Refresh”
Hey man, it’s been a long 36 hours…
Just wanted to give you respect for being the only one to explain this properly.
While the StageWebView fires events correctly on the desktop (i.e. fires LocationChangeEvent.LOCATION_CHANGE) in a redirect, on mobile StageWebView this is not the case, not on Android running Air 2.6 at least.
So, after changing my event listeners from LocationChangeEvent.LOCATION_CHANGE
Everything is very fine and sexy…
Awesome. Glad I could help.
Any update on your Remember the Milk app for playbook? That would be awesome!
huge thank you for blogging this. took me so long to figure out that the event wasn’t firing properly.
I am using stageWebView for showing webpage in my mobile app but don’t know how to move back to my app once it gets loaded. In application descriptor file, I had already registered custom uri scheme (myapp://) for IOS devices and from the loaded page inside stageWebView, I was trying to call following URL myapp://webcam. But nothing had happened. It neither called LOCATION_CHANGE event of StageWebView not called INVOKE_EVENT of nativeapplication.
How can I fix this issue?
Thanks in advance,
Thanks for the tip, proved really useful! Had the issue on Android with Air 3.2 RC1 and this solved the problem.
You just save my day Sir, Thank You So Much ^_^