Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I receive (not send) push notification from nodejs?

Tags:

node.js

I'm building a web app to help Airbnb hosts manage their listings. I want to be notified of new reservation instead of pinging Airbnb's servers every few minutes. Airbnb's API doesn't have a way to push data to a server so I thought maybe I could emulate a device and receive push notifications.

Is this possible to emulate a device and receive push notifications in nodejs?

Update

Looks like the iOS app registers for push notifications at the following address:

https://api.airbnb.com/v2/air_notification_devices

with the following data:

{
    "app_version": "19.08",
    "device_type": "iphone_gcm",
    "device_id": "{{DEVICE_ID}}",
    "token": "{{TOKEN}}",
    "enabled": true
}

and with the following cookie:

SRVID=mofi-production-12ab3c456-7defg_172.21.128.38:32350

and returns:

{
    "air_notification_device": {
        "app_version": "19.08",
        "created_at": "2019-03-01T16:27:13Z",
        "device_id": "{{DEVICE_ID}}",
        "device_type": "iphone_gcm",
        "enabled": true,
        "id":{{ID}},
        "locale": "en",
        "token": "{{DIFFERNT_TOKEN}}",
        "updated_at": "2019-03-01T16:27:13Z",
        "user_id": {{USER_ID}}
    },
    "metadata": {}
}
like image 673
Dev01 Avatar asked Feb 19 '19 15:02

Dev01


People also ask

Can I send push notifications without FCM?

Without FCM, you'd need to build more than three notification systems. You'd need one each for iOS and Android, but then you'd also need to accommodate all the different types of browsers for the web application to deliver push notifications without a hitch.

What is pull notification?

Pull notifications are updates delivered to a computer or mobile device in response to a user or software-initiated poll of a remote server. Generally, pull notifications are how noncritical updates and communications are delivered.

How do I turn on push notifications in react JS?

Run the React app and visit your website. You should see the following prompt appear after your chosen time delay interval: Click on the blue Allow button to enable push notifications on your browser.


1 Answers

TL;DR: Yes you can, but without knowledge from receive these notifications you will not do much.

You must look for how the application registers for notifications. As you have the documentation, look for how to sign up for notifications.

BTW: Airbnb has push notification in browser? If so, I would be more interested in this than it was starting to debug the android application.

Without an official API, you'll have a good dose of reverse engineering, but 90% of them used there is FCM from google.

On a publicly available website in English they write only about OAuth2 and updates,but in my language I have:

What can I do with the Airbnb API?

The API allows teams of developers to conduct secure authorization on new and existing Airbnb accounts. Users of your application will have the option of receiving push notifications about content updates, rates and availability. Once Airbnb guests have booked your offer, we will pass on your booking information and details, allowing applications to create your own data flow and deliver amazing experiences to our common guests.

It's worth starting by installing the phone emulator, listen on all network communication and installing the application. But it will not be easy, because you have to do a Man in the middle attack for HTTPS communication.

The option is to decompile the official application and search in the code.

First you need to discover the service used for notifications. If this is FCM, then the process looks like this:

  • The application generates unique token identifying the application instance

  • The application sends this token to Airbnb to sign up for notifications

And I could not find a client in Node that would subscribe to notifications but here is Web (JS), so it is possible. (Again reverse engineering)

There is some about XMPP server receive upstream messages, but better write small app in C++ / Unity which will further forward notifications to Node eg via websocket.

like image 94
bato3 Avatar answered Oct 18 '22 11:10

bato3