Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.2.0
-
None
-
Windows phone 8.1
-
Important
Description
The hardware back button when tapped closes the app (puts in background mode) in addition to closing the InAppBrowser.
This behavior exists in windows phone only whereas it works fine in Android (it closes only the InAppBrowser).
Please help me fix this issue.
Attachments
Issue Links
- links to
Activity
Hi Sergey, It is WP8. I used the same technique which gave me back, forward and close buttons which acts specific to the InAppBrowser. My only problem is, if user taps on Hardware back button, it will close the InAppBrowser along with the app altogether.
Is there any timeline when we can expect the fix for this.
It's unlikely we'll try to fix this as this is for the WP8 platform which is deprecated. You have a couple of options:
- try to fix this yourself and issue a PR
- Consider moving to `Windows` platform which supports WP 8.1 and Windows 10 phone
- As Sergey, suggested have back button show up on the UI.
I guess, we have misunderstanding about the issue. The issue is not about whether the back button from the InAppBrowser appears or not. Rather, the issue is, the Hardware back button while InAppBrowser is open, if pressed closes the both InAppBrowser and the App altogether instead of closing only the InAppBrowser.
And this issue happens in WP 8.1 also.
Issue reproduces on Windows Phone 8.1 (cordova-windows) platform, investigating.
GitHub user daserge opened a pull request:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178
CB-10467 Hardware back button, while InAppBrowser is opened, closes t…
<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
is intended as a quick reference, for complete details please see our Contributor Guidelines:
http://cordova.apache.org/contribute/contribute_guidelines.html
Thanks!
-->
…he app too in addition to closing InAppBrowser
[Jira issue](https://issues.apache.org/jira/browse/CB-10467)
-
-
- Platforms affected
Windows
- Platforms affected
-
-
-
- What does this PR do?
Adds the same backbutton handling behavior to Windows as Android platform has, i.e. if `hardwareback=yes` (by default) we navigate history back and then close inappbrowser, and just close iab if `hardwareback=no`.
- What does this PR do?
-
-
-
- What testing has been done on this change?
Tested on Windows 8.1/10 and Phone 8.1/10.
backbutton event is not fired in a Windows 8.1 project on Windows 10 host OS; otherwise all works ok.
- What testing has been done on this change?
-
-
-
- Checklist
-
- [x] [ICLA](http://www.apache.org/licenses/icla.txt) has been signed and submitted to secretary@apache.org.
- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [x] Added automated test coverage as appropriate for this change.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/daserge/cordova-plugin-inappbrowser CB-10467
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #178
commit 3f180ffa96ac345384e31fd52a479517a14f4000
Author: daserge <v-seshak@microsoft.com>
Date: 2016-08-16T17:10:15Z
CB-10467 Hardware back button, while InAppBrowser is opened, closes the app too in addition to closing InAppBrowser
Github user cordova-qa commented on the issue:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178
Cordova CI Build has completed successfully.
*Commit* - [Link](https://github.com/apache/cordova-plugin-inappbrowser/pull/178/commits/3f180ffa96ac345384e31fd52a479517a14f4000)
*Dashboard* - [Link](http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/57/)
Github user vladimir-kotikov commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178#discussion_r75115134
— Diff: src/windows/InAppBrowserProxy.js —
@@ -176,6 +179,38 @@ var IAB = {
browserWrap.appendChild(popup);
+ var closeHandler = function (e) {
+ setTimeout(function ()
, 0);
+ };
+
+ if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) {
+ hardwareBackCallback = function () {
+ if (browserWrap.style.display === 'none') {
+ // NOTE: On Windows Phone 8.1 backbutton handlers have to throw an exception in order to exit the app
+ throw 'Exit the app';
— End diff –
From what i understand, this doesn't necessarily mean that app will exit after this - this just means that app will fall back to default system navigation behavior. If that's true please update comment above to reflect this.
Github user vladimir-kotikov commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178#discussion_r75115204
— Diff: src/windows/InAppBrowserProxy.js —
@@ -176,6 +179,38 @@ var IAB = {
browserWrap.appendChild(popup);
+ var closeHandler = function (e) {
+ setTimeout(function ()
, 0);
+ };
+
+ if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) {
+ hardwareBackCallback = function () {
+ if (browserWrap.style.display === 'none')
+
+ if (popup.canGoBack)
else
{ + closeHandler(); + } + };
+ } else if (features.indexOf("hardwareback=no") > -1) {
+ hardwareBackCallback = function () {
+ if (browserWrap.style.display === 'none') {
+ // NOTE: On Windows Phone 8.1 backbutton handlers have to throw an exception in order to exit the app
+ throw 'Exit the app';
— End diff –
Same as above
Github user vladimir-kotikov commented on the issue:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178
Two minor comments, otherwise LGTM
Github user vladimir-kotikov commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178#discussion_r75116093
— Diff: src/windows/InAppBrowserProxy.js —
@@ -176,6 +179,38 @@ var IAB = {
browserWrap.appendChild(popup);
+ var closeHandler = function (e) {
+ setTimeout(function ()
, 0);
+ };
+
+ if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) {
+ hardwareBackCallback = function () {
+ if (browserWrap.style.display === 'none') {
+ // NOTE: On Windows Phone 8.1 backbutton handlers have to throw an exception in order to exit the app
+ throw 'Exit the app';
— End diff –
Prooflinks:
- WP8.1 [`onbackclick` event](https://msdn.microsoft.com/ru-ru/library/windows/apps/dn607962.aspx)
- UWP [`SystemNavigationManager` class](https://msdn.microsoft.com/ru-ru/library/windows/apps/windows.ui.core.systemnavigationmanager)
Github user cordova-qa commented on the issue:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178
Cordova CI Build has completed successfully.
*Commit* - [Link](https://github.com/apache/cordova-plugin-inappbrowser/pull/178/commits/2776b14db6e949c87850d3874ad94d45208c7011)
*Dashboard* - [Link](http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/59/)
Commit 2776b14db6e949c87850d3874ad94d45208c7011 in cordova-plugin-inappbrowser's branch refs/heads/master from daserge
[ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-inappbrowser.git;h=2776b14 ]
CB-10467 Hardware back button, while InAppBrowser is opened, closes the app too in addition to closing InAppBrowser
Github user asfgit closed the pull request at:
https://github.com/apache/cordova-plugin-inappbrowser/pull/178
Is it 'wp8' or 'windows' platform?
As a temporary workaround you can try adding `location=yes` param to bring software navigation bar.
cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');