Twitter web intent missing close button on android


#1

I would like a user to be able to send out a tweet from my website. I added your default button, which shows a page to type in their tweet (in which I default some text), then they hit the send button, and it brings them to a final page with recommendations on who else to follow. On my desktop and on my iPhone, this page has a close button, which allows the user to navigate back to my page. On the android, there is no close button, so they must use the hardware backbutton (twice) to go back to the ‘type the tweet’ page and then once again to go back to my website. That is not an ideal UX. When I tweet from other websites on my Android, I get the close button so I suspect there is some parameter I should be setting. Please advise.
Thanks.
Don

P.S. I don’t think this would matter but my website is being run as a local Cordova/Phonegap app on the phone, meaning hosting local html/js files inside the webview of a native android app.


#2

Hi Don,

The issue probably is with the Cordova environment, here’s why: The Web Intent supports being instantiated in pop-ups, as pages/tabs in mobile browsers, and as standalone pages through regular web navigation. The “Close” UI therefore only applies in some contexts, and we toggle the button (plus window.close() behaviour) where it’s available.

Regular browsers, and mobile browsers with tabs, maintain a concept of page hierarchy via the window.parent property, when window.parent is available, we enable the ‘close’ button, as this indicates that the window will have permission to close itself (browsers do not tend to allow pages to close windows that scripts did not also create, lest the user experience be unexpectedly hijacked.)

My understanding of the PhoneGap environment is that by default there is only a single page canvas, so there is probably no window.parent, and so the Intent would be unable to close itself.

To compensate for this environment, in your website app you would need to listen for links to the Intents and perhaps open them in a dedicated browser context, or alternatively listen for an /intent/tweet/complete path and trigger the navigation based on that.

Hope that helps,

Ben


#3

Thanks a lot Ben. That was indeed the problem. For your reference, I changed the launch to open the system browser (window.open(,"_system"…), and it worked elegantly on the Android (iOS I had a different solution anyway). This when you launch outside of PhoneGap, Android sees the href is twitter and asked if you want to open the Twitter app on the device (and only asks this once). Once you did that, you had a nice native UX, and once you hit the tweet button, it closed and brought you right back. (I’m going to add an audible bird tweet on that soon).

As a general point, in case you are advising PhoneGap developers in the future, launching with _system on the Android should be the norm because it’s easy to get back (because of the hardware back button) and Android sees certain hrefs and launch native apps like Twitter - and the same thing happened to my launch of the google maps website, it intercepted it and asked me if I wanted to launch the native app. Cool.

Thanks again.


#4