Push Notifications Dependency

Why I have repeated this post

I know I have already made a post on it Push Notifications using Firebase but many people faced difficulties in it because I hadn’t provided proper instructions and there were some mistakes in my code as well. So this time, instead of an Example App to take reference from, I have made this available as a proper dependency

I thought about merging this post into the Original Topic but that would have made things messy since it has more than 30 replies and this post would have been buried under all of it.

By the way I tried deleting the original post but apparently I don’t have permission to do it?


If you wish to keep your users informed with Push Notifications, you can do that for your Anvil App as well! This Dependency will allow you to easily send Push Notifications to your users using Firebase Cloud Messaging (FCM). The best part is that it works even in background so even if Users have closed your Anvil App, they can still receive notifications.

To enable Push Notifications for your Anvil App, visit https://push-notifications.anvil.app/ (Sorry for the bad designing)


And if you are wondering why there is no Clone link here, that’s because when you will visit the site and fill the details there, the code will be modified for your needs and a personalized .yaml file will be generated which can be imported as an Anvil App (Tried something new this time :wink:)

If you encounter any problems, feel free to tell me about it.

9 Likes

Certainly a novel idea for sharing code! I like it a lot and it’s very well designed!

1 Like

Awesome, a lot to a beginner like me, but very well documented and please keep this live so that I can always come back to learn it later :slight_smile:

1 Like

error

Hello !!

I get this error when calling

token=firebase.request_push_notifications()

On the client side.

I tried looking at the firebase docs, but no solution found. Do you know how can I solve this security issue?

UPDATE:

After further digging, ended up discovering it was a Firefox issue. Ended up deleting all firefox add-ons and worked.

3 Likes

14 posts were split to a new topic: Push Notification Dependency - using device token

Awesome, so much for a beginner like me, there’s more I would like to learn here in this thread. please keep it live so I can always come back to learn it later.

Added new features to the dependency. Now you can customise your notification with lots of new options and there are also some fixes

Check it out at https://push-notifications.anvil.app/

If you were already using the previous dependency in your app and wish to use the new features, you can remove the existing dependency and generate a new one for yourself from the website.

PS: I tried using the Material Design 3 theme for the first time in a project and it indeed gives what it promises - much prettier apps without making too much changes to CSS.

4 Likes

I get this error even when the notifications are enabled. Any help is appreciated!

Can you tell me which browser you see this on?

By any chance, is it Brave?

Nope, I’m using Chrome

Can you provide something like a clone link or code snippets?

Also, do you see a prompt from your browser to allow notifications? If yes, have you accepted it?

https://anvil.works/build#clone:ITDQC7U6DEDXVBKQ=SNG2NZ7QN7CG5R3YOCFPKDTG

Yes, i accepted the notifications, but I only saw it once. When I ran the app for the first time.

In your clone link, when you were using server.call, the function was not a string and that’s why you were getting error for the function not being defined.

Also, once you accept the notification prompt, you don’t need to accept it every time. You can just use the token you got the first time to send notifications. (For development purposes, you can reset notification permissions for the website on your browser and try again).

Thank you @divyeshlakhotia. I removed the function, ran it again and i still see the error

But do you think there is some issue with firebase configuration?

It works fine on my browser so likely an issue with your browser.

Are you running the app on a private/guest/incognito window?

Nope I’m not running it in private/guest/incognito window

Thanks for the recording. I understood your error. You will have to run your app in a new tab (since your app runs as an iframe on Anvil Editor and iframes do not have notification permissions).

1 Like

I tried running the example app , it says “Push Notifications are not supported on your browser. Please use a different browser”.

Which browser do you suggest?

The key part of @divyeshlakhotia’s response was this:

In the Beta editor, you can accomplish that by clicking the three dots next to the “Run” button and selecting “Run in new tab.”