MAC - Bear: Retrieve Tags and Send

I love the “Bear: Retrieve Tags and Send” Action - is there any way to use it on Mac?

@derekvan what would you say?

This works for me on Mac. What problems are you having?

The version in the Action Directory is only set-up for iPhone and iPad, no Mac - there’s no check for a Mac model in the code.

The first time you run it, it will request your Bear API tokens for all devices, so have those handy. You can retrieve the token for each device from Bear in Settings—>General—>API Token. Unfortunately, each device you use will use a different token. Hopefully you only have one iPhone and one iPad—if you have multiple of either I’m pretty sure this won’t work right.

Here’s the relevant section of code.

var credential = Credential.create("Bear Tokens", "Bear requires these tokens to retrieve tags using the x-callback url requests. Unfortunately, the tokens are different on iPhone and iPad even with the same iCloud account so you will need to paste both in here when requested.");

credential.addPasswordField("iphone", "iPhone token");
credential.addPasswordField("ipad", "iPad token");


var model = device.model;
var iphone = credential.getValue("iphone");
var ipad = credential.getValue("ipad");

// test whether device is iPhone or iPad to use the correct token

if (model == "iPhone") {
	var beartoken = iphone;
else if (model == "iPad") {
	var beartoken = ipad;

I've reworked the version on the Action Directory and tested it on a Mac and an iPhone.

This version should work for any number of devices of any model. The action is generating a unique ID and storing that in local storage. This ID is created if it does not exist, or read if it does exist. It is then used as part of the name of the credential identifier, thus each device will have a unique credential identifier to store its unique Bear API token.

I’ve also added in some additional tag processing to exclude blank/empty tags that can be retrieved from Bear and to account for tags that have spaces in them (they get closed by a closing hash symbol).

I’ve also reworked some other bits of logic too, but the procedure is still very much based around the original.

Hope that helps.

1 Like

Thanks! I guess I had done something similar on my end but never uploaded a more recent action.

1 Like

Thank you all very much. I am supremely grateful!

1 Like