mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 07:19:50 -04:00
Capacitor can't do the the typical web login for reasons.
So we need to use a plugin that will handle native auth, and we fixed an issue with logout.
This commit is contained in:
parent
8ac6dfa2ae
commit
a0c3528e8b
6
src/android/.idea/compiler.xml
generated
Normal file
6
src/android/.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
</component>
|
||||
</project>
|
2
src/android/.idea/misc.xml
generated
2
src/android/.idea/misc.xml
generated
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK" />
|
||||
</project>
|
@ -66,6 +66,15 @@ dependencies {
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
||||
implementation project(':capacitor-cordova-android-plugins')
|
||||
// Import the BoM for the Firebase platform
|
||||
implementation platform('com.google.firebase:firebase-bom:26.5.0')
|
||||
|
||||
// Declare the dependency for the Firebase Authentication library
|
||||
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||
implementation 'com.google.firebase:firebase-auth'
|
||||
|
||||
// Also declare the dependency for the Google Play services library and specify its version
|
||||
implementation 'com.google.android.gms:play-services-auth:19.0.0'
|
||||
}
|
||||
|
||||
apply from: 'capacitor.build.gradle'
|
||||
|
@ -9,7 +9,7 @@ android {
|
||||
|
||||
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||
dependencies {
|
||||
|
||||
implementation project(':codetrix-studio-capacitor-google-auth')
|
||||
|
||||
}
|
||||
|
||||
|
64
src/android/app/google-services.json
Normal file
64
src/android/app/google-services.json
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "200739882604",
|
||||
"firebase_url": "https://dynamicbible-7c6cf.firebaseio.com",
|
||||
"project_id": "dynamicbible-7c6cf",
|
||||
"storage_bucket": "dynamicbible-7c6cf.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:200739882604:android:98d382a57407577e",
|
||||
"android_client_info": {
|
||||
"package_name": "walljm.dynamicbible"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "200739882604-cdsthjn22k31civpbbp3hv1vhhqan27u.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "walljm.dynamicbible",
|
||||
"certificate_hash": "61703efe57998735ca5d22fec522d099cea1e83c"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "200739882604-vl9sdm2o394c9v8dlnt6j41ng99bfdc4.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "walljm.dynamicbible",
|
||||
"certificate_hash": "51e2a302e891905184570920c3b9ec332cc9a15b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "200739882604-vlavth3q12b5vbm8jflb791e84dnr2a5.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "walljm.dynamicbible",
|
||||
"certificate_hash": "f431037c6ae25c37ec4d3cb5626220143e864f37"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "200739882604-i4mk6rp4mcb8n590j5kc8i6bncpm5bo1.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyA05ZDn1nyjceJSpDta5esnvKSV4RKEbH4"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "200739882604-418lja1hb6d76ttfsdo3fdu733svukqj.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
@ -7,7 +7,13 @@
|
||||
"plugins": {
|
||||
"SplashScreen": {
|
||||
"launchShowDuration": 0
|
||||
},
|
||||
"GoogleAuth": {
|
||||
"scopes": ["profile", "email"],
|
||||
"serverClientId": "200739882604-i4mk6rp4mcb8n590j5kc8i6bncpm5bo1.apps.googleusercontent.com",
|
||||
"forceCodeForRefreshToken" : true
|
||||
}
|
||||
|
||||
},
|
||||
"cordova": {}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.getcapacitor.BridgeActivity;
|
||||
import com.getcapacitor.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;
|
||||
|
||||
public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
@ -16,6 +17,7 @@ public class MainActivity extends BridgeActivity {
|
||||
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
|
||||
// Additional plugins you've installed go here
|
||||
// Ex: add(TotallyAwesomePlugin.class);
|
||||
add(GoogleAuth.class);
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,5 @@
|
||||
<string name="title_activity_main">dynamicbible</string>
|
||||
<string name="package_name">walljm.dynamicbible</string>
|
||||
<string name="custom_url_scheme">walljm.dynamicbible</string>
|
||||
<string name="server_client_id">200739882604-i4mk6rp4mcb8n590j5kc8i6bncpm5bo1.apps.googleusercontent.com</string>
|
||||
</resources>
|
||||
|
@ -10,7 +10,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||
classpath 'com.google.gms:google-services:4.3.3'
|
||||
classpath "com.github.triplet.gradle:play-publisher:3.1.0"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||
include ':capacitor-android'
|
||||
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
||||
|
||||
include ':codetrix-studio-capacitor-google-auth'
|
||||
project(':codetrix-studio-capacitor-google-auth').projectDir = new File('../node_modules/@codetrix-studio/capacitor-google-auth/android')
|
||||
|
@ -7,7 +7,13 @@
|
||||
"plugins": {
|
||||
"SplashScreen": {
|
||||
"launchShowDuration": 0
|
||||
},
|
||||
"GoogleAuth": {
|
||||
"scopes": ["profile", "email"],
|
||||
"serverClientId": "200739882604-i4mk6rp4mcb8n590j5kc8i6bncpm5bo1.apps.googleusercontent.com",
|
||||
"forceCodeForRefreshToken" : true
|
||||
}
|
||||
|
||||
},
|
||||
"cordova": {}
|
||||
}
|
||||
|
23
src/package-lock.json
generated
23
src/package-lock.json
generated
@ -1847,6 +1847,29 @@
|
||||
"resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-2.4.0.tgz",
|
||||
"integrity": "sha512-G4WcQHS4RuK94Ncoi5K+r12DWPqkB8yZKupQrJaGT1S/Zyc3mcA9m1f4HwRPlYCwyxQ6lCd8+N9GYxLu7Kv+SA=="
|
||||
},
|
||||
"@codetrix-studio/capacitor-google-auth": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@codetrix-studio/capacitor-google-auth/-/capacitor-google-auth-2.1.3.tgz",
|
||||
"integrity": "sha512-uglDFmaE9109dAEq+EIXIkAmST9zn8U+aw/f48bHdD52yKEPWExpHqUR0v0W4OeY4jepB7SUgBk8mCcLjxDmDA==",
|
||||
"requires": {
|
||||
"@capacitor/core": "^2.4.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@capacitor/core": {
|
||||
"version": "2.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@capacitor/core/-/core-2.4.6.tgz",
|
||||
"integrity": "sha512-3KLSMorCELA5RNRXwHOGlRGuxXaxCEYHC29wOUxObicI2mf14hbMJWylt4QBzNmSqh3/ha7u4/CAZMoJUQR/QA==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@dabh/diagnostics": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.2.tgz",
|
||||
|
@ -30,6 +30,7 @@
|
||||
"@capacitor/cli": "^2.4.0",
|
||||
"@capacitor/core": "^2.4.0",
|
||||
"@capacitor/ios": "^2.4.0",
|
||||
"@codetrix-studio/capacitor-google-auth": "^2.1.3",
|
||||
"@ngx-pwa/local-storage": "^10.0.1",
|
||||
"@types/mathjs": "^6.0.5",
|
||||
"angular2-uuid": "^1.1.1",
|
||||
|
@ -7,8 +7,9 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
import { AngularFireAuth } from '@angular/fire/auth';
|
||||
import { auth } from 'firebase/app';
|
||||
import { Capacitor, Plugins } from '@capacitor/core';
|
||||
import '@codetrix-studio/capacitor-google-auth';
|
||||
|
||||
import { Storable } from 'src/app/common/storable';
|
||||
import { SubscriberBase } from '../../common/subscriber-base';
|
||||
import { DisplaySettings } from 'src/app/models/app-state';
|
||||
import { CardFonts } from 'src/app/constants';
|
||||
@ -40,8 +41,8 @@ export class SettingsComponent extends SubscriberBase {
|
||||
|
||||
constructor(
|
||||
public appService: AppService,
|
||||
private navService: NavService,
|
||||
public authService: AngularFireAuth,
|
||||
private navService: NavService,
|
||||
private dialog: MatDialog,
|
||||
private snackBar: MatSnackBar
|
||||
) {
|
||||
@ -74,14 +75,24 @@ export class SettingsComponent extends SubscriberBase {
|
||||
);
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.signInWithPopup(new auth.GoogleAuthProvider()).then((cred) => {
|
||||
console.log('Authenticated.');
|
||||
});
|
||||
async login() {
|
||||
if (Capacitor.isNative) {
|
||||
const googleUser = await Plugins.GoogleAuth.signIn();
|
||||
const credential = auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
|
||||
this.authService.signInAndRetrieveDataWithCredential(credential);
|
||||
} else {
|
||||
this.authService.signInWithPopup(new auth.GoogleAuthProvider()).then((cred) => {
|
||||
console.log('Authenticated.');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.authService.signOut();
|
||||
async logout() {
|
||||
if (Capacitor.isNative) {
|
||||
await Plugins.GoogleAuth.signOut();
|
||||
}
|
||||
await this.authService.signOut();
|
||||
this.appService.setUser(null); // clear the user.
|
||||
}
|
||||
|
||||
//#region Page Settings
|
||||
|
@ -13,7 +13,7 @@ export const FirebaseConfig = {
|
||||
authDomain: 'dynamicbible-7c6cf.firebaseapp.com',
|
||||
databaseURL: 'https://dynamicbible-7c6cf.firebaseio.com',
|
||||
projectId: 'dynamicbible-7c6cf',
|
||||
storageBucket: '',
|
||||
storageBucket: 'dynamicbible-7c6cf.appspot.com',
|
||||
messagingSenderId: '200739882604',
|
||||
};
|
||||
// export const FirebaseConfig = {
|
||||
@ -23,5 +23,4 @@ export const FirebaseConfig = {
|
||||
// projectId: 'dynamic-bible-testing',
|
||||
// storageBucket: 'dynamic-bible-testing.appspot.com',
|
||||
// messagingSenderId: '813845246474',
|
||||
// appId: '1:813845246474:web:6dccfa057b6cb3067565f3',
|
||||
// };
|
||||
|
Loading…
x
Reference in New Issue
Block a user