Sending Code via WhatsApp

By default, when the user enters a phone number, we'll send a verification code using SMS. You can add the option for your users to receive the verification code as a WhatsApp message.

How to Add the WhatsApp Option

1) Using verify.openAuth('PHONE')

If you choose to open the in-app browser with no predefined input using where the user can enter email or phone in the in-app browser), update your code like below:

class Register extends PureComponent {
  ...
  openCotterAuth = async () => {
    var verify = new Verify(...);
    
    await verify.openAuth(
      'PHONE', 
      ['SMS', 'WHATSAPP'], // 👈 Add ['SMS', 'WHATSAPP'] as a parameter
    );
  };
};

Possible options are:

  • ['SMS'] (default, sms only)

  • ['SMS', 'WHATSAPP'] (allow both)

  • ['WHATSAPP'] (WhatsApp only)

2) Using verify.openAuthWithInput('PHONE', this.state.phone)

If you choose to open the web browser after the user entered their email or phone number in your app's input field, you can set it to automatically send the verification code via WhatsApp:

class Register extends PureComponent {
  ...
  openCotterAuth = async () => {
    var verify = new Verify(...);
    await verify.openAuthWithInput(
      'PHONE', 
      this.state.phone, 
      'WHATSAPP', // 👈 'WHATSAPP' as a parameter to automatically send code via WhatsApp
    );
  };
  
  
  // Possible options are:
  // - 'SMS'                (default, send code via SMS)
  // - 'WHATSAPP'           (send code via WHATSAPP)
  ...
}

Possible options are:

  • 'SMS' (default, send code via SMS)

  • 'WHATSAPP' (send code via WhatsApp)

WhatsApp Opt-In Requirements

WhatsApp requires that your application implement explicit user opt-ins to deliver messages over WhatsApp.

Since the in-app browser will automatically send the code via WhatsApp, you need to inform your users that we will send a message to their WhatsApp account. Make sure you make the following things clear:

  • The phone number that will receive the message

  • That the user does an action (press a button or a checkbox) to acknowledge that the code is sent via WhatsApp (show the WhatsApp logo, using assets and color from https://whatsappbrand.com/)

  • If necessary, add a text explaining what message you'll be sending, for example:"If you choose to login with WhatsApp, we will send a WhatsApp message to this number with a verification code".

Please make sure that your customer is informed that they will be receiving a WhatsApp message, otherwise your application may be suspended. This includes using the appropriate language that your users can understand.

Last updated