Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button don't work in browser #1959

Closed
CamilleFrive opened this issue Dec 10, 2023 · 5 comments
Closed

Button don't work in browser #1959

CamilleFrive opened this issue Dec 10, 2023 · 5 comments

Comments

@CamilleFrive
Copy link

Bug Report

Plugin(s)

"@capacitor/browser": "^5.1.0"

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 5.5.1
  @capacitor/core: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/ios: 5.5.1

Installed Dependencies:

  @capacitor/cli: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/core: 5.5.1
  @capacitor/ios: 5.5.1

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

ios

Current Behavior

click on a specific button in the browser does nothing

Expected Behavior

click should redirect to an url which will also redirect to a custom scheme url which will close the browser

Code Reproduction

this code should be called

window.location.replace('frive://close');

and how it is handled

const tryClose = async () => {
    if (Capacitor.isNativePlatform()) {
      await Browser.close();
    }
  };

  App.addListener('appUrlOpen', (data) => {
    if (data.url == 'frive://close') {
      tryClose();
      window.location.reload();
    } 
  });

Other Technical Details

This don't work on some device (like iphone 15 pro max) and work on other (iphone XS)

The agree button is the one which cause the issue (a javascript issue?)
image

@CamilleFrive
Copy link
Author

CamilleFrive commented Dec 11, 2023

Update:
The issue is that i used navigate (is this a bug?) here the full addListener i used

  const tryRequest = async (url: string) => {
    const url2 = new URL(url);
    const apiService = axios.create({
      baseURL: url2.origin,
    });

    await apiService.get(url2.pathname + url2.search);
  };

  const tryClose = async () => {
    if (Capacitor.isNativePlatform()) {
      await Browser.close();
    }
  };

 App.addListener('appUrlOpen', (data) => {
    const navigate = useNavigate();

    if (data.url == 'frive://close') {
      tryClose();
      window.location.reload();
    } else {
      if (data.url.startsWith('https://')) {
        if (data.url.includes('/api/v1')) {
          tryRequest(data.url);
          tryClose();
          window.location.reload();
        } else {

          const url = new URL(data.url);
          if (url) {
            navigate(url.pathname);
          }
        }
      }
    }
  });

But now I don't know what to do to redirect users, windows.location seems not to work

@dallastjames dallastjames self-assigned this Jan 2, 2024
@dallastjames
Copy link
Contributor

You likely need to navigate based on the framework you're using, which would be specific to your application since navigation is handled by the web app and not Capacitor. Where are you getting the navigate from? Can you provide a sample reproduction that reproduces this issue in a minimal application?

@Ionitron
Copy link
Collaborator

Ionitron commented Jan 2, 2024

This issue needs more information before it can be addressed.
In particular, the reporter needs to provide a minimal sample app that demonstrates the issue.
If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks!
Ionitron 💙

@Ionitron
Copy link
Collaborator

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day!
Ionitron 💙

Copy link

ionitron-bot bot commented Feb 2, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants