carlomigueldy.eth
07/23/2021, 11:58 AMfenix
07/23/2021, 4:19 PMwiesson
07/23/2021, 5:48 PMzlwaterfield
07/26/2021, 2:49 AMrichard
07/26/2021, 6:15 PMScott P
07/26/2021, 6:21 PMpbad
07/26/2021, 6:48 PMcopple
07/27/2021, 2:38 AMVolkan
07/27/2021, 2:40 AMcopple
07/27/2021, 8:37 AMTyler
07/27/2021, 8:58 AMuser
07/27/2021, 2:50 PMuser
07/27/2021, 2:50 PMengj
07/27/2021, 5:56 PMuser
07/27/2021, 5:58 PMlawrencecchen
07/28/2021, 7:10 AMKosh
07/28/2021, 11:59 AMTrigger:
create trigger notification_inserted
after
insert
on notifications FOR EACH ROW EXECUTE PROCEDURE on_notification_created();
on_notification_created basically, construct some data and eventually call this method below::
create
or replace function send_push(
push_token text,
title text,
body text,
ref_id uuid,
creator_id uuid,
n_type text
) returns void as $$
SELECT
status,
content
FROM
http(
(
'POST',
'https://fcm.googleapis.com/fcm/send',
ARRAY [ http_header(
'Authorization',
'key=myawesomekey'
),
http_header('Content-Type', 'application/json') ],
'application/json',
(
select
get_fcm_body(
push_token,
title,
body,
ref_id,
creator_id,
n_type
)
)
) :: http_request
);
$$ language sql;
I believe this is worth mentioning as alot of who is switching from firebase will definitely want this until workflow is implemented.
happy supabase'ing.Azura
07/28/2021, 12:01 PMKosh
07/28/2021, 12:01 PMcreate
or replace function get_fcm_body(
push_token text,
title text,
body text,
ref_id uuid,
creator_id uuid,
n_type text
) returns json AS $$
declare
notification json;
n_data json;
begin
notification := json_build_object(
'title', title,
'body', body,
'clickAction', 'FLUTTER_NOTIFICATION_CLICK',
'sound', 'default',
'tag', ref_id::text
);
n_data := json_build_object(
'title', title,
'body', body,
'type', n_type,
'refId', ref_id,
'creatorId', creator_id::text
);
return json_build_object(
'to', push_token,
'notification', notification,
'data', n_data
);
end;
$$ language plpgsql;
! Class self.PythonAddict = True
07/28/2021, 12:12 PMProbablyBatman
07/28/2021, 4:08 PMFlyken
07/28/2021, 8:54 PMhttps://i.imgur.com/DHUVNOy.pngβΎ
vblinden
07/29/2021, 1:23 PMwiesson
07/29/2021, 7:26 PMFlyken
07/29/2021, 10:14 PMhttps://i.imgur.com/xs6O3sB.pngβΎ
Flyken
07/29/2021, 10:14 PMDhaiwat10
07/30/2021, 1:57 AMuser
07/30/2021, 1:14 PM