mikehardy / react-native-update-apk

Update apk from non-play store servers, and update ios from app store in React Native.
MIT License
195 stars 57 forks source link

Ability to prevent tapping outside the update modal #66

Open deserthurricane opened 2 years ago

deserthurricane commented 2 years ago

Hi

I recently started using your lib. Thank you, it's really cool and helps us to deliver new versions to our customers much faster 👍

I only have one question on how I can block user interface from tapping outside the installation modal and crashing the app 😅 This is how it can be reproduced:

  1. Launch the example app.
  2. Click "Update" in the modal.
  3. Click "Install" in the next modal.
  4. When the installation modal is shown, tap outside of it.
  5. The installation process becomes interrupted, and the app crashes.

https://user-images.githubusercontent.com/19632032/166200894-717ce98f-dc7e-4753-bec4-6b6e0057d7f4.mov

I tried to investigate the source code of your lib - ACTION_INSTALL_PACKAGE intent is called for updating the application. I googled if there are any special flags like "setCancellable(false)" that we could pass to this intent, but didn't find any.

Then I tried to make a fix at the "react-native" side and added a View with absolute position and pointerEvents="none" prop on the whole screen. But unfortunately this didn't work: if I tap on that View, the installation modal closes immediately.

How do you think, are there any ways to prevent installation modal from being closed and the app - crashed? Or is it a standard Android behavior which we cannot change?

mikehardy commented 2 years ago

Hi there! I'm glad you find the module useful, I do still use it myself. Unfortunately I have not probed the use case you indicate, I only distribute updates like this to my developers and I assume they will either "behave" (if it crashes when you do that....don't do that) or that it's fine if it crashes in a cornercase.

So this isn't a use case I personally care to spend time investigating, just for transparency.

However! I can think of one other system that does updates like this and may serve for inspiration - the F-Droid 3rd party app repository. I suppose APKPure too but I know F-Droid is open source, maybe that helps?

If you do discover something and it's worth a PR I'd be happy to collaborate to merge and release it of course - the project's not dead and I am interested in it working, and working well - I just don't need this specific feature so you'd have to develop it.

Hope this helps?

deserthurricane commented 2 years ago

@mikehardy thank you for your answer! I will investigate the alternatives you proposed. Also, if I have an idea how to add the expected behavior to the current library, I will send a PR.