Skip to content

Commit

Permalink
- [dependencies][android] remove all Firebase SDKs in favour of Fireb…
Browse files Browse the repository at this point in the history
…ase BoM

- [android] upgrade to Android X
- [android] upgrade gradle wrapper to v5.4.1
- [android][ios][tests] remove manual packages & enable auto-linking
- [tests][internal] upgrade tests project to RN 60
- [ios] temporarily remove framework support in pods - broken in RN 60 - see facebook/react-native#25349
- [linting] switch to use rn community linting rules
  • Loading branch information
Salakar committed Jul 30, 2019
1 parent 21c0b59 commit 9ca0a61
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion RNFBAuth.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Pod::Spec.new do |s|
s.dependency 'Firebase/Core', '~> 6.5.0'
s.dependency 'Firebase/Auth', '~> 6.5.0'
s.dependency 'RNFBApp'
s.static_framework = true
s.static_framework = false
end
12 changes: 4 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}

Expand All @@ -24,12 +24,8 @@ project.ext {
buildTools: "28.0.3"
],

googlePlayServices: [
base: "16.1.0",
],

firebase : [
auth: "17.0.0"
bom : "21.1.0",
],
],
])
Expand All @@ -56,8 +52,8 @@ repositories {

dependencies {
api project(':@react-native-firebase_app')
implementation "com.google.firebase:firebase-auth:${ReactNative.ext.getVersion("firebase", "auth")}"
implementation "com.google.android.gms:play-services-base:${ReactNative.ext.getVersion("googlePlayServices", "base")}"
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-auth"
}

ReactNative.shared.applyPackageVersion()
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
9 changes: 2 additions & 7 deletions e2e/auth.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('auth()', () => {
describe('signInWithCustomToken()', () => {
// TODO(salakar) use new testing api to create a custom token
xit('signs in with a admin sdk created custom auth token', async () => {
const customUID = `zdwHCjbpzraRoNK7d64FYWv5AH02`;
const customUID = 'zdwHCjbpzraRoNK7d64FYWv5AH02';
const token = await firebaseAdmin.auth().createCustomToken(customUID, {
test: null,
roles: [
Expand Down Expand Up @@ -762,17 +762,14 @@ describe('auth()', () => {

describe('languageCode', () => {
it('it should change the language code', () => {
// eslint-disable-next-line no-param-reassign
firebase.auth().languageCode = 'en';
if (firebase.auth().languageCode !== 'en') {
throw new Error('Expected language code to be "en".');
}
// eslint-disable-next-line no-param-reassign
firebase.auth().languageCode = 'fr';
if (firebase.auth().languageCode !== 'fr') {
throw new Error('Expected language code to be "fr".');
}
// eslint-disable-next-line no-param-reassign
firebase.auth().languageCode = 'en';
});
});
Expand Down Expand Up @@ -811,9 +808,7 @@ describe('auth()', () => {
it('should not error', async () => {
const random = Utils.randString(12, '#aA');
const email = `${random}@${random}.com`;
const pass = random;

await firebase.auth().createUserWithEmailAndPassword(email, pass);
await firebase.auth().createUserWithEmailAndPassword(email, random);

try {
await firebase.auth().sendPasswordResetEmail(email);
Expand Down
2 changes: 1 addition & 1 deletion ios/RNFBAuth.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Pod::Spec.new do |s|
s.dependency 'Firebase/Core', '~> 6.5.0'
s.dependency 'Firebase/Auth', '~> 6.5.0'
s.dependency 'RNFBApp'
s.static_framework = true
s.static_framework = false
end
24 changes: 17 additions & 7 deletions lib/PhoneAuthListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ export default class PhoneAuthListener {

_emitToErrorCb(snapshot) {
const { error } = snapshot;
if (this._reject) this._reject(error);
if (this._reject) {
this._reject(error);
}
this._auth.emitter.emit(this._publicEvents.error, error);
}

_emitToSuccessCb(snapshot) {
if (this._resolve) this._resolve(snapshot);
if (this._resolve) {
this._resolve(snapshot);
}
this._auth.emitter.emit(this._publicEvents.success, snapshot);
}

Expand All @@ -105,7 +109,9 @@ export default class PhoneAuthListener {
}

_promiseDeferred() {
if (!this._promise) this._promise = promiseDefer();
if (!this._promise) {
this._promise = promiseDefer();
}
}

/* --------------------------
Expand Down Expand Up @@ -179,13 +185,13 @@ export default class PhoneAuthListener {
on(event, observer, errorCb, successCb) {
if (event !== 'state_changed') {
throw new Error(
`firebase.auth.PhoneAuthListener.on(*, _, _, _) 'event' must equal 'state_changed'.`,
"firebase.auth.PhoneAuthListener.on(*, _, _, _) 'event' must equal 'state_changed'.",
);
}

if (!isFunction(observer)) {
throw new Error(
`firebase.auth.PhoneAuthListener.on(_, *, _, _) 'observer' must be a function.`,
"firebase.auth.PhoneAuthListener.on(_, *, _, _) 'observer' must be a function.",
);
}

Expand All @@ -204,13 +210,17 @@ export default class PhoneAuthListener {

then(fn) {
this._promiseDeferred();
if (this._promise) return this._promise.then.bind(this._promise)(fn);
if (this._promise) {
return this._promise.then.bind(this._promise)(fn);
}
return undefined;
}

catch(fn) {
this._promiseDeferred();
if (this._promise) return this._promise.catch.bind(this._promise)(fn);
if (this._promise) {
return this._promise.catch.bind(this._promise)(fn);
}
return undefined;
}
}
16 changes: 12 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class FirebaseAuthModule extends FirebaseModule {
}

get settings() {
if (!this._settings) this._settings = new Settings(this);
if (!this._settings) {
this._settings = new Settings(this);
}
return this._settings;
}

Expand Down Expand Up @@ -134,7 +136,9 @@ class FirebaseAuthModule extends FirebaseModule {
listener,
);

if (this._authResult) listener(this._user || null);
if (this._authResult) {
listener(this._user || null);
}
return () => subscription.remove();
}

Expand All @@ -144,13 +148,17 @@ class FirebaseAuthModule extends FirebaseModule {
listener,
);

if (this._authResult) listener(this._user || null);
if (this._authResult) {
listener(this._user || null);
}
return () => subscription.remove();
}

onUserChanged(listener) {
const subscription = this.emitter.addListener(this.eventNameForApp('onUserChanged'), listener);
if (this._authResult) listener(this._user || null);
if (this._authResult) {
listener(this._user || null);
}

return () => {
subscription.remove();
Expand Down

0 comments on commit 9ca0a61

Please sign in to comment.