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

On Android first launch, files must contain a video for it to work properly #122

Open
Audeos opened this issue Oct 4, 2024 · 2 comments
Labels
android question Further information is requested react-navigation

Comments

@Audeos
Copy link

Audeos commented Oct 4, 2024

I have applied the linking you provided in react-navigation-example. I also provided below stuff in app.json:

"androidIntentFilters": ["image/*", "video/*"], "androidMultiIntentFilters": ["image/*", "video/*"]

Everything works as intended. However on android release build, if you share files that only contain image, the getInitialUrl function claims needRedirect to be false, and it does not navigate to the screen I asked for it to. It does work if at least one of your shared files is a video. However, even in that case, it's still false. What's different between the video sharing or image sharing is this pending value:

const shareIntentEventSubscription = addStateListener((event) => {
      // REQUIRED FOR ANDROID WHEN APP IS IN BACKGROUND
      console.debug(
        "react-navigation[subscribe] shareIntentStateListener",
        event.value,
      );
      if (event.value === "pending") { // this was the thing that videos fire and images don't
        listener(`${Constants.expoConfig?.scheme}://shareintent`);
      }
    });

and getInitialUrl looks like to be false all the time.

In development build, neither the ios or android works as intended, probably because expo is in the way. So I had to test these on release build, logging with alerts.

@achorein
Copy link
Owner

achorein commented Oct 4, 2024

for the app, there is no difference between image and video.

on android we are not using deep link (using scheme only on ios), so it's normal that getInitialURL is always false.

you should use hasShareIntent(getShareExtensionKey()); as mention in the example.
it calls share-intent native module to check if we got pending request to handle.

@achorein achorein added the question Further information is requested label Oct 4, 2024
@Audeos
Copy link
Author

Audeos commented Oct 4, 2024

What I meant is,
const needRedirect = hasShareIntent(getShareExtensionKey());
above expression is false. It's inside getInitialUrl in the link you provide.

 async getInitialURL() {
    // REQUIRED FOR ANDROID FIRST LAUNCH
    const needRedirect = hasShareIntent(getShareExtensionKey());
    console.debug(
      "react-navigation[getInitialURL] redirect to ShareIntent screen:",
      needRedirect,
    );
    if (needRedirect) {
      return `${Constants.expoConfig?.scheme}://shareintent`;
    }
    // As a fallback, do the default deep link handling
    const url = await Linking.getInitialURL();
    return url;
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android question Further information is requested react-navigation
Projects
None yet
Development

No branches or pull requests

2 participants