From b826124fa09d26b6d015e90c3f0468f6f1da11c5 Mon Sep 17 00:00:00 2001 From: Valentin <36477338+ValentinWalter@users.noreply.github.com> Date: Wed, 26 May 2021 11:46:14 +0200 Subject: [PATCH] Add Middleman setup documentation --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 9c5675a..d41ebd1 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Honey is based on [Middleman](https://github.com/ValentinWalter/Middleman/), a c - [Setup](#-setup) - [Installation](#installation) - [Configuration](#configuration) + - [Receiving urls](#receiving-urls) - [API](#-api) - [Actions](#-actions) - [Types](#-types) @@ -85,6 +86,37 @@ Provide your API token if you plan on using any actions that require an API toke Edit scheme… > Run > Arguments > Environment Variables ``` +### Receiving urls +As Honey is based on [Middleman](https://github.com/ValentinWalter/Middleman/#-setup), you will need to configure Middleman as well. To receive callbacks you need to make sure your app has a custom url scheme implemented. Middleman will then automatically read the first entry in the `CFBundleURLTypes` array in the main bundle's Info.plist. + +For Middleman to be able to parse incoming urls, you need to put one of the following methods in the delegate (UIKit/Cocoa) appropriate for your platform or in the `onOpenURL` SwiftUI modifier. + +```swift +// SwiftUI +// On any view (maybe in your `App`) +.onOpenURL { url in + Middleman.receive(url) +} + +// macOS +// In your `NSAppDelegate`: +func application(_ application: NSApplication, open urls: [URL]) { + Middleman.receive(urls) +} + +// iOS 13 and up +// In your `UISceneDelegate`: +func scene(_ scene: UIScene, openURLContexts urlContexts: Set) { + Middleman.receive(urlContexts) +} + +// iOS 12 and below +// In your `UIAppDelegate`: +func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + Middleman.receive(url) +} +``` + # 👾 API All actions and types Honey implements are namespaced under `Bear`. The general workflow is to type `Bear.` and choose your desired action from the auto-complete menu. All actions follow the same kind of structure: