Courtesy: GitHub

SMS Verify App

This sample demonstrates the use of Play Service's SMS Verification APIs to get access to specially-tagged text messages (the tags associate the message with the APK) without needing full SMS retrieval permission (SMS_READ).

Configuration

To build the application, you will need to acquire or generate at least three (potentially four), files. These files are not distributed with this source as they contain sensitive keys, etc.

./android/app/google-services.json (configuration for Google API client). (Online tool to generate google-services.json. The package name is com.google.samples.smartlock.sms_verify.)

./sms-verification/android/app/src/main/res/values/sensitive.xml (configures the HTTP endpoint the app uses to send the SMS). The format is:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="server_client_secret">0000000000</string>
  <string name="url_verify">https://your-server.com/api/verify</string>
  <string name="url_request">https://your-server.com/api/request</string>
  <string name="url_reset">https://your-server.com/api/reset</string>
</resources>

./sms-verification/android/debug.keystore (keystore used to sign the APK).

./sms-verification/appengine/credentials.py (configures the SMS itself). (Optional—this is only necessary if deploying/changing the appengine server-side component.) Use the script sms-verification/bin/sms_retriever_hash_v9.sh to generate the hash if required:

$ sms-verification/bin/sms_retriever_hash_v9.sh --package com.google.samples.smartlock.sms_verify --keystore sms-verification/android/debug.keystore 

These three files have dependencies on each other; they together ensure that the text messages sent by the server can be read by Google Play Services.

compileSdkVersion 25

applicationId "com.google.samples.smartlock.sms_verify"

minSdkVersion 23

targetSdkVersion 25

versionCode 1

versionName "1.0"

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:25.3.1'

compile 'com.android.volley:volley:1.0.0'

compile 'com.android.support:design:25.3.1'

compile 'com.google.android.gms:play-services-base:11.0.1'

compile 'com.google.android.gms:play-services-identity:11.0.1'

compile 'com.google.android.gms:play-services-auth:11.0.1'

compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'

compile 'com.android.support:support-v4:25.3.1'

testCompile 'junit:junit:4.12'

compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'

package com.google.samples.smartlock.sms_verify

uses-permission

  • android.permission.INTERNET

MainActivity

SignUpActivity

ResetActivity

SettingsActivity

A {@link PreferenceActivity} that presents a set of application settings. On handset devices, settings are presented as a single list. On tablets, settings are split by category, with category headers shown to the left of the list of settings.

See Android Design: Settings for design guidelines and the Settings API Guide for more information on developing a Settings UI.

Set up the {@link android.app.ActionBar}, if the API is available.

PhoneNumberVerifier

A service to verify a telephone number.

Handle action Foo in the provided background thread with the provided parameters.