Skip to content

Commit 0088da2

Browse files
committed
Initial import from private repository
0 parents  commit 0088da2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2252
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Vonage
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Phone Number Authentication Demo
2+
3+
This demo shows how to verify your identify using your phone number. The demo uses the following Vonage APIs:
4+
5+
* [Network Enablement API]()
6+
* [Number Verificatio API](https://developer.vonage.com/en/number-verification/overview)
7+
8+
## Common Prerequisites
9+
10+
- A [Vonage developer](https://developer.vonage.com) account.
11+
- An application set up in the [Vonage Dashboard](https://developer.vonage.com/dashboard) with the `Network Registry` capability enabled.
12+
13+
## Architecture
14+
15+
* [Android mobile app](client)
16+
* [Node backend](server)
17+
18+
## License
19+
20+
This project is licensed under the MIT License. See the LICENSE file for details.
21+

client/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Kotlin cache directory
5+
.kotlin
6+
7+
# Ignore Gradle build output directory
8+
build
9+
10+
#built application files
11+
*.apk
12+
*.ap_
13+
14+
# files for the dex VM
15+
*.dex
16+
17+
# Java class files
18+
*.class
19+
20+
# generated files
21+
bin/
22+
gen/
23+
24+
# Local configuration file (sdk path, etc)
25+
local.properties
26+
27+
# Windows thumbnail db
28+
Thumbs.db
29+
30+
# OSX files
31+
.DS_Store
32+
33+
# Android Studio
34+
*.iml
35+
.idea
36+
.navigation
37+
captures/
38+
output.json
39+
40+
#NDK
41+
obj/
42+
.externalNativeBuild

client/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Alvaro Navarro
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

client/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Android Number Verification Client
2+
3+
This Android application serves as a client for a Node.js backend that
4+
integrates with Vonage's Number Verification API. The app demonstrates a
5+
complete flow where a user inputs their phone number, requests a login URL, and
6+
performs number verification.
7+
8+
## Features
9+
10+
- Uses **Compose** for a modern, declarative UI.
11+
- Interacts with a Node.js backend to generate a login URL and perform OAuth authentication.
12+
- Verifies the phone number using the **Vonage SDK**.
13+
- Displays real-time status updates and error handling.
14+
- Built with **Kotlin** and utilizes modern libraries such as **OkHttp** and **Kotlin Coroutines**.
15+
16+
## Dependencies
17+
18+
- [Vonage Number Verification SDK](https://github.com/Vonage/number-verification-sdk-android) to force the use of mobile data over WiFi.
19+
- **OkHttp**: For making HTTP requests.
20+
- **Kotlin Coroutines**: For asynchronous programming.
21+
- **Jetpack Compose**: For UI.
22+
23+
24+
## Building the App
25+
26+
1. Open the project in **Android Studio**.
27+
2. Sync Gradle to download dependencies.
28+
3. Connect an Android device or start an emulator.
29+
4. Build and run the app by clicking the **Run** button.
30+
31+
32+
## Usage
33+
34+
1. Set up the Backend
35+
36+
Ensure the Node.js backend for this app is running. For details, see the [Node.js Backend Documentation](https://github.com/alnacle/demo-number-verification-android-node/server).
37+
38+
2. Configure the App
39+
40+
Update the `LOGIN_URL` in the app code with the URL where the backend is running:
41+
42+
```kotlin
43+
const val LOGIN_URL = "https://your-node-backend-url/login"
44+
```
45+
3. Enter a valid phone number in international format (e.g., `+1234567890`).
46+
47+
4. Tap the **Login** button.
48+
49+
5. The app will:
50+
- Send a request to the backend for an auth URL.
51+
- Perform OAuth and phone number verification using the Vonage SDK.
52+
53+
6. The verification result (success or failure) will be displayed on the screen.
54+
55+
56+
## Troubleshooting
57+
58+
1. **Error: HTTP 400/500 from the Backend**
59+
- Ensure the backend is running and accessible at the `LOGIN_URL`.
60+
61+
2. **Build Issues**
62+
- Sync Gradle and ensure all dependencies are downloaded.
63+
64+

client/app/build.gradle.kts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
plugins {
2+
id("com.android.application")
3+
id("org.jetbrains.kotlin.android")
4+
}
5+
6+
android {
7+
namespace = "com.vonage.numberverification.test"
8+
compileSdk = 34
9+
10+
defaultConfig {
11+
applicationId = "com.vonage.numberverification.test"
12+
minSdk = 24
13+
targetSdk = 34
14+
versionCode = 1
15+
versionName = "1.0"
16+
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
vectorDrawables {
19+
useSupportLibrary = true
20+
}
21+
}
22+
23+
buildTypes {
24+
release {
25+
isMinifyEnabled = false
26+
proguardFiles(
27+
getDefaultProguardFile("proguard-android-optimize.txt"),
28+
"proguard-rules.pro"
29+
)
30+
}
31+
}
32+
compileOptions {
33+
sourceCompatibility = JavaVersion.VERSION_1_8
34+
targetCompatibility = JavaVersion.VERSION_1_8
35+
}
36+
kotlinOptions {
37+
jvmTarget = "1.8"
38+
}
39+
buildFeatures {
40+
compose = true
41+
}
42+
composeOptions {
43+
kotlinCompilerExtensionVersion = "1.5.8"
44+
}
45+
packaging {
46+
resources {
47+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
48+
}
49+
}
50+
}
51+
52+
dependencies {
53+
implementation("com.vonage:client-sdk-number-verification:1.1.1")
54+
55+
implementation("androidx.activity:activity-compose:1.9.3")
56+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
57+
implementation(platform("androidx.compose:compose-bom:2024.11.00"))
58+
implementation("androidx.compose.ui:ui")
59+
implementation("androidx.compose.ui:ui-graphics")
60+
implementation("androidx.compose.ui:ui-tooling-preview")
61+
implementation("androidx.compose.material3:material3")
62+
implementation("com.squareup.okhttp3:okhttp:4.11.0")
63+
64+
testImplementation("junit:junit:4.13.2")
65+
androidTestImplementation("androidx.test.ext:junit:1.2.1")
66+
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
67+
androidTestImplementation(platform("androidx.compose:compose-bom:2024.11.00"))
68+
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
69+
}

client/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.NumberVerification">
13+
<activity
14+
android:name=".MainActivity"
15+
android:exported="true"
16+
android:label="@string/app_name"
17+
android:theme="@style/Theme.NumberVerification">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
26+
</manifest>

0 commit comments

Comments
 (0)