Skip to content

Instantly share code, notes, and snippets.

@kmerrell42
Last active April 18, 2017 20:51
Show Gist options
  • Save kmerrell42/99d0f62a2700b1e9260dc9f115300eed to your computer and use it in GitHub Desktop.
Save kmerrell42/99d0f62a2700b1e9260dc9f115300eed to your computer and use it in GitHub Desktop.
Create a BroadcastReceiver that accepts a callback to let us know the verification code has been received
public class SmsBroadcastReceiver extends BroadcastReceiver {
private final OnVerificationCodeReceivedListener codeReceivedListener;
public SmsBroadcastReceiver(@NonNull OnVerificationCodeReceivedListener codeReceivedListener) {
this.codeReceivedListener = codeReceivedListener;
}
@Override
public void onReceive(Context context, Intent intent) {
// TODO: See if this message is coming from the expected phone number
// TODO: If so, parse the code out of the message and notify the callback
}
interface OnVerificationCodeReceivedListener {
void onVerificationCodeReceived(String code);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment