ios – Can people on Facebook messenger get a notification when you’re active?

So I have this friend on Facebook, he was a coworker and he took a liking to me as he’s disabled and I helped him out a lot at work.

I moved away and he sent me a voice message from time to time (he can’t type). Every time it was the same “Hi ___, it’s ____”. There isn’t a lot I can’t respond to that, so after a while I stopped replying.

But now, I’ve noticed that as soon as I open the messenger app, within 30 seconds he sends me a new message.

The timing can’t be coincidental – he doesn’t message me otherwise, but as soon as I open the app, a message from him comes through, every time.

My question is, how does he know? Is there a way he can get notifications when I become active (open the app)? Or does he just watch my name 24/7 and wait for me to become active?

database – Notification System Design for Multi User Application

I have a requirement to design a notification system for multi-user(~1000 users) application, here are the high level requirements.

  1. System event gets triggered on specific operations.
  2. On event trigger, individual notification for all(or sometimes only for relevant) users gets generated and stored in database.
  3. While user logs in, all unread notifications for him will be pulled and displayed in ui.
  4. While user reads the notification, we capture the read status.
  5. A scheduler in background evicts all the stale notifications.

This seems like a very typical use case and straight forward to implement with the database.

But my doubt is, is there any way we can replace the Database with the Queue based messaging system? The reason I think this way is because, the use case I have seems like asynchronous in nature(like events, notifications and timely eviction of messages).

While I replace the Database with Queues, the first 2 points from above fits well, but on later part I have some doubts –

  1. In General, are queues flexible to store and query notifications based on user ids ?

  2. Consider this scenario – Notifications gets generated and stored in the queue, and the user is not logged in, what is the best way to handle consumer messages.

    a. Should the consumer constantly listen for the messages ?, If so should the messages be stored in application memory(does not seems to be good option) ?

    b. Or the consumers should be created for each users dynamically on user login? Is this a regular pattern ?

Any other recommended ways ?

Thanks

java – notification channel is not sending notifications

  private void sendNotif(String title , String text , int id) {
        // Create an explicit intent for an Activity in your app
        Intent intent = new Intent(this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "mychannel")
                .setSmallIcon(android.R.drawable.screen_background_light)
                .setContentTitle(title)
                .setContentText(text)
                .setStyle(new NotificationCompat.BigTextStyle()
                        .bigText(text))
                // Set the intent that will fire when the user taps the notification
                .setContentIntent(pendingIntent)
                .setChannelId("mychannel")
                .setAutoCancel(true)
                .setOngoing(false);

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        
        // notificationId is a unique int for each notification that you must define
        notificationManager.notify(id , builder.build());


    }

    private void createNotificationChannel() {
        // Create the NotificationChannel, but only on API 26+ because
        // the NotificationChannel class is new and not in the support library
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            CharSequence name = "notif channel";
            String description = "this is the main notif channel";
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel channel = new NotificationChannel("mychannel", name, importance);
            channel.setDescription(description);
            // Register the channel with the system; you can't change the importance
            // or other notification behaviors after this
            NotificationManager notificationManager = getSystemService(NotificationManager.class);
            notificationManager.createNotificationChannel(channel);
        }
    

I have two simple methods one to send notifications and other to a create a notification channel
Everything seems alright to me, but no notifications are being sent also i would like to mention that the same channel is created twice, although createNotificationChannel () is called once also the docs mentions that :

It’s safe to call this repeatedly because creating an existing
notification channel performs no operation.

but it did obviously

i am using android 10 and here’s my build.gradle file :

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.1"
        defaultConfig {
            applicationId ""
            minSdkVersion 19
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ('*.jar'))
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
        implementation 'com.google.android.material:material:1.2.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.3.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
 
        
    
    }

thanks in advance

design – How does a database update trigger a notification to application layer?

Application component 1(ap1) record/insert/update a new state in graph database(neo4j)

For every new state change in the database, application component 2(ap2) needs to be informed/notified that a new entry(event) is made. ap2 would not like to poll database and track/find for state change.

enter image description here


Both application components will be written in GoLang

Database supports triggers & Stored procedures functionality. It is neo4j database.

OS Environment is Linux

I came acros this article: http://graphdb.ontotext.com/documentation/free/notifications.html

What is the design pattern to make ap2 listen to any new event(immediately) on a database update? without ap2 tracking & polling state changes in database

PostgreSQL enable “notification” via trigger/function

Im trying to create a PostgreSQL “notification” event.
I founy a github gist which describs how it should be done: https://gist.github.com/colophonemes/9701b906c5be572a40a84b08f4d2fa4e

My notify_trigger function looks like this:

CREATE FUNCTION notify_trigger() RETURNS trigger AS $trigger$
DECLARE
  rec RECORD;
  payload TEXT;
  column_name TEXT;
  column_value TEXT;
  payload_items JSONB;
BEGIN
  -- Set record row depending on operation
  CASE TG_OP
  WHEN 'INSERT', 'UPDATE' THEN
     rec := NEW;
  WHEN 'DELETE' THEN
     rec := OLD;
  ELSE
     RAISE EXCEPTION 'Unknown TG_OP: "%". Should not occur!', TG_OP;
  END CASE;
  
  -- Get required fields
  FOREACH column_name IN ARRAY TG_ARGV LOOP
    EXECUTE format('SELECT $1.%I::TEXT', column_name)
    INTO column_value
    USING rec;
    payload_items := coalesce(payload_items,'{}')::jsonb || json_build_object(column_name,column_value)::jsonb;
  END LOOP;

  -- Build the payload
  payload := json_build_object(
    'timestamp',CURRENT_TIMESTAMP,
    'operation',TG_OP,
    'schema',TG_TABLE_SCHEMA,
    'table',TG_TABLE_NAME,
    'data',payload_items
  );

  -- Notify the channel
  PERFORM pg_notify('db_notifications', payload);
  
  RETURN rec;
END;
$trigger$ LANGUAGE plpgsql;

Which gets called from this trigger:

CREATE TRIGGER send_notify AFTER INSERT OR UPDATE OR DELETE ON sentitems
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
  'TextDecoded',
  'CreatorID',
  'SenderID',
  'ID'
);

The problem is, when something happend on the table sentitems i get the following error:

ERROR: operator does not exist: jsonb || jsonb at character 44
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
QUERY: SELECT coalesce(payload_items,'{}')::jsonb || json_build_object(column_name,column_value)::jsonb
CONTEXT: PL/pgSQL function notify_trigger() line 24 at assignment

PostgreSQL version is 9.4.24, which should have the jsonb format/function/schema.

What is the notif_trigger wrong ?

PHP – Web Push Notification – importing subscribers

Currently we run a web push system running in this PHP library.
https://github.com/web-push-libs/web-push-php

Everything works fine – we are able to show the notification client side and then send notifications from the server.
What we want to extend now is the feature of importing subscribers from other Push Services/Companies.

For this we have been told that changing the service worker js file on the client side should help in importing subscribers. We are looking for someone…

PHP – Web Push Notification – importing subscribers