sigalor / whatsapp-web-reveng

Reverse engineering WhatsApp Web.
MIT License
6.04k stars 802 forks source link

Presence subscription #228

Open grIskra opened 4 years ago

grIskra commented 4 years ago

Is Presence subscription working good?

How can one subscribe contacts presence on web.whatsapp.com using window.Store / WAPI object ?

darioackermann commented 4 years ago

@grIskra Hey. It's working good but you should resubscribe every 5 minutes to ensure you don't miss out on presence updates. In my tests I had about 1 in 20 where presence stayed on online while they've gone offline.

Subscribe Store.Wap.subscribePresence('number@c.us') where NUMBER consists out of country code and local number

get people who are online Store.Presence.filter(a => a.__x_isOnline == true)

Hope that works out for you. Cheers.

Kml55 commented 4 years ago

@baldoius These javascript codes are not working now. Is there new working js now?

darioackermann commented 4 years ago

@Kml55 You need to load the objects first.

window.Store = webpackJsonp([], null, ["bhggeigghg"]).default;
window.Store.Wap = webpackJsonp([], null, ["bihdhbjih"]).default;
Kml55 commented 4 years ago

@Kml55 You need to load the objects first.

window.Store = webpackJsonp([], null, ["bhggeigghg"]).default;
window.Store.Wap = webpackJsonp([], null, ["bihdhbjih"]).default;

Thank you. it works

darioackermann commented 4 years ago

@Kml55 You're welcome. Happy "hacking" ;)

ersinayaz commented 4 years ago

can we subscribe to users who are not registered in the contacts? @baldoius

darioackermann commented 4 years ago

should be possible AFAIK, best is you try it @ersinayaz

Kml55 commented 4 years ago

@baldoius I realized that mobile and web do not behave same. Have you ever faced a problem like that? A communication started from mobile solves the problem.

darioackermann commented 4 years ago

Okay it's possible that you need to start a conversation on mobile first. Alternatively, you can save the person as contact and make sure it's synced (then it should probably work as well.) @Kml55 Let me know whether both work out for you

Kml55 commented 4 years ago

@baldoius I have already saved the contact but it needs mobile touch for new contacts. I will look at appium :)

amoghh commented 4 years ago

Did you'll figure out how to subscribe to presence of a unsaved contact? There must be some way because a lot of apps in play store are now doing this and charge a ton of money for it.

amoghh commented 4 years ago

@grIskra Hey. It's working good but you should resubscribe every 5 minutes to ensure you don't miss out on presence updates. In my tests I had about 1 in 20 where presence stayed on online while they've gone offline.

Subscribe Store.Wap.subscribePresence('number@c.us') where NUMBER consists out of country code and local number

get people who are online Store.Presence.filter(a => a.__x_isOnline == true)

Hope that works out for you. Cheers.

Is There any way i can attach a event handler to a specifc number so that it is triggered when the state changes?

amoghh commented 4 years ago

I still cannot check the presence of an unknown user without interacting with the user on the phone. Does any one know how the countless apps on the playstore do it? This for eg. https://play.google.com/store/apps/details?id=com.wtrack_android

plato79 commented 4 years ago

AFAIS while the subscription works ( the presence is updated ) it doesn't work if the phone screen is off.. web.whatsapp.com doesn't require this. Do you know the cause?

amoghh commented 4 years ago

AFAIS while the subscription works ( the presence is updated ) it doesn't work if the phone screen is off.. web.whatsapp.com doesn't require this. Do you know the cause?

Yes i am facing the same issue.. did you figure it out? can anyone help here who has more knowledge about this?

darioackermann commented 4 years ago

@amoghh @plato79 While I wasn't able to find out what the cause was, resubscribing at a fixed interval made it work for me for almost all contacts, no need to keep the screen on. If you need to keep your screen on, probably your device kills WhatsApp Service in the background?

Kml55 commented 3 years ago

Resubscribing at a fixed interval works for contacts with whom I had already chatted before.

If the whatsapp contact has never been chatted before, I must open a new empty chat on the phone. Then I will get the presence update on whatsapp.web during 10 minutes, after that it will stop giving presence updates.

That's annoying because I want to do it at scale. I can't open every chat every 10 minutes if I have 10000 or 100000 phone numbers to check.

Did you find a solution for this problem? I have a backend everything is OK but without mobile communication presence update is stopped.

I wrote a native android application which iterates contacts and open whatsapp chat screen but this is not a scalable solution. :)

rizwansoaib commented 3 years ago

@Kml55 is your android application open-source

Kml55 commented 3 years ago

@Kml55 is your android application open-source

Hi,

It is a simple code. Critical part is below. You can iterate your contacts.

String URL = "https://api.whatsapp.com/send?phone="+phoneNumber;
Intent intentWhatsapp = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
                intentWhatsapp.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
                        Intent.FLAG_ACTIVITY_CLEAR_TASK |
                        Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intentWhatsapp);
rizwansoaib commented 3 years ago

Thanks but I need automation without using appium is it possible?

Just I have to run my app then open chat then automatically back fetch another next contact via api then open chat then back further continue....

Thanks & regards RIZWAN AHMAD

On Fri 18 Sep, 2020, 2:00 AM Kamil ÇAKIR, notifications@github.com wrote:

@Kml55 https://github.com/Kml55 is your android application open-source

Hi,

It is a simple code. Critical part is below. You can iterate your contacts.

String URL = "https://api.whatsapp.com/send?phone="+phoneNumber; Intent intentWhatsapp = new Intent(Intent.ACTION_VIEW, Uri.parse(URL)); intentWhatsapp.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentWhatsapp);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sigalor/whatsapp-web-reveng/issues/228#issuecomment-694482349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHC2EZGT25242QRTCTIFESLSGJWURANCNFSM4I2FSGCA .

-- Disclaimer:  Messages from 'knit.ac.in http://knit.ac.in' mail server and any associated files may contain information that is confidential, subject to copyright or contains proprietary information. If you are not the intended addressee you are hereby notified that any dissemination, copying or distribution of these messages, or files associated with these messages is prohibited. If you have received the message in error, please notify us by replying to the concerned message and deleting it from your computer. Please also scan the message to verify that it is virus free. Thank you for your time.

This email is governed by the Disclaimer Terms of  KNIT.

sorosons commented 3 years ago

is there anyone fix that subscription problem please help :)

darioackermann commented 3 years ago

@sorosons just seen your e-mail and the comment here.
i suggest you switching to node and this library https://github.com/open-wa/wa-automate-nodejs if your project allows it.

sorosons commented 3 years ago

do you thınk this project will solve my problem

Dario Ackermann notifications@github.com, 4 Oca 2021 Pzt, 15:14 tarihinde şunu yazdı:

@sorosons https://github.com/sorosons just seen your e-mail and the comment here. i suggest you switching to node and this library https://github.com/open-wa/wa-automate-nodejs if your project allows it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sigalor/whatsapp-web-reveng/issues/228#issuecomment-753941918, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASG4T7A37RWRNV5QSCQH2Z3SYGWJXANCNFSM4I2FSGCA .

sorosons commented 3 years ago

do you think should ı completely look this project not using other one ?

Soro Sons sorosonsbt@gmail.com, 4 Oca 2021 Pzt, 15:29 tarihinde şunu yazdı:

do you thınk this project will solve my problem

Dario Ackermann notifications@github.com, 4 Oca 2021 Pzt, 15:14 tarihinde şunu yazdı:

@sorosons https://github.com/sorosons just seen your e-mail and the comment here. i suggest you switching to node and this library https://github.com/open-wa/wa-automate-nodejs if your project allows it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sigalor/whatsapp-web-reveng/issues/228#issuecomment-753941918, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASG4T7A37RWRNV5QSCQH2Z3SYGWJXANCNFSM4I2FSGCA .

Okcor commented 3 years ago

According to the API, it seems https://github.com/open-wa/wa-automate-nodejs only works for chats, not anyone. I do know something that can work for anyone.

There's another node js library called "Baileys" that had a callback function to check the presence for any jid/user. It was deprecated in version 4.0.0, but you can easily add the 2 lines I mention here to get it working again.

I've also been trying to make a dedicated function that you can await to get the first presence update, but I've hit a road block with Baileys' custom callback stuff.