Android Example [B4X] Supabase - Supachat chat example app


This is a simple B4X chat example with supabase as backend.


Setup Supabase
Create dt_Rooms:
create table
  public."dt_Rooms" (
    id bigint generated by default as identity,
    name text not null,
    created_at timestamp without time zone not null default now(),
    created_by uuid not null default auth.uid (),
    constraint dt_Rooms_pkey primary key (id),
    constraint dt_Rooms_created_by_fkey foreign key (created_by) references auth.users (id)
  ) tablespace pg_default;
Create dt_Chat:
create table
  public."dt_Chat" (
    id bigint generated by default as identity,
    room_id bigint not null,
    created_at timestamp without time zone not null default now(),
    created_by uuid not null default auth.uid (),
    message character varying not null,
    constraint dt_Chat_pkey primary key (id),
    constraint dt_Chat_created_by_fkey foreign key (created_by) references users (id),
    constraint dt_Chat_room_id_fkey foreign key (room_id) references "dt_Rooms" (id) on delete cascade
  ) tablespace pg_default;
We need a join on the auth table, this is not possible, so we need to create a new public.users table and create a database function, so we can call it in a database trigger:
dont forget to turn on Realtime and set your RLS permissions
1699734332310.png


Libraries
Have Fun :)
 

Attachments

  • Supabase Chat.zip
    198 KB · Views: 99
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
When you register, we create an anonymous account, the email address and password are randomly generated. If the user deletes and reinstalls the app, they must register again.
Supabase unfortunately does not yet support anonymous login, hence this workaround
 

Alexander Stolte

Expert
Licensed User
Longtime User
link i should to down jetty_b4j.jar
 
Top