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

Import files to web page #591

Open
developvsn opened this issue Sep 14, 2020 · 9 comments
Open

Import files to web page #591

developvsn opened this issue Sep 14, 2020 · 9 comments

Comments

@developvsn
Copy link

Hello. I’m trying to upload some photos or files/documents on page loaded in web view, i read old closed issues but didn’t find final answer about this topic. Can we open “choose action” picker on android depending on web page or there is no ways to perform it ? Thanks in advance

@KojiNakamaru
Copy link
Member

The current versions supports the file input field on Android, please check the top of https://github.com/gree/unity-webview/tree/8e7e576949536a4d5e127bc1d46e99060523bcbd#android .

@Blindsp0t-creative
Copy link

Hi there !!

First of all thank you for the amazing work on this.

I'm facing the same issue here, i tried both versions (with and without Fragment). When i browse a page with a button to upload a file, and click on it, nothing happens...
No window to pick a file, or anything.

Any idea what i'm doing wrong?

I'm building an Android app, and test with Android 5.1.1 and another device running Android 8.0.0

Thanks in advance

@KojiNakamaru
Copy link
Member

I tested the sample app with dist/unity-webview.zip and confirmed it worked. My environment is:

  • Unity 2019.4.13f1
  • Vankyo S7 (Android 9.0)

The sample app contains <input type="file" name="datafile"/> at the bottom of the page. If you didn't run the sample app, could you please test it?

@Blindsp0t-creative
Copy link

Thank you very much for the quick answer.

I built an entire new Unity project, and tested with the /dist/unity-webview.zip and can confirm it works !!!

Don't know if it was due to my previous project settings or the version of the unitypackage i was using before...

Thank you again !

@wantsliveforever
Copy link

wantsliveforever commented Jun 25, 2021

Hello! Unfortunately, the input file does not work on Android. On iOS works fine. I'm trying to upload an image to the site at https://mirkoda.com/Identity/Account/Login I didn't dig into the code CWebViewPlugin.java. I looked, there are already changes related to the link a1a2a89 But not all

@wantsliveforever
Copy link

wantsliveforever commented Jun 26, 2021

This is a part of log from Samsung S8+. I clicking to input file.

06-26 17:40:34.353 5505 5690 D WifiNotificationController: clearPendingNotification with resetRepeatTime= true, state= 0
06-26 17:40:34.459 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:34.660 7615 7615 I chatty : uid=10168(com.sec.android.inputmethod) identical 1 line
06-26 17:40:34.861 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:34.981 5505 5663 D InputReader: Input event(8): value=1 when=70655.138172
06-26 17:40:34.981 5505 5663 D InputReader: Input event(8): value=1 when=70655.138172
06-26 17:40:34.981 5505 5663 I InputReader: Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.1687 ] when=70655.138172
06-26 17:40:34.982 5505 5662 I InputDispatcher: Delivering touch to (31394): action: 0x0, displayId: 0, '34ffdb9', toolType: 1
06-26 17:40:34.982 31394 31394 D ViewRootImpl@5166214[UnityPlayerActivity]: ViewPostIme pointer 0
06-26 17:40:35.061 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:35.098 5505 5663 D InputReader: Input event(8): value=0 when=70655.255494
06-26 17:40:35.099 5505 5663 D InputReader: Input event(8): value=0 when=70655.255494
06-26 17:40:35.099 5505 5663 I InputReader: Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=70655.255494
06-26 17:40:35.099 5505 5662 I InputDispatcher: Delivering touch to (31394): action: 0x1, displayId: 0, '34ffdb9', toolType: 1
06-26 17:40:35.100 31394 31394 D ViewRootImpl@5166214[UnityPlayerActivity]: ViewPostIme pointer 1
06-26 17:40:35.125 31394 31394 D InputMethodManager: HSIFW - flag : 0 Pid : 31394
06-26 17:40:35.126 5505 7118 V InputMethodManagerService: Client requesting input be hidden, flags : 0
06-26 17:40:35.126 5505 7118 V InputMethodManagerService: hideCurrentInputLocked : shouldHideSoftInput is false
06-26 17:40:35.262 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:35.302 13661 20884 I BCL@Common: (ProvisionProvider) query, content://com.samsung.android.bixby.agent.common.provision/service_id
06-26 17:40:35.308 7200 13733 D BWU@VoiceWakeupInfo: getBixbyServiceID :
06-26 17:40:35.308 7200 13733 I SamsungAnalyticsUtil: :Ph::SamsungAnalytics can't setConfiguration because serviceId is empty after 68018000
06-26 17:40:35.463 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:35.865 7615 7615 I chatty : uid=10168(com.sec.android.inputmethod) identical 2 lines
06-26 17:40:36.065 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:36.125 5505 5663 D InputReader: Input event(8): value=1 when=70656.281711
06-26 17:40:36.125 5505 5663 D InputReader: Input event(8): value=1 when=70656.281711
06-26 17:40:36.125 5505 5663 I InputReader: Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.1688 ] when=70656.281711
06-26 17:40:36.125 5505 5662 I InputDispatcher: Delivering touch to (31394): action: 0x0, displayId: 0, '34ffdb9', toolType: 1
06-26 17:40:36.126 31394 31394 D ViewRootImpl@5166214[UnityPlayerActivity]: ViewPostIme pointer 0
06-26 17:40:36.252 5505 5663 D InputReader: Input event(8): value=0 when=70656.408806
06-26 17:40:36.252 5505 5663 D InputReader: Input event(8): value=0 when=70656.408806
06-26 17:40:36.252 5505 5663 I InputReader: Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=70656.408806
06-26 17:40:36.252 5505 5662 I InputDispatcher: Delivering touch to (31394): action: 0x1, displayId: 0, '34ffdb9', toolType: 1
06-26 17:40:36.254 31394 31394 D ViewRootImpl@5166214[UnityPlayerActivity]: ViewPostIme pointer 1
06-26 17:40:36.266 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:36.282 31394 31394 D InputMethodManager: HSIFW - flag : 0 Pid : 31394
06-26 17:40:36.282 5505 7118 V InputMethodManagerService: Client requesting input be hidden, flags : 0
06-26 17:40:36.283 5505 7118 V InputMethodManagerService: hideCurrentInputLocked : shouldHideSoftInput is false
06-26 17:40:36.314 13661 20884 I BCL@Common: (ProvisionProvider) query, content://com.samsung.android.bixby.agent.common.provision/service_id
06-26 17:40:36.317 7200 13733 D BWU@VoiceWakeupInfo: getBixbyServiceID :
06-26 17:40:36.317 7200 13733 I SamsungAnalyticsUtil: :Ph::SamsungAnalytics can't setConfiguration because serviceId is empty after 68019000
06-26 17:40:36.467 7615 7615 I SKBD : and isTosAccept false
06-26 17:40:36.668 7615 7615 I chatty : uid=10168(com.sec.android.inputmethod) identical 1 line
06-26 17:40:36.869 7615 7615 I SKBD : and isTosAccept false

@KojiNakamaru
Copy link
Member

KojiNakamaru commented Jun 28, 2021

I'm sorry for the inconvenience. Since #655 , a dialog for requesting permissions will be shown only if one of the following permissions are enabled:

int hasPerm1 = pm.checkPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE, activity.getPackageName());
int hasPerm2 = pm.checkPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, activity.getPackageName());
int hasPerm3 = pm.checkPermission(android.Manifest.permission.CAMERA, activity.getPackageName());

You can enable the camera access by defining UNITYWEBVIEW_ANDROID_ENABLE_CAMERA or can enable the external storage access by setting Player Settings/Other Settings/Write Permission to External (SDCard). Once the dialog is shown and a user agrees, <input type="file"> should work.

I'll later update README.md about this point.

@wantsliveforever
Copy link

Hello! Thank you for answer!
Yes, I have already declared a variable UNITYWEBVIEW_ANDROID_ENABLE_CAMERA and Microphone. And set Permittion.Camera in to SampleWebView.cs
Today i'll try to Android resolver -> Force resolve

@KojiNakamaru
Copy link
Member

UNITYWEBVIEW_ANDROID_ENABLE_CAMERA should not be declared as a variable, should be defined as below:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants