### Run Node.js Sample Server - Node.js/Shell Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Starts the main Node.js application file ('app.js'), which runs the sample OTP server. The server will listen for incoming API requests, typically on port 3000. Requires Node.js installed. ```Shell node app.js ``` -------------------------------- ### Run Python Setup Script - Python/Shell Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Executes the main Python setup script ('setup.py'). This script typically handles tasks like creating the WhatsApp OTP message template and collecting necessary information. Requires Python3 installed. Includes an alternative command for specific Python versions. ```Shell python3 setup.py ``` ```Shell python3.8 setup.py ``` -------------------------------- ### Install Python Dependencies - pip3 Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Installs all necessary Python packages for the setup script. The packages are listed in the 'requirements.txt' file within the 'setup' directory. Requires Python3 and pip3 to be installed. ```Shell pip3 install -r requirements.txt ``` -------------------------------- ### Install Node.js Dependencies - npm Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Installs all necessary Node.js packages for the sample server application. Dependencies are typically defined in a 'package.json' file. Requires Node.js and npm to be installed. ```Shell npm install ``` -------------------------------- ### Navigate to Setup Directory - Shell Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Changes the current directory in the terminal to the 'setup' subdirectory. This is a required step before installing Python dependencies or running the setup script. ```Shell cd setup/ ``` -------------------------------- ### Navigate to Server Directory - Shell Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Changes the current directory in the terminal to the 'server' subdirectory. This is a required step before installing Node.js dependencies or running the sample server application. ```Shell cd server/ ``` -------------------------------- ### Send OTP via GET Request - cURL Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Demonstrates how to make a GET request to the running sample server's '/otp/:phone_number/' endpoint using the cURL command-line tool. This triggers the server to send an OTP to the specified phone number. ```cURL curl -X GET HTTP://127.0.0.1:3000/otp/:phone_number/ ``` -------------------------------- ### Verify OTP via POST Request - cURL Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Server/README.md Demonstrates how to make a POST request to the running sample server's '/otp/:phone_number/' endpoint using the cURL command-line tool. The request body must be JSON containing the 'code' field with the OTP to be verified. ```cURL curl -X POST HTTP://127.0.0.1:3000/otp/:phone_number/ -d '{"code": ""}' -H "Content-Type: application/json" ``` -------------------------------- ### Registering WhatsApp OTP Handlers in Android Manifest XML Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Android/README.md This Android Manifest XML snippet registers an Activity (WhatsAppCodeReceiverActivity) and a BroadcastReceiver (OtpCodeReceiver) to listen for the com.whatsapp.otp.OTP_RETRIEVED intent from WhatsApp. This setup allows the application to receive and process OTP codes for one-tap and zero-tap autofill functionalities. Dependencies include the WhatsApp OTP SDK and the corresponding Activity/Receiver classes. ```XML ``` -------------------------------- ### Using Mockingbird in Swift Tests Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/iOS/mockingbird/src/README.md This Swift snippet demonstrates the core usage of Mockingbird in a unit test. It shows how to create a mock instance of a type, stub a property's return value using 'given' and 'willReturn', and verify that a specific method was called on the mock using 'verify' and 'wasCalled'. ```swift // Mocking let bird = mock(Bird.self) // Stubbing given(bird.canFly).willReturn(true) // Verification verify(bird.fly()).wasCalled() ``` -------------------------------- ### Configuring Mockingbird Swift (Console) Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/iOS/mockingbird/src/README.md This console command configures the Mockingbird framework for a specific test target within your Swift project. It sets up the necessary build settings and files for automatic mock generation. ```console $ mockingbird configure BirdTests -- --target Bird ``` -------------------------------- ### Initiating WhatsApp OTP Handshake in Java Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/Android/README.md This Java snippet shows how to initiate the handshake process required for WhatsApp OTP autofill functionality. It creates an instance of WhatsAppOtpHandler and calls sendOtpIntentToWhatsApp, passing the application context. This method sends an intent to WhatsApp to perform the necessary handshake for receiving OTP codes. The snippet relies on the WhatsApp-OTP-SDK. ```Java WhatsAppOtpHandler whatsAppOtpHandler = new WhatsAppOtpHandler(); whatsAppOtpHandler.sendOtpIntentToWhatsApp(context); ``` -------------------------------- ### Generating Mockingbird Mocks Manually (Console) Source: https://github.com/whatsapp/whatsapp-otp-sample-app/blob/main/iOS/mockingbird/src/README.md This command manually triggers the generation of mock classes using the Mockingbird CLI. It specifies the test bundle, the target containing the types to be mocked, and the output path for the generated Swift file. ```console $ mockingbird generate --testbundle BirdTests --target Bird --output Mocks.generated.swift ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.