public class

SCVerifyNumberFacade

extends Object
java.lang.Object
   ↳ com.c2call.sdk.pub.facade.SCVerifyNumberFacade

Class Overview

This singleton provides a low-level API to handle phone number verification.

Summary

Nested Classes
class SCVerifyNumberFacade.VerificationData  
Protected Constructors
SCVerifyNumberFacade()
Public Methods
synchronized void clearSavedData(Context context)
Clear all saved validation data.
String generateCode(int codeLength)
Convenient method to generate a random numeric string of a given length
int getCodeLength(Context context)
synchronized SCVerifyNumberFacade.VerificationData getVerificationData(Context context)
Get the stored #SCVerifyNumberFacade.VerificationData if any.
int getWrongCodeCount(Context context)
Returns the count how often a code validation failed.
int incWrongCodeCount(Context context)
Manually increment the counter of wrong code entries by 1.
static SCVerifyNumberFacade instance()
Returns the singleton instance
boolean isVerificationDataAvailable(Context context)
Checks if verification data is available.
synchronized int numberVerificationForRegister(String phoneNumber, String pinMessage, boolean forcePinCall)
If you want to implement a WhatsApp style user registration with phone number, use this method to submit a verification PIN to the users phone.
void resetWrongCodeCount(Context context)
Resets the counter of wrong code entries to 0.
synchronized String saveVerificationData(Context context, String number, String code)
Manually save verification data.
synchronized boolean sendVerificationCode(Context ctx, String number, String code)
Sends a verification code to a given number.
void setWrongCodeCount(Context context, int value)
Manually set the counter of wrong code entries.
synchronized boolean updateProfileNumber(Context ctx, String number)
Update the user's profile with the given phone number.
synchronized boolean validateCode(Context ctx, String code, boolean autoUpdateProfile)
Compares a given code to the last code sent by sendVerificationCode(Context, String, String)
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected SCVerifyNumberFacade ()

Public Methods

public synchronized void clearSavedData (Context context)

Clear all saved validation data.

public String generateCode (int codeLength)

Convenient method to generate a random numeric string of a given length

Parameters
codeLength the length of the generated code
Returns
  • the generated random code

public int getCodeLength (Context context)

public synchronized SCVerifyNumberFacade.VerificationData getVerificationData (Context context)

Get the stored #SCVerifyNumberFacade.VerificationData if any.

Returns
  • the stored verification data or null if nothing was stored.

public int getWrongCodeCount (Context context)

Returns the count how often a code validation failed. This number is maintained acrooss restarts.

Returns
  • the count of invalid code entries.

public int incWrongCodeCount (Context context)

Manually increment the counter of wrong code entries by 1. This is called automatically by validateCode(Context, String, boolean) if the given code was not valid.

Returns
  • the new counter value.

public static SCVerifyNumberFacade instance ()

Returns the singleton instance

Returns
  • the singleton instance

public boolean isVerificationDataAvailable (Context context)

Checks if verification data is available. I.e. a verification code was sent to a mobile number.

Returns
  • true if verification data is available

public synchronized int numberVerificationForRegister (String phoneNumber, String pinMessage, boolean forcePinCall)

If you want to implement a WhatsApp style user registration with phone number, use this method to submit a verification PIN to the users phone. Typically the PIN will be submitted as SMS, however for landline phone numbers or some mobile networks, SMS will not be received by the user. In this case, use forcePinCall, the user will be then called on his phone and the PIN code will be read to the user. This method requires to master credit in your developer account, as the costs for the SMS or the PIN Call will be charged from your master credit. In case of SMS, a PIN message can be specified. Please use %PIN as placeholder where the actual PIN will be set in your message text.

Parameters
phoneNumber phone number in E.164 format (e.g. +1408123456)
pinMessage The PIN Message sent to the user or null (default message is: "PIN: ")
forcePinCall if true then use a pin call instead of SMS, otherwise use SMS if possible and fall back to a pin call.
Returns
  • 0 on success

public void resetWrongCodeCount (Context context)

Resets the counter of wrong code entries to 0.

public synchronized String saveVerificationData (Context context, String number, String code)

Manually save verification data. This is automaticaly done if sendVerificationCode(Context, String, String) succeeds.

Parameters
number the phone number to by verified
code the code that was send to the phone number
Returns
  • a MD5 representation of the sent code.

public synchronized boolean sendVerificationCode (Context ctx, String number, String code)

Sends a verification code to a given number. The message text is taken from the string resource, R.string.sc_verifynumber_pin_message which must contain a format specifier (%s) where the code will be included. Must not be called from main-thread.

Parameters
number the number to which the verification code will be sent.
code the code to send
Returns
  • true on success.

public void setWrongCodeCount (Context context, int value)

Manually set the counter of wrong code entries. This is called automatically by validateCode(Context, String, boolean) if the given code was not valid.

Returns
  • the new counter value.

public synchronized boolean updateProfileNumber (Context ctx, String number)

Update the user's profile with the given phone number. Must not be called from main-thread.

Parameters
number the number to update
Returns
  • true on success.

public synchronized boolean validateCode (Context ctx, String code, boolean autoUpdateProfile)

Compares a given code to the last code sent by sendVerificationCode(Context, String, String)

Parameters
code the code to check
autoUpdateProfile set this to true to automatically update the user's profile on success. Otherwise you have to call updateProfileNumber(Context, String) manually.
Returns
  • true if the given code was valid.