magicbell-js

JavaScript/TypeScript SDK monorepo for MagicBell - The real-time notification inbox for web & mobile apps

OTHER License

Downloads
139.2K
Stars
28
Committers
19

Bot releases are hidden (Show)

magicbell-js - @magicbell/[email protected]

Published by MagicBella 4 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 4 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 4 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 4 months ago

Minor Changes

  • #296 fd91c86 Thanks @smeijer! - Move fields to query params for api get requests. This makes it just slightly easier to form urls for GET request when using the api escape hatch in our cli.

    mb api '/notifications' -f seen=false -X get -c user -r curl
    
    curl --url 'https://api.magicbell.com/notifications?seen=false' \
      --request 'GET' \
      --header 'accept: application/json' \
      --header 'accept-version: v2' \
      --header 'x-magicbell-api-key: 8cd...c70' \
      --header 'x-magicbell-user-email: [email protected]' \
      --header 'x-magicbell-user-hmac: uaZ...hU='
    

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Major Changes

  • #283 7bea88f Thanks @smeijer! - BREAKING CHANGE!

    This is a complete revamp of how we're registering client push notification subscriptions, but given that the v1 API surface is small, migrating should be easy enough. You can find the migration guide on our site.

    The methods mentioned here are the breaking ones that you use when interacting with the browser directly. We've also added a bunch of functions to interact with the MagicBell API directly, leaving all browser interaction for you to implement. Think of use cases where you already have a service worker, and just want to push the channel tokens to our backend, or because you need to list all the currently active channel tokens so the user can unsubscribe from a device they no longer control.

    Please read more about those methods in the docs for @magicbell/webpush

    import { WebPushClient } from '@magicbell/webpush';
    
    const client = new WebPushClient({
      apiKey: '024…0bd',
      userEmail: '[email protected]',
      userHmac: 'NCI…I6M',
    });
    
    await client.isSubscribed();
    await client.subscribe();
    await client.unsubscribe();
    

    Subscribe to push notifications:

    Subscribing to push notifications is now a single call on the client, instead of the two-step flow from v1.

    - import { getAuthToken, subscribe } from '@magicbell/webpush';
    + import { WebPushClient } from '@magicbell/webpush';
    
    - const token = await getAuthToken({
    + const client = new WebPushClient({
      apiKey: '024…0bd',
      userEmail: '[email protected]',
      userHmac: 'NCI…I6M',
    });
    
    - await subscribe({
    -   token: token.token,
    -   project: token.project,
    - });
    
    + await client.subscribe();
    

    Unsubscribe from push notifications.

    This is a new method that didn't exist in previous versions. Unsubscribing and resubscribing is now trivial, giving your users the option to "pause" the push notifications.

    import { WebPushClient } from '@magicbell/webpush';
    
    const client = new WebPushClient({
      apiKey: '024…0bd',
      userEmail: '[email protected]',
      userHmac: 'NCI…I6M',
    });
    
    await client.unsubscribe();
    

    Get subscription status

    Verifying subscription status is now a single call on the client, instead of the two-step flow from v1.

    - import { getAuthToken, isSubscribed } from '@magicbell/webpush';
    + import { WebPushClient } from '@magicbell/webpush';
    
    - const token = await getAuthToken({
    + const client = new WebPushClient({
      apiKey: '024…0bd',
      userEmail: '[email protected]',
      userHmac: 'NCI…I6M',
    });
    
    - const subscribed = await isSubscribed({
    -   token: token.token,
    -   project: token.project,
    - });
    
    + const subscribed = await client.isSubscribed();
    

    Get authentication token

    The authentication token is no longer required for basic functionality, but can still be used to for example transfer the session to a popup.

    - import { getAuthToken } from '@magicbell/webpush';
    + import { WebPushClient } from '@magicbell/webpush';
    
    - const token = await getAuthToken({
    + const client = new WebPushClient({
      apiKey: '024…0bd',
      userEmail: '[email protected]',
      userHmac: 'NCI…I6M',
    });
    
    + const token = await client.getAuthToken();
    

    API Methods

    We've added a bunch of useful methods to work with our api directly. Please read more about those methods in the docs for @magicbell/webpush.

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - [email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Minor Changes

  • #276 702ee27 Thanks @smeijer! - Support reading email or external id for user commands from profile. With this change, instead of running magicbell user notifications list --user-email [email protected], one can run also run:

    # magicbell user notifications list --user-email [email protected]
    magicbell config set userEmail [email protected]
    magicbell user notifications list
    

    or

    # magicbell user notifications list --user-external-id abc
    magicbell config set userExternalId abc
    magicbell user notifications list
    

    Note that the arguments still take precedence when provided.

  • #277 8f20dec Thanks @smeijer! - Show command description in the help for that specific command.

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - [email protected]

Published by MagicBella 5 months ago

Patch Changes

magicbell-js - @magicbell/[email protected]

Published by MagicBella 5 months ago

Patch Changes

Package Rankings
Top 4.27% on Npmjs.org
Related Projects