Skip to content

Commit

Permalink
Merge pull request #17 from m1ga/master
Browse files Browse the repository at this point in the history
Android: Update 3.0.1
  • Loading branch information
hansemannn authored Jan 17, 2021
2 parents 96240e9 + 0a50fe4 commit 8477ab5
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ thank you!

##### `signInAndRetrieveDataWithCredential(parameters)` (Dictionary, iOS-only)

##### `sendPasswordResetWithEmail(parameters)` (Dictionary, iOS-only)
##### `sendPasswordResetWithEmail(parameters)` (Dictionary)

##### `confirmPasswordResetWithCode(parameters)` (Dictionary, iOS-only)

##### `checkActionCode(parameters)` (Dictionary, iOS-only)
##### `checkActionCode(parameters)` (Dictionary)

##### `verifyPasswordResetCode(parameters)` (Dictionary, iOS-only)

Expand All @@ -67,32 +67,51 @@ thank you!

##### `currentUser` (Dictionary, get)

##### `languageCode` (String, get, iOS-only)
##### `languageCode` (String, get)

##### `apnsToken` (Ti.Blob, get, iOS-only)

- For Android, use `fetchIDToken(forceRefresh, callback)`

### FirebaseAuth.AuthCredential

Virtual Type to be used in ``signInWithCredential`. Create with `createCredential(parameters)`.
Virtual Type to be used in `signInWithCredential`. Create with `createCredential(parameters)`.

## Example
```js
// Require the Firebase Auth module
var FirebaseAuth = require('firebase.auth');


// Sign-up
FirebaseAuth.createUserWithEmail({
email: '[email protected]',
password: 't1r0ck$!',
callback: function(e) {
if (!e.success) {
Ti.API.error('Create: error: ' + JSON.stringify(e));
return;
}

Ti.API.info('Create: success!');
Ti.API.info(JSON.stringify(e.user));
}
});


// Login
FirebaseAuth.signInWithEmail({
email: '[email protected]',
password: 't1r0ck$!',
callback: function(e) {
if (!e.success) {
Ti.API.error('Error: ' + e.error);
Ti.API.error('Error: ' + JSON.stringify(e));
return;
}

Ti.API.info('Success!');
Ti.API.info(e.user);
Ti.API.info(JSON.stringify(e.user)); // e.g. {"uid":"...","photoURL":null,"phoneNumber":null,"email":"...","providerID":"...","displayName":null}

}
});

Expand Down
3 changes: 1 addition & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ repositories {


dependencies {
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-auth-interop:19.0.0'
implementation 'com.google.firebase:firebase-auth:20.0.2'
}
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.0.0
version: 3.0.1
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: titanium-firebase-auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.EmailAuthProvider;
import com.google.firebase.auth.FacebookAuthProvider;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.GithubAuthProvider;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.OAuthProvider;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.auth.TwitterAuthProvider;
import org.appcelerator.kroll.KrollDict;

import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
Expand Down
23 changes: 23 additions & 0 deletions android/src/firebase/auth/TitaniumFirebaseAuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package firebase.auth;

import android.app.Activity;
import android.drm.DrmStore;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -18,6 +19,7 @@
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.ActionCodeResult;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
Expand Down Expand Up @@ -224,6 +226,27 @@ public void onComplete(Task<Void> task) {
});
}

@Kroll.method
public void checkActionCode(KrollDict params)
{
String code = (String) params.get("code");
final KrollFunction callback = (KrollFunction) params.get("callback");

mAuth.checkActionCode(code).addOnCompleteListener(new OnCompleteListener<ActionCodeResult>() {
@Override
public void onComplete(Task<ActionCodeResult> task) {
KrollDict event = new KrollDict();
if (task.isSuccessful()) {
event.put("success", task.isSuccessful());
event.put("operation", task.getResult().getOperation());
} else {
event.put("success", false);
}
callback.callAsync(getKrollObject(), event);
}
});
}

@Kroll.method
public void signInWithCredential(KrollDict params)
{
Expand Down

0 comments on commit 8477ab5

Please sign in to comment.