Skip to content

How to implement Web Push Notifications on your own domain? #79

Answered by smeijer
nordhagen asked this question in Questions
Discussion options

You must be logged in to vote

Hi,

Very sorry about that. That blog post had a couple of errors. I've fixed the snippet, but the MagicBell provider is not covered in that post.

Re the solution, I've just pushed out a new version of our react sdk. Due to recent api changes, you'll need to use @magicbell/[email protected] or later to use the PushNotificationsSubscriber component.

Your custom component should look like:

import { PushNotificationsSubscriber } from '@magicbell/magicbell-react';

function EnablePushNotificationsButton() {
  return (
    <PushNotificationsSubscriber serviceWorkerPath="/service-worker.js">
      {({ createSubscription }) => (
        <button onClick={createSubscription}>
          Enable …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by smeijer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Questions
Labels
None yet
3 participants