Still in progress for documentation and testing, but working.
- Import library in your
app
directory
import Crypto from 'fitbit-crypto/app';
- Import
listen()
method and activate it within yourcompanion
file
import { listen } from 'fitbit-crypto/companion';
listen()
- Create a
Text
element within your views with an Id - Initiate Crypto library to create a instance to fetch, display, prices
import Crypto from 'fitbit-crypto/app';
const crypto = new Crypto('elementId', { fromSymbol: 'USD', toSymbol: 'BTC' });
const load = async () => {
const btcPrice = await crypto.getPrice();
console.log('BTC Price', btcPrice);
// Display to the target element
crypto.setPrice();
// Get price to update the target element every second
setInterval(async () => {
await crypto.getPrice();
crypto.setPrice
}, 1000);
};
load();
Use the library to create multiple listener for different crytocurrencies and attach a refresh button to it
import Crypto from 'fitbit-crypto/app';
const btc = new Crypto('btcId', { fromSymbol: 'USD', toSymbol: 'BTC', tapTargetId: 'btcRefreshBtn' });
const doge = new Crypto('dogeId', { fromSymbol: 'USD', toSymbol: 'DOGE', tapTargetId: 'dogeRefreshBtn' });
const eth = new Crypto('ethId', { fromSymbol: 'USD', toSymbol: 'ETH', tapTargetId: 'ethRefreshBtn' });
// Set Initial Prices
btc.getPrice().then(() => btc.setPrice());
eth.getPrice().then(() => eth.setPrice());
doge.getPrice().then(() => doge.setPrice());
fitfont, fromSymbol = 'BTC', toSymbol = 'USD', onPriceChange, tapTargetId, defaultErrorMessage, quickError = true
This module is being used for the following watchfaces:
- Dogee (4.8 ⭐s) - A free dogecoin watchface by Pixels on Ridge
Pixels on Ridge
MIT © Brandon Him