This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
def work_version = "2.2.0" | |
// (Java only) | |
implementation "androidx.work:work-runtime:$work_version" | |
// Kotlin + coroutines | |
implementation "androidx.work:work-runtime-ktx:$work_version" | |
// optional - RxJava2 support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppSignatureHelper extends ContextWrapper { | |
public static final String TAG = AppSignatureHelper.class.getSimpleName(); | |
private static final String HASH_TYPE = "SHA-256"; | |
public static final int NUM_HASHED_BYTES = 9; | |
public static final int NUM_BASE64_CHAR = 11; | |
public AppSignatureHelper(Context context) { | |
super(context); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<receiver android:name=".MySMSBroadcastReceiver" android:exported="true"> | |
<intent-filter> | |
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED" /> | |
</intent-filter> | |
</receiver> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySMSBroadcastReceiver : BroadcastReceiver() { | |
private var otpReceiver: OTPReceiveListener? = null | |
/** | |
* @param receiver OTPReceiveListener | |
*/ | |
fun initOTPListener(receiver: OTPReceiveListener) { | |
this.otpReceiver = receiver | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun startSMSListener() { | |
val client = SmsRetriever.getClient(this /* context */) | |
val task = client.startSmsRetriever() | |
task.addOnSuccessListener { | |
// Successfully started retriever, expect broadcast intent | |
// ... | |
// otpTxtView.text = "Waiting for the OTP" | |
Timber.e("SMS Retriever starts") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Obtain the phone number from the result | |
fun onActivityResult(requestCode:Int, resultCode:Int, data:Intent) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if (requestCode == RESOLVE_HINT) | |
{ | |
if (resultCode == RESULT_OK) | |
{ | |
val credential = data.getParcelableExtra(Credential.EXTRA_KEY) | |
// credential.getId(); <-- will need to process phone number string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Construct a request for phone numbers and show the picker | |
private fun requestHint() { | |
val hintRequest = HintRequest.Builder() | |
.setPhoneNumberIdentifierSupported(true) | |
.build() | |
val intent = Auth.CredentialsApi.getHintPickerIntent( | |
apiClient, hintRequest) | |
startIntentSenderForResult(intent.getIntentSender(), | |
RESOLVE_HINT, null, 0, 0, 0) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation 'com.google.android.gms:play-services-base:11.6.0' | |
implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0' | |
//Optional for phone number hint | |
implementation 'com.google.android.gms:play-services-auth:11.6.0' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.res.ColorStateList; | |
import android.content.res.Resources; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.ColorFilter; | |
import android.graphics.Paint; | |
import android.graphics.Path; | |
import android.graphics.Rect; |
NewerOlder