Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform camera permission and app config check #5

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ repositories {
}
}
```
Note:
As for projects on Gradle 8+ and Kotlin 1.8+ build will fail if the JDK version between
compileKotlin and compileJava and jvmTarget are not aligned.

This won't be necessary anymore from React Native 0.73. More on this:
https://kotlinlang.org/docs/whatsnew18.html#obligatory-check-for-jvm-targets-of-related-kotlin-and-java-compile-tasks

## Add camera permission
For module usage, configuring permissions for the device camera on both iOS and Android is necessary. You must also explicitly request user permission before commencing the identity verification process. See the `/example` project to learn more.
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 20 additions & 4 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { NativeModules, NativeEventEmitter, SafeAreaView, EmitterSubscription, ActivityIndicator, View, StyleSheet } from 'react-native';
import { NativeModules, NativeEventEmitter, SafeAreaView, EmitterSubscription, ActivityIndicator, View, StyleSheet, Platform } from 'react-native';
import { request, PERMISSIONS } from 'react-native-permissions';

import IdentityVerification, { TSIDV } from 'react-native-ts-idv';
Expand Down Expand Up @@ -81,9 +81,17 @@ export default class App extends React.Component<any, State> {
}

private requestCameraPermissions = (): void => {
request(PERMISSIONS.IOS.CAMERA).then((result) => {
console.log(`Requested camera permissions. Result: ${result}`);
});
if (Platform.OS === "android") {
request(PERMISSIONS.ANDROID.CAMERA).then((result) => {
console.log(`Requested camera permissions. Result: ${result}`);
});
} else if (Platform.OS === "ios"){
request(PERMISSIONS.IOS.CAMERA).then((result) => {
console.log(`Requested camera permissions. Result: ${result}`);
});
} else {
console.error("Unsupported platform");
}
}

private onRecapture = (): void => {
Expand Down Expand Up @@ -137,6 +145,10 @@ export default class App extends React.Component<any, State> {
}

private onAppReady = async (): Promise<void> => {
if (!this.isAppConfigured()) {
this.logAppEvent("Error: This code requires configuration of the App's Client ID and Secret. Please set the values in config.ts before proceeding.");
return;
}
IdentityVerification.initialize(config.clientId);
this.registerForEvents();
this.requestCameraPermissions();
Expand All @@ -148,6 +160,10 @@ export default class App extends React.Component<any, State> {
}
}

private isAppConfigured = (): boolean => {
return !(config.clientId === "REPLACE_WITH_CLIENT_ID" || config.secret === "REPLACE_WITH_SECRET");
}

// Event Emitter

private registerForEvents() {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading