Suggestion: ExtensionKit as next gen replacement for URL schemes

Thanks for adding more URL schemes, but the interface could be vastly improved with the brand-new framework Apple shipped with macOS 13.0 and iOS 16.1, called ExtensionKit / ExtensionFoundation. Apple themselves have just started building new stuff on top of this to enable some of their more recent cutting edge system features, but us devs are also free to use it now.

There are two parts, one for showing iframe-like views that you control in other peoples’ host apps and another for headless extensions across apps. Then other apps would essentially refer people to purchase Anki) if they can embed any useful views or CRUD operations on notes/decks via the headless framework.

FWIW I would implement this immediately in Manabi Reader (I’m about to launch 3.0, not meant to be an ad I can remove the mention), but I want to offer Anki users nice ways to create Anki flashcards and support this app better. A lot of users are interested, it’s the biggest feedback.

Resources:

  • ChimeHQ “extensionkit-intro”, intro on macOS ExtensionKit from before iOS 16.1 launched with ExtensionKit
  • Apple docs
  • iosexample dot com has a good article with a sample app

You’re asking for two separate things here - exposing a new transport mechanism for IPC, and new APIs to be used with it. The latter is probably better solved by introducing something that can be shared across the different Anki clients - I’ve added a note about that on Consider exposing programmatic API ala AnkiConnect in rslib · Issue #2520 · ankitects/anki · GitHub

1 Like

My use case is iOS users who don’t have Anki desktop running or connectable remotely, who want to be able to add flashcards from other iOS apps.

If you add to rslib, then other iOS apps won’t be able to interact with Anki Mobile via it. Cross-app IPC is now supported via ExtensionFoundation. You can’t reliably run servers across iOS apps, it’s fighting the platform like the pasteboard+url scheme approach is. As soon as AnkiMobile gets backgrounded, your IPC server can stop. So I’m not sure how your suggestion is relevant to IPC on iOS.

Improving Anki desktop doesn’t help as much because users already have AnkiConnect (it would just improve adoption) and wouldn’t help most iOS users unless I misunderstand. My macOS users are already able to use AnkiConnect and are a much much smaller audience than iPhone users. Further segmenting the macOS users down to ones who are willing and capable to run home servers to connect their iOS devices seems niche.

I’m not necessarily suggesting new APIs either - if you just port the ‘add notes’ and ‘list profiles and decks’ ones you added to ExtensionFoundation, that would be much better than a pasteboard authorization+url scheme approach.

I’m even open to contributing this to AnkiMobile if you’d permit me (ObjC/Swift/UIKit expertise)

The point of adding it to rslib is so that the mobile clients can provide the same API. It doesn’t necessarily need to be via a http server; it could accept JSON messages over XPC that are then fed into the API for example.

But that’s a somewhat large task, and if you’re just looking for the existing API over an alternative transport, and you’re able to provide an example app under a liberal license that provides the add notes/list profiles methods (stubbed out), that would be appreciated, and greatly increases the chances this will get integrated sooner rather than later.

1 Like

Thank you dae, I understand better now. So you mean put the API into rslib and perhaps have ExtensionFoundation in front of that, so that we can have other frontends to it in other Anki clients for other purposes. If that’s your idea, that sounds great too.

I’m well familiar with your codebase/db but not Rust or your new rslib internals, so I’m inclined to begin outside of it if I’m going to contribute this. I’ll think this over and research it more. I’ll find reason in my own projects to prototype/learn ExtensionFoundation and ExtensionKit soon so I will dual purpose and try to share an Anki version with you soon as well. I’m also open to NDA or whatnot to contribute the prototype directly into the codebase (or even some exposed part of it, I can get pretty far without running it tbh…) if you’re satisfied w/ the prototype.

I think to invest in this big project without getting into rslib, I’d probably have to expand the existing API with one or two endpoints, if I can figure out my minimal needs and see if they’re reasonable additions for yourself, and we can talk about how I can contribute that too, as possible.

It would be ideal to have one of your db exports available via ExtensionFoundation, for example CSV or other representations, I’m not caught up on what’s currently in AnkiMobile capabilities. The use case, personally speaking, is for apps such as a reader app (my Manabi Reader) to be able to show the flashcard learning status of vocabulary and kanji on web content the user is reading. FoundationKit could be used here to require user consent via your own UI to send the selection of export data to that app. I’d also be interested in submitting reviews to AnkiMobile, for use cases such as automatically reviewing flashcards that the user has when they read a page of text with vocab/kanji they have as flashcards (passive review).

Another quick idea I’d pitch to you is via ExtensionKit, allow rendering a flashcard and the grading buttons inside an iframe-like view that runs in AnkiMobile’s process space but appears inside other apps, exactly like WKWebView. Have some kind of review session config as input. Then other apps can add notes to Anki and users can quickly do reviews relevant to the material they’re covering in that other app. This kind of integration could introduce serious sales funnels for AnkiMobile. Personally speaking, I’d love to send more users to Anki and help them stay there for their flashcard needs, in ways that mutually bring value to users of my own apps. This is definitely an independent project, but a good example of something that you can do specially in Apple’s environment to expose the UI to other apps in a way that might not make sense with much inside rslib. Something to consider after the ExtensionFoundation (without FoundationKit for UI) project above.

Speaking as another software professional please let me know how I can best align the above with your aims and contribute it with minimal distraction. Thanks for your time.

1 Like

Yep.

CSV export is supported and could potentially be exposed via an API.

Anki doesn’t support answering cards outside of regular study, but cards can be forgotten/rescheduled to a different review date.

Let’s focus on the Foundation stuff first :slight_smile:

2 Likes

Perfect. If I can export, forget/extend due dates, and add cards as a minimum, this is worthwhile for me to work on / contribute. I’ll update you next with the initial sample project.

2 Likes