Closed pookdeveloper closed 6 years ago
let follow my step, I will make an PR soon:
1) ionic cordova plugin add cordova-universal-links-plugin
2) ionic cordova plugin add cordova-plugin-buildinfo
3) ionic cordova plugin add cordova-plugin-browsertab
4) ionic cordova plugin add cordova-plugin-inappbrowser
5) ionic cordova plugin add cordova-plugin-customurlscheme (for ios)
STEP 2.1: [setup firebase to angular project] (https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md)
STEP 2.2: To set up an Android app, go to Firebase Console then Click Add Firebase to your Android app and follow the setup steps.
STEP 3.1: In the Firebase console, open the Dynamic Links section at bottom left panel, setup by they instruction
STEP 3.2: add this to config.xml at root level of project:
<universal-links>
<!-- this is dynamic link created in firebase -->
<host name="zm4e4.app.goo.gl" scheme="https" />
<!-- this is your firebase app link -->
<host name="routing-aadd4.firebaseapp.com" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>
<!-- for android -->
<preference name="AndroidLaunchMode" value="singleTask" />
STEP 3.3: make sure your <widget id="com.yourandroid.id" ... >
the same with android app's id you
added in firebase at STEP 2.2.
at login.service.ts add this function:
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import AuthProvider = firebase.auth.AuthProvider;
export class AuthService {
private user: firebase.User;
constructor(public afAuth: AngularFireAuth) {
afAuth.authState.subscribe(user => {
this.user = user;
});
}
signInWithGoogle() {
console.log('Sign in with google');
return this.oauthSignIn(new firebase.auth.GoogleAuthProvider());
}
private oauthSignIn(provider: AuthProvider) {
if (!(<any>window).cordova) {
return this.afAuth.auth.signInWithPopup(provider);
} else {
return this.afAuth.auth.signInWithRedirect(provider)
.then(() => {
return this.afAuth.auth.getRedirectResult().then( result => {
// This gives you a Google Access Token.
// You can use it to access the Google API.
let token = result.credential.accessToken;
// The signed-in user info.
let user = result.user;
console.log(token, user);
}).catch(function(error) {
// Handle Errors here.
alert(error.message);
});
});
}
}
}
if you got error when build code like this:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined
Please, using this fix from issue:
Making this change in 'cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js' fixed this issue for me: b2c5784#diff-d5955d9f4d88b42e5efd7a3385be79e9
can you follow this step and make some comment? I will improve it and make an documentation about this. Thanks for your support. @pookdeveloper
@hiepxanh Works perfect! thanks!
is that my tutorial good? can you login? if yes, maybe can you close the issue?
Closed ;)
thank you, but can I ask you. Is that tutorial missing anything? should I add anything before creating a tutorial on angularfire2 docs? @pookdeveloper
I see good, only specify the fisrt steep install the module angular firebase2
2018-05-10 9:09 GMT+02:00 hiepxanh notifications@github.com:
thank you, but can I ask you. Is that tutorial missing anything? should I add anything before creating a tutorial on angularfire2 docs? @pookdeveloper https://github.com/pookdeveloper
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angularfire2/issues/1601#issuecomment-387971858, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOlnjOlk87fuYQpl34K-cQgnf5Hhk8-ks5tw-e0gaJpZM4T0HLb .
-- Un saludo! David Garcia Santes https://www.linkedin.com/pub/david-garcia/33/45/221 davidgarciasantes@gmail.com
@pookdeveloper yes, I will update angularfire2 in the list, anything else? can you show me?
for now nothing ,is very complete.
Regards
2018-05-10 9:21 GMT+02:00 hiepxanh notifications@github.com:
@pookdeveloper https://github.com/pookdeveloper yes, I will update angularfire2 in the list, anything else? can you show me?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angularfire2/issues/1601#issuecomment-387974244, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOlnv-izcCI8gp84fy7gw6gfeddtu6kks5tw-qTgaJpZM4T0HLb .
-- Un saludo! David Garcia Santes https://www.linkedin.com/pub/david-garcia/33/45/221 davidgarciasantes@gmail.com
thank you ❤️
one last question, what kind of animal in your avatar ? it look so cute 😄 @pookdeveloper
hahah its a octopus:
https://www.pinterest.es/oceanomonaco/octopus/?lp=true
this is the image: https://www.pinterest.es/pin/94223817182004374/
2018-05-10 9:26 GMT+02:00 hiepxanh notifications@github.com:
one last question, what kind of animal in your avatar, it look so cute 😄
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angularfire2/issues/1601#issuecomment-387975083, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOlnlAmgcYPhpWrEasHJi7GKv7FIA7zks5tw-ucgaJpZM4T0HLb .
-- Un saludo! David Garcia Santes https://www.linkedin.com/pub/david-garcia/33/45/221 davidgarciasantes@gmail.com
that not an octopus, octopus is something like this, are you trolling me 😭
I sorry in git hub.. hahaha its a red panda:
https://es.wikipedia.org/wiki/Ailurus_fulgens
2018-05-10 9:33 GMT+02:00 hiepxanh notifications@github.com:
[image: image] https://user-images.githubusercontent.com/16970990/39857790-d1d91d90-545e-11e8-8f5c-71c3494d74da.png that not an octopus, octopus is something like this, are you trolling me 😭 [image: image] https://user-images.githubusercontent.com/16970990/39857837-f9468796-545e-11e8-963e-c0b41cffb321.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angularfire2/issues/1601#issuecomment-387976593, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOlnojxi2ytIacnjoGzX3LbuzSbQ_Bpks5tw-1RgaJpZM4T0HLb .
-- Un saludo! David Garcia Santes https://www.linkedin.com/pub/david-garcia/33/45/221 davidgarciasantes@gmail.com
Yes, I'm so happy, I will change all my background with that red panda 😄
wiiiiiiii 😸
2018-05-10 9:42 GMT+02:00 hiepxanh notifications@github.com:
Yes, I'm so happy, I will change all my background with that red panda 😄
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angularfire2/issues/1601#issuecomment-387978428, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOlniPA5BeK3o_PJ2ovu0oHJoVgL-MOks5tw-9ugaJpZM4T0HLb .
-- Un saludo! David Garcia Santes https://www.linkedin.com/pub/david-garcia/33/45/221 davidgarciasantes@gmail.com
@hiepxanh hi, those steps are not working for me on android > 7.0 but it does on android's higher , onAuthStatechanged is never being fired after redirect and like you suggested
afAuth.authState.subscribe(user => { this.user = user; }); }
is null
I tried but didn't work. When I click on "login" button, the app freezes.
Also, I couldn't install the browsertab plugin, it said that is deprecated. cordova plugin add cordova-plugin-browsertab
Anyone else are having this throubles?
Hey. I just tried step by step what @hiepxanh suggested but all the time i try to login with google/facebook it opens Chrome browser tab, i see the "app-12345.firebaseapp.com" address then it redirects to localhost.
cordova 8.0.0
android 7.0.0 (26)
"angularfire2": "^5.0.0-rc.12"
"firebase": "^5.4.2"
"cordova-universal-links-plugin": {},
"cordova-plugin-buildinfo": {},
"cordova-plugin-browsertab": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-customurlscheme": {
"URL_SCHEME": "com.firebase.cordova",
"ANDROID_SCHEME": " ",
"ANDROID_HOST": " ",
"ANDROID_PATHPREFIX": "/"
}
"cordova-plugin-browsertab": "^0.2.0",
"cordova-plugin-buildinfo": "^2.0.2",
"cordova-plugin-customurlscheme": "^4.3.0",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-ionic-webview": "^2.1.3",
"cordova-universal-links-plugin": "^1.2.1",
the code
doGoogleLogin() {
this.doAuth(new auth.GoogleAuthProvider());
}
doFacebookLogin() {
this.doAuth(new auth.FacebookAuthProvider());
}
doAuth(provider: any) {
if (!(<any>window).cordova) {
return this.afAuth.auth.signInWithPopup(provider);
} else {
this.afAuth.auth.signInWithRedirect(provider)
.then(() => {
return this.afAuth.auth.getRedirectResult().then(result => {
if (result.user) {
this.user = result.user;
this.initialize();
}
}).catch(error => {
console.log('auth error', error);
});
});
}
}
@h2u Did you find a solution with Android 7+ ? I'm having issues getting universal-links working on Android.
@h2u Did you find a solution with Android 7+ ? I'm having issues getting universal-links working on Android.
I moved to solution with signInAndRetrieveDataWithCredential method and native google and facebook libs. It's the best way you can do it imho.
Hello I try to sign in. with google, in chrome works good but in android not open the popup,
I try this and dosent work..
any solution ?