Push notifications

I want to share with you.
I asked ChatGPT: is it possible to send push notifications on an applcation created with mit app inventor 2?
here is the answer and tell me what you think:

Yes, it is possible to send push notifications in an application created with MIT App Inventor 2 by using the FirebaseDB component in combination with an external service for managing push notifications, such as Firebase Cloud Messaging (FCM). Here’s how you can set up and implement this functionality:

Steps to Set Up Push Notifications

  1. Configure Firebase in the MIT App Inventor Project:
  • Go to the Firebase Console.
  • Create a new project or use an existing project.
  • Add your Android app to the Firebase project.
  • Follow the instructions to download the google-services.json file and add it to your MIT App Inventor project.
  1. Set Up Firebase Cloud Messaging (FCM):
  • In the Firebase Console, go to the "Cloud Messaging" section.
  • Note your server key and sender ID.
  1. Add and Configure the FirebaseDB Component in the App:
  • Open your project in MIT App Inventor.
  • Add the FirebaseDB component from the components panel.
  • Configure the FirebaseURL and FirebaseToken properties of the component with the values obtained from the Firebase Console.
  1. Send Push Notifications with FCM:
  • Use an external service or a server-side script to send push notifications via FCM. Here’s an example of a Python script to send a push notification:

---------->
CODE:
import requests
import json

def send_push_notification(token, title, body):
server_key = 'YOUR_SERVER_KEY'
headers = {
'Content-Type': 'application/json',
'Authorization': 'key=' + server_key,
}
payload = {
'to': token,
'notification': {
'title': title,
'body': body
}
}
response = requests.post('https://fcm.googleapis.com/fcm/send', headers=headers, data=json.dumps(payload))
print(response.status_code, response.text)

Example usage

device_token = 'DEVICE_REGISTRATION_TOKEN'
send_push_notification(device_token, 'Notification Title', 'Message body')

----------<

Implementation Example

  1. **Set Up FirebaseDB in the App:**Configure the FirebaseDB component with the following properties:
  • FirebaseURL: https://your-project-id.firebaseio.com/
  • FirebaseToken: [Token]
  1. **Use the Notifier Component to Display Notifications:**Configure the Notifier component to display notifications when you receive a push message.
  2. Blocks for Receiving Notifications:

---------->
CODE:
when FirebaseDB1.DataChanged do
call Notifier1.ShowMessageDialog with title DataChanged.Title and message DataChanged.Message
----------<

  1. **Script to Send Push Notifications:**You can use the provided Python script to send push notifications to registered devices.

Final Considerations

  • Ensure that you have the necessary permissions in your AndroidManifest.xml file to receive push notifications.
  • Thoroughly test sending and receiving push notifications on various devices to ensure they work correctly.

By following these steps, you should be able to send and receive push notifications in an application created with MIT App Inventor 2.

Good luck with that :+1:



Let me know if you need a paid FCM extension.

Why?
Are you being ironic? :slight_smile:

Actually, yes.

So it is not possible to do that?

You need an extension.

exists?

Given we are being terse:

Yes, at least one, if not more...

You people are heroes!

Many.

Here is mine: