Auties00 / Cobalt

Standalone unofficial fully-featured Whatsapp Web and Mobile API for Java and Kotlin
MIT License
662 stars 189 forks source link

Can someone please help me get the qr code generation working ? #254

Closed rward27 closed 1 year ago

rward27 commented 1 year ago

Not an issue but just need clarity and help please.

Using version 3.2.3

Below is the code I am trying to use:

public static void main(String[] args) {
     try {
         WhatsappOptions opt = WhatsappOptions.WebOptions
                 .builder()
                 .autodetectListeners(false)
                 .textPreviewSetting(TextPreviewSetting.ENABLED)
                 .historyLength(HistoryLength.THREE_MONTHS)
                 .errorHandler(ErrorHandler.toTerminal())
                 .qrHandler(QrHandler.toTerminal())
                 .build();

         Whatsapp whatsapp = Whatsapp.newConnection(opt);
         whatsapp.connect().join();
     } catch (Exception e) {
         e.printStackTrace();
     }
 }

It never prints anything on the console and doesnt even throw any exception ever. Application just keeps running with no output.

I also tried adding below handler codes but then also nothing is printed.

Whatsapp w = Whatsapp.lastConnection(opt);
            w.addNodeReceivedListener(listener -> {
                System.out.println(listener);
            });

            w.addNodeSentListener(listener -> {
                System.out.println(listener);
            });
            w.connect().join();

Can someone please help me resolving the issue? Issue is that nothing is printed on console, no QR code. I also tried to output QR code on filesystem but that also didnt work at all.