Skip to content

Enable for mobile #13

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

Closed
piranha opened this issue Jul 23, 2021 · 11 comments
Closed

Enable for mobile #13

piranha opened this issue Jul 23, 2021 · 11 comments

Comments

@piranha
Copy link

piranha commented Jul 23, 2021

Hey! This plugin is enabled for desktop only right now. Do you think it's possible to enable it for mobile app? :)

@gavvvr
Copy link
Owner

gavvvr commented Jul 23, 2021

Hi @piranha. I tried it on mobile by manually uploading it to mobile vault and changing isDesktopOnly in manifest, but it does not work "as-is".
This plugin uploads images on:

  • "drag" (when you use drag-and-drop) and
  • "paste" (when you paste from the clipboard buffer) events

On mobile you are also allowed to add images from the gallery to your note. But looks like none of those events are used.
I posted a quick question on Discord about how it works, but the question left unanswered.

So, in short:

  • you can attach images from the gallery on mobile
  • so I think there must be a way to override the default behaviour and perform remote upload instead. But for now I do not know which event is involved into this process ​

When I developed for desktop, there was a Chrome console which helped me a lot. For mobile, I do not know yet how to easily debug. There was a message in the chat on how to connect to remote console, but I haven't tried that yet.

Do you know if copy-paste is available for images on mobile platforms? I have an Android phone. I have a "Copy" context menu option in Chrome browser. When I go to Obsidian, and try to "Paste", simply nothing happens. At the same time if I go to Telegram and Paste the image previously copied from Chrome, it works! I think Obsidian for Android does not handle paste event as we and the current implementation of imgur plugin expects.
If you have an iOS device, please let me know if you can copy/paste images there (with other, more mature apps) and if Obsidian can handle it or not

@piranha
Copy link
Author

piranha commented Jul 23, 2021

Yeah, I have an iOS device and nothing happens. I also installed an iPad version on macOS and nothing happens on pasting an image there. So I guess mobile app has no support for pasting anything but text right now.

@gavvvr
Copy link
Owner

gavvvr commented Jul 24, 2021

Tried with iPhone too -> same result. Nothing happens on "paste" context menu item.

I created the feature request on Obsidian forums to support "pasting" images on mobile.

@martinjo
Copy link

I have no idea about the events involved when pasting on mobile platforms. But there is a plugin that enables a dev console on mobile (I’ve only tried it on iOS). I think it needs to be installed manually, but it worked fine for me. Debugging this way is still cumbersome, but at least it’s something 😌

@A000045
Copy link

A000045 commented Feb 25, 2023

"This plugin does not support your device"

My situation is the following : I can't even enable the plugin on ipadOS, because (as is often the case) I get this red notice : "This plugin does not support your device". I wonder if this is easily fixable. Would love to learn how to fix this kind of thing as it is a recurring pbm with obsidian plugins on mobile.

Anyway, I have a feeling that the conversation has gotten a bit old and I'm not quite sure we're refering to the same issue : it seems that people here are refering to pasting images from a clipboard, which has only been made possible very recently on obsidian mobile ( forum.obsidian ).

@gavvvr
Copy link
Owner

gavvvr commented Feb 27, 2023

Hi @A000045

You can easily fix this error message by opening the vault which you had on PC and changing one line in manifest.json.

  1. Create the vault on PC
  2. Install Imgur plugin
  3. Go to your_vault/.obsidian/plugins/obsidian-imgur-plugin/manifest.json and change the value for isDesktopOnly to false
  4. Somehow copy your vault to your mobile device (as an Android user, I use OneSync to sync my knowledge base between PC and mobile device)
  5. Open the vault which you just copied using mobile app. The plugin should be able to be "Enabled", but as I know it does not work on mobile (still did not find a time to debug it on mobile devices).

@gavvvr
Copy link
Owner

gavvvr commented Oct 8, 2023

Today I've spent my morning on understanding why it does not work on mobile.
It turned out to be surprisingly easy to enable debugging on mobile:

  1. enable USB debugging on Android phone
  2. connect it with USB to laptop
  3. open chrome://inspect right in the browser and choose Obsidian mobile app

So, I opened the "Network" tab to understand what's wrong and first thing I saw was net::ERR_HTTP2_PROTOCOL_ERROR on request itself and TypeError: Failed to fetch exception.
After more attempts to upload an image the error turned into 429 with human-readable payload:

{
    "data": {
        "error": "Imgur is temporarily over capacity. Please try again later."
    },
    "success": false,
    "status": 403
}

I compared requests from desktop and mobile Obsidian apps and one major difference is that the Origin header from mobile app is http://localhost, while it is app://obsidian.md for Desktop app. Then the "try again later" message makes sense to me, there are always too many requests from http://localhost from around the world or it's a kind of banned forever by target servers, even though it's not explicitly prohibited by CORS.

I've posted a question on Obsidian forums about the possibility to get non-localhost value for Origin header in mobile app. Let's see. If that's not possible even for Obsidian developers to affect this header for mobile app, then this feature will never be implemented.

gavvvr added a commit that referenced this issue Oct 20, 2023
This refactoring is needed to enable support of mobile devices
#13
gavvvr added a commit that referenced this issue Oct 20, 2023
@gavvvr
Copy link
Owner

gavvvr commented Oct 20, 2023

Finally available in v2.4.0 🎉 (just released)

@softlylove
Copy link

Hi @gavvvr , thanks for your effort on maintaining this plugin 🙏

I have installed this plugin today, and I confirm that I have authenticated in Imgur, however, after uploading an image from gallery via Obsidian iOS, the file is saved only locally. I have no idea where to debug.

Can u please give some hints?

Thanks a lot!

@gavvvr
Copy link
Owner

gavvvr commented Jul 25, 2024

Hi @softlylove

The problem is that the plugin currently handles "paste" or "drag-and-drop" events. Those are 2 different ways how you add images on desktop Obsidian app.
When you add image from the gallery on mobile phone, it's some 3rd mechanism, which is not handled by the plugin (there is an issue #60). An enhancement is required. As a workaround, try to open the gallery, press and hold your image to get context menu (if any) and choose "copy" (I don't have iOS, so I can't check if it will work out). If you find a way to copy your image to mobile device's clipboard, you can then "Paste" it into your note and it will be handled by the plugin the same way as it's done by desktop app. As I know, at least it should be possible to copy and paste images from Safari, not sure about the gallery.


I have no idea where to debug.

Can u please give some hints?

Unfortunately, I have no idea if it's even possible to debug Obsidian on iOS. If you have Android device, you can enabled USB debugging and connect to Obsidian mobile with Chrome Dev Tools (I've described how to do it here)

@softlylove
Copy link

As I know, at least it should be possible to copy and paste images from Safari, not sure about the gallery.

It works on iOS Photos :)

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

5 participants