How to make Templater to use a template in iOS when using “Share with Obsidian”

I use Obsidian a lot in my iPad to save notes of interest that I find in the web, and more specifically papers.

The only problem that I have is that Templater doesn’t know I am in iOS when using the “Share” button to save the internet page to a note. It just creates a blank note -no frontmatter at all -, and pastes the link, or image, that I want to save to Obsidian.

Templater works well in the iPad if I create the note from within Obsidian. But I want to save the extra typing of frontmatter when I use the “Share” button of iOS.

I never tried this with Templater, and the following plugins when used in conjuction could pay dividends:

This may be overdoing it and you may be better off creating some iOS Shortcuts which would match with regex where you want to file away what.

In addition, now there is Obsidian Web Clipper on iOS as well (not working for my older tablet … dang), which could be…

  1. configured for different types of content to be saved to any folder, with any set properties;
  2. set with title ‘Untitled’, and then when the clip gets saved (to vault root for instance), a template manager via Templater should/would open up with where the user wants to file away the clipping.

Tried Obsidian Web Clipper but it’s overkill for what I want to achieve. Besides, OWC conflicts with the default Templater template; OWC requires that an automatic or default template is disabled, otherwise it will append its frontmatter and content over the default template.

What I need is something simple: an automatic template that is triggered when Obsidian is called via the “Shared” button in iOS.

Why not try a simple iOS Shortcut (there is a shortcut thread here somewhere and there are other places) that saves the file without templates with filename ‘Untitled.md’ and use an if conditional in your template what to do if the file is named ‘Untitled’, or you can do it with ‘Webclip.md’ and act accordingly.
From the site I’ve just seen:

Not sure how that’d work with Templater but Actions seems like good stuff.

Thanks. I will explore this option.

I found just minutes ago a clue on how to make Templater know which device you are creating a note from.

Here:

Unfortunately, this Templater command
<% app.internalPlugins.plugins.sync.instance.deviceName %>
returns empty in iOS.

I tried all possible ways to populate a note, via a template, that is created using iOS “Share with”, and no success.
So, I came up with this workaround combining it with a script by @AlanG.
The Templater template has to be called in insert mode, not create.

<%-*
/*  Inserts frontmatter to a previously existing note
	This is ideal when a note is created from a LinkedIn post 
    or the web in a mobile device using “Share with”.
*/
const uuid = tp.file.creation_date("YYYYMMDDHHmmss");
let device = ""
var isIosApp = tp.obsidian.Platform.isIosApp
var isLinux = tp.obsidian.Platform.isLinux
var isMacOS = tp.obsidian.Platform.isMacOS
var isTablet = tp.obsidian.Platform.isTablet
var isPhone = tp.obsidian.Platform.isPhone
var isDesktop = tp.obsidian.Platform.isDesktop
if (isIosApp && isTablet) {
   device = "iPad"
} else if (isIosApp && isPhone) {
  device = 'iPhone'
} else if (isDesktop && isLinux) {
  device = 'Linux'
} else if (isDesktop && isMacOS) {
  device = 'macOS'
}
setTimeout(() => {
  app.fileManager.processFrontMatter(tp.config.target_file, frontmatter => {
    frontmatter['uuid'] = uuid
    frontmatter['device'] = device
    frontmatter['tags'] = ['linkedin']
  })
}, 200)
-%>

1 Like

I tried also this “Save to Obsidian” iOS shortcut. It’s a very long iOS script.
It partially works. I don’t like that It asks a lot of questions before saving a note, and second, that it sends the link you are trying to save to a server somewhere else. Still overkill for just calling an existing template when using the iOS button “Share with Obsidian”.

There are 5-6 Save to Obsidian shortcuts on the net, I think. Maybe all of them on this forum.
You can even use Js with Scriptable or shell with A-Shell in conjuction with Shortcuts.
So there are many DIY solutions. All it needs is…yet more tinkering…

1 Like

I will keep trying. The solution I came up is a workaround, not a solution per se. I have also asked the Templater GitHub issues.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.