Ameur MM
 · CEO Talbiah | intermediate FF

Issue in push notification with supabase

Database & APIs

Hi! I would ask about push notification with supabase, i follow the steps to install supabase locally, and create an edge function + webhook on supabase to listen to my table (notification), but in the custom action (initializamessaging) which supabase call firebase to do the notification= i can't run it, because the dependencies and it versions?! i've tried many versions but nothing happend..

could you see it and give your opinion in it ?

What have you tried so far?

/ Automatic FlutterFlow imports

import '/backend/schema/structs/index.dart';

import '/backend/supabase/supabase.dart';

import '/flutter_flow/flutter_flow_theme.dart';

import '/flutter_flow/flutter_flow_util.dart';

import '/custom_code/actions/index.dart'; // Imports other custom actions

import '/flutter_flow/custom_functions.dart'; // Imports custom functions

import 'package:flutter/material.dart';

// Begin custom action code

// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:firebase_core/firebase_core.dart';

import 'package:firebase_messaging/firebase_messaging.dart';

import 'package:awesome_notifications/awesome_notifications.dart';

Future initializaMessaging() async {

// Add your function code here!

await Firebase.initializeApp();

FirebaseMessaging.instance.requestPermission().then((settings) {

if(settings.authorizationStatus == AuthorizationStatus.authorized){

FirebaseMessaging.instance.getToken().then(token) {

FFAppState().fcmToken= token ?? 'No token';

});

} else{

FFAppState().fcmToken= 'No token';

}

});

await AwesomeNotifications().initialize(

null, //'resource://drawable/res_app_icon',//

[

NotificationChannel(

channelKey: 'alerts',

channelName: 'Alerts',

channelDescription: 'Notification tests as alerts',

playSound: true,

onlyAlertOnce: true,

groupAlertBehavior: GroupAlertBehavior.Children,

importance: NotificationImportance.High,

defaultPrivacy: NotificationPrivacy.Private,

defaultColor: Colors.deepPurple,

ledColor: Colors.deepPurple)

],

debug: true);

//String? token = await FirebaseMessaging.instance.getToken();

//FFAppState().token = token ?? 'No token';

//FirebaseMessaging.instance.getInitialMessage().then((message) {

//if (message != null) {

// print('received initial message: ${message.notification.title}');

//}

//});

FirebaseMessaging.onMessage.listen((RemoteMessage message) async {

print('received message1: ${message.notification.title}');

await AwesomeNotifications().createNotification(

content: NotificationContent(

id: -1, // -1 is replaced by a random number

channelKey: 'alerts',

title: 'Huston! The eagle has landed!',

body:

"A small step for a man, but a giant leap to Flutter's community!",

//bigPicture: 'https://storage.googleapis.com/cms-storage-bucket/d406c736e7c4c57f5f61.png',

//largeIcon: 'https://storage.googleapis.com/cms-storage-bucket/0dbfcc7a59cd1cf16282.png',

//'asset://assets/images/balloons-in-sky.jpg',

//notificationLayout: NotificationLayout.BigPicture,

payload: {'notificationId': '1234567890'}),

actionButtons: [

NotificationActionButton(key: 'REDIRECT', label: 'Redirect'),

NotificationActionButton(

key: 'REPLY',

label: 'Reply Message',

requireInputText: true,

actionType: ActionType.SilentAction),

NotificationActionButton(

key: 'DISMISS',

label: 'Dismiss',

actionType: ActionType.DismissAction,

isDangerousOption: true)

]);

});

// FirebaseMessaging.onMessage.listen((RemoteMessage message) {

// print('received message2: ${message.notification.title}');

//});

//FirebaseMessaging.onBackgroundMessage((message) async {

// print('received message2: ${message.notification.title}');

//});

}

Did you check FlutterFlow's Documentation for this topic?
No
2 replies