-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Switch between QR or phone number pairing method #3180
base: main
Are you sure you want to change the base?
Conversation
…app-web.js into webpack-exodus
…app-web.js into webpack-exodus
…ommit for some reason)
…app-web.js into webpack-exodus
…edroslopez#3001) * Change window.Store.ProfilePic.profilePicFind to window.Store.ProfilePic.requestProfilePicFromServer * Prevent breaking v2.2x * refactor: make it more readable --------- Co-authored-by: alechkos <[email protected]>
93e9b57
to
adbfb3d
Compare
When this pull request will be merged? |
While waiting for merge, anyone who wants to use this feature can do so by installing this version: I'll do my best to keep it updated with the |
This merge is really very useful and would help a lot!! |
b018166
to
b5c64b8
Compare
if (window.codeInterval) { | ||
clearInterval(window.codeInterval); // remove existing interval | ||
} | ||
window.codeInterval = setInterval(async () => { | ||
if (window.AuthStore.AppState.state != 'UNPAIRED' && window.AuthStore.AppState.state != 'UNPAIRED_IDLE') { | ||
clearInterval(window.codeInterval); | ||
return; | ||
} | ||
window.onCodeReceivedEvent(await getCode()); | ||
}, intervalMs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MobCode100 Is there a way we could get rid of this custom interval and use the WhatsApp one? Maybe there is an event that triggered once the code is expired and we can subscribe to this event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anyway to find out? Using inspect element or some tool? I will do my own research on this later.
Co-authored-by: Leandro Matilla <[email protected]>
MobCode100 Could you please update your reposirory with last commit? 👉 https://github.com/MobCode100/whatsapp-web.js Im using it in my |
Sorry for late. Done! Thank you very much for your review. |
PR Details
The ability to change the preferred login/authentication method either use QR code or pair with a phone number (Linked devices -> Link a device -> Link with phone number instead).
Description
pairWithPhoneNumber
which is an object containing the parameters forrequestPairingCode
function in Client.js. The attributes of this object are:phoneNumber
: Phone number in international, symbol-free format <COUNTRY_CODE><PHONE_NUMBER>showNotification
: Show notification to pair for the specified phone numberintervalMs
: The interval in milliseconds on how frequent to generate pairing code (WhatsApp default to 3 minutes)code
andwindow.onCodeReceivedEvent
event will run a callback once a code has been generated.The
inject
function in Client.js will check if thephoneNumber
option is set, and will switch to phone number pairing mode without running any QR related functions.intervalMs
is the time to wait for the next generation of code to mitigate the problem of expired code.Related Issues
closes ##3370 fixes #3371
Motivation and Context
requestPairingCode
without having to manually utilize the functionHow Has This Been Tested
To run or test this feature, run
node app.js
where app.js contains the following code:The pairing code should be displayed to the terminal every 3 minutes. Developer tools are used to inspect some variables while running in non-headless mode. So far, no issues have been encountered during testing on QR code functions or any other existing features.
Types of changes
Checklist