misc formatting
This commit is contained in:
parent
c652d73c9f
commit
4d9255c3e9
|
@ -11,19 +11,19 @@ import io.invertase.firebase.messaging.RNFirebaseMessaging;
|
||||||
|
|
||||||
public class RNFirebaseInstanceIdService extends FirebaseInstanceIdService {
|
public class RNFirebaseInstanceIdService extends FirebaseInstanceIdService {
|
||||||
|
|
||||||
private static final String TAG = "FSInstanceIdService";
|
private static final String TAG = "FSInstanceIdService";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onTokenRefresh() {
|
public void onTokenRefresh() {
|
||||||
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
||||||
Log.d(TAG, "Refreshed token: " + refreshedToken);
|
Log.d(TAG, "Refreshed token: " + refreshedToken);
|
||||||
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_TOKEN);
|
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_TOKEN);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("token", refreshedToken);
|
bundle.putString("token", refreshedToken);
|
||||||
i.putExtras(bundle);
|
i.putExtras(bundle);
|
||||||
sendBroadcast(i);
|
sendBroadcast(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,64 +11,64 @@ import io.invertase.firebase.messaging.RNFirebaseMessaging;
|
||||||
|
|
||||||
public class RNFirebaseMessagingService extends FirebaseMessagingService {
|
public class RNFirebaseMessagingService extends FirebaseMessagingService {
|
||||||
|
|
||||||
private static final String TAG = "FSMessagingService";
|
private static final String TAG = "FSMessagingService";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||||
Log.d(TAG, "Remote message received");
|
Log.d(TAG, "Remote message received");
|
||||||
// debug
|
// debug
|
||||||
Log.d(TAG, "From: " + remoteMessage.getFrom());
|
Log.d(TAG, "From: " + remoteMessage.getFrom());
|
||||||
|
|
||||||
if (remoteMessage.getData().size() > 0) {
|
|
||||||
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remoteMessage.getNotification() != null) {
|
|
||||||
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_NOTIFICATION);
|
|
||||||
i.putExtra("data", remoteMessage);
|
|
||||||
sendOrderedBroadcast(i, null);
|
|
||||||
|
|
||||||
|
if (remoteMessage.getData().size() > 0) {
|
||||||
|
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (remoteMessage.getNotification() != null) {
|
||||||
public void onMessageSent(String msgId) {
|
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
|
||||||
// Called when an upstream message has been successfully sent to the GCM connection server.
|
|
||||||
Log.d(TAG, "upstream message has been successfully sent");
|
|
||||||
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_SEND);
|
|
||||||
i.putExtra("msgId", msgId);
|
|
||||||
sendOrderedBroadcast(i, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_NOTIFICATION);
|
||||||
public void onSendError(String msgId, Exception exception) {
|
i.putExtra("data", remoteMessage);
|
||||||
// Called when there was an error sending an upstream message.
|
sendOrderedBroadcast(i, null);
|
||||||
Log.d(TAG, "error sending an upstream message");
|
|
||||||
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_SEND);
|
}
|
||||||
i.putExtra("msgId", msgId);
|
|
||||||
i.putExtra("hasError", true);
|
@Override
|
||||||
SendException sendException = (SendException) exception;
|
public void onMessageSent(String msgId) {
|
||||||
i.putExtra("errorCode", sendException.getErrorCode());
|
// Called when an upstream message has been successfully sent to the GCM connection server.
|
||||||
switch(sendException.getErrorCode()){
|
Log.d(TAG, "upstream message has been successfully sent");
|
||||||
case SendException.ERROR_INVALID_PARAMETERS:
|
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_SEND);
|
||||||
i.putExtra("errorMessage", "Message was sent with invalid parameters.");
|
i.putExtra("msgId", msgId);
|
||||||
break;
|
sendOrderedBroadcast(i, null);
|
||||||
case SendException.ERROR_SIZE:
|
}
|
||||||
i.putExtra("errorMessage", "Message exceeded the maximum payload size.");
|
|
||||||
break;
|
@Override
|
||||||
case SendException.ERROR_TOO_MANY_MESSAGES:
|
public void onSendError(String msgId, Exception exception) {
|
||||||
i.putExtra("errorMessage", "App has too many pending messages so this one was dropped.");
|
// Called when there was an error sending an upstream message.
|
||||||
break;
|
Log.d(TAG, "error sending an upstream message");
|
||||||
case SendException.ERROR_TTL_EXCEEDED:
|
Intent i = new Intent(RNFirebaseMessaging.INTENT_NAME_SEND);
|
||||||
i.putExtra("errorMessage", "Message time to live (TTL) was exceeded before the message could be sent.");
|
i.putExtra("msgId", msgId);
|
||||||
break;
|
i.putExtra("hasError", true);
|
||||||
case SendException.ERROR_UNKNOWN:
|
SendException sendException = (SendException) exception;
|
||||||
default:
|
i.putExtra("errorCode", sendException.getErrorCode());
|
||||||
i.putExtra("errorMessage", "Unknown error.");
|
switch (sendException.getErrorCode()) {
|
||||||
break;
|
case SendException.ERROR_INVALID_PARAMETERS:
|
||||||
}
|
i.putExtra("errorMessage", "Message was sent with invalid parameters.");
|
||||||
sendOrderedBroadcast(i, null);
|
break;
|
||||||
|
case SendException.ERROR_SIZE:
|
||||||
|
i.putExtra("errorMessage", "Message exceeded the maximum payload size.");
|
||||||
|
break;
|
||||||
|
case SendException.ERROR_TOO_MANY_MESSAGES:
|
||||||
|
i.putExtra("errorMessage", "App has too many pending messages so this one was dropped.");
|
||||||
|
break;
|
||||||
|
case SendException.ERROR_TTL_EXCEEDED:
|
||||||
|
i.putExtra("errorMessage", "Message time to live (TTL) was exceeded before the message could be sent.");
|
||||||
|
break;
|
||||||
|
case SendException.ERROR_UNKNOWN:
|
||||||
|
default:
|
||||||
|
i.putExtra("errorMessage", "Unknown error.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
sendOrderedBroadcast(i, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,8 @@ public class RNFirebaseModule extends ReactContextBaseJavaModule implements Life
|
||||||
|
|
||||||
KeySetterFn fn = new KeySetterFn() {
|
KeySetterFn fn = new KeySetterFn() {
|
||||||
public String setKeyOrDefault(
|
public String setKeyOrDefault(
|
||||||
final String key,
|
final String key,
|
||||||
final String defaultValue) {
|
final String defaultValue) {
|
||||||
if (params.hasKey(key)) {
|
if (params.hasKey(key)) {
|
||||||
// User-set key
|
// User-set key
|
||||||
final String val = params.getString(key);
|
final String val = params.getString(key);
|
||||||
|
|
|
@ -21,44 +21,45 @@ import io.invertase.firebase.messaging.RNFirebaseMessaging;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class RNFirebasePackage implements ReactPackage {
|
public class RNFirebasePackage implements ReactPackage {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public RNFirebasePackage() {
|
public RNFirebasePackage() {
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param reactContext react application context that can be used to create modules
|
|
||||||
* @return list of native modules to register with the newly created catalyst instance
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
||||||
List<NativeModule> modules = new ArrayList<>();
|
|
||||||
modules.add(new RNFirebaseModule(reactContext));
|
|
||||||
modules.add(new RNFirebaseAuth(reactContext));
|
|
||||||
modules.add(new RNFirebaseDatabase(reactContext));
|
|
||||||
modules.add(new RNFirebaseAnalytics(reactContext));
|
|
||||||
modules.add(new RNFirebaseStorage(reactContext));
|
|
||||||
modules.add(new RNFirebaseMessaging(reactContext));
|
|
||||||
return modules;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list of JS modules to register with the newly created catalyst instance.
|
* @param reactContext react application context that can be used to create modules
|
||||||
* <p/>
|
* @return list of native modules to register with the newly created catalyst instance
|
||||||
* IMPORTANT: Note that only modules that needs to be accessible from the native code should be
|
*/
|
||||||
* listed here. Also listing a native module here doesn't imply that the JS implementation of it
|
@Override
|
||||||
* will be automatically included in the JS bundle.
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||||
*/
|
List<NativeModule> modules = new ArrayList<>();
|
||||||
@Override
|
modules.add(new RNFirebaseModule(reactContext));
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
modules.add(new RNFirebaseAuth(reactContext));
|
||||||
return Collections.emptyList();
|
modules.add(new RNFirebaseDatabase(reactContext));
|
||||||
}
|
modules.add(new RNFirebaseAnalytics(reactContext));
|
||||||
|
modules.add(new RNFirebaseStorage(reactContext));
|
||||||
|
modules.add(new RNFirebaseMessaging(reactContext));
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param reactContext
|
* @return list of JS modules to register with the newly created catalyst instance.
|
||||||
* @return a list of view managers that should be registered with {@link UIManagerModule}
|
* <p/>
|
||||||
*/
|
* IMPORTANT: Note that only modules that needs to be accessible from the native code should be
|
||||||
@Override
|
* listed here. Also listing a native module here doesn't imply that the JS implementation of it
|
||||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
* will be automatically included in the JS bundle.
|
||||||
return Collections.emptyList();
|
*/
|
||||||
}
|
@Override
|
||||||
|
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param reactContext
|
||||||
|
* @return a list of view managers that should be registered with {@link UIManagerModule}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class Utils {
|
||||||
public static void sendEvent(final ReactContext context, final String eventName, final WritableMap params) {
|
public static void sendEvent(final ReactContext context, final String eventName, final WritableMap params) {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
context
|
context
|
||||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||||
.emit(eventName, params);
|
.emit(eventName, params);
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Missing context - cannot send event!");
|
Log.d(TAG, "Missing context - cannot send event!");
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ public class Utils {
|
||||||
|
|
||||||
// snapshot
|
// snapshot
|
||||||
public static WritableMap dataSnapshotToMap(
|
public static WritableMap dataSnapshotToMap(
|
||||||
String name,
|
String name,
|
||||||
String path,
|
String path,
|
||||||
String modifiersString,
|
String modifiersString,
|
||||||
DataSnapshot dataSnapshot
|
DataSnapshot dataSnapshot
|
||||||
) {
|
) {
|
||||||
WritableMap data = Arguments.createMap();
|
WritableMap data = Arguments.createMap();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +35,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param enabled
|
* @param enabled
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -45,7 +43,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param screenName
|
* @param screenName
|
||||||
* @param screenClassOverride
|
* @param screenClassOverride
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +62,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param milliseconds
|
* @param milliseconds
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -74,7 +70,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param milliseconds
|
* @param milliseconds
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -83,7 +78,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -92,7 +86,6 @@ public class RNFirebaseAnalytics extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,40 +121,40 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void createUserWithEmail(final String email, final String password, final Callback callback) {
|
public void createUserWithEmail(final String email, final String password, final Callback callback) {
|
||||||
mAuth.createUserWithEmailAndPassword(email, password)
|
mAuth.createUserWithEmailAndPassword(email, password)
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
userCallback(task.getResult().getUser(), callback);
|
userCallback(task.getResult().getUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void signInWithEmail(final String email, final String password, final Callback callback) {
|
public void signInWithEmail(final String email, final String password, final Callback callback) {
|
||||||
|
|
||||||
mAuth.signInWithEmailAndPassword(email, password)
|
mAuth.signInWithEmailAndPassword(email, password)
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
userCallback(task.getResult().getUser(), callback);
|
userCallback(task.getResult().getUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -175,22 +175,22 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
AuthCredential credential = EmailAuthProvider.getCredential(email, password);
|
AuthCredential credential = EmailAuthProvider.getCredential(email, password);
|
||||||
user
|
user
|
||||||
.linkWithCredential(credential)
|
.linkWithCredential(credential)
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "user linked with password credential");
|
Log.d(TAG, "user linked with password credential");
|
||||||
userCallback(mAuth.getCurrentUser(), callback);
|
userCallback(mAuth.getCurrentUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -209,42 +209,42 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
public void signInAnonymously(final Callback callback) {
|
public void signInAnonymously(final Callback callback) {
|
||||||
Log.d(TAG, "signInAnonymously:called:");
|
Log.d(TAG, "signInAnonymously:called:");
|
||||||
mAuth.signInAnonymously()
|
mAuth.signInAnonymously()
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
Log.d(TAG, "signInAnonymously:onComplete:" + task.isSuccessful());
|
Log.d(TAG, "signInAnonymously:onComplete:" + task.isSuccessful());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
userCallback(task.getResult().getUser(), callback);
|
userCallback(task.getResult().getUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void signInWithCustomToken(final String customToken, final Callback callback) {
|
public void signInWithCustomToken(final String customToken, final Callback callback) {
|
||||||
mAuth.signInWithCustomToken(customToken)
|
mAuth.signInWithCustomToken(customToken)
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
Log.d(TAG, "signInWithCustomToken:onComplete:" + task.isSuccessful());
|
Log.d(TAG, "signInWithCustomToken:onComplete:" + task.isSuccessful());
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
userCallback(task.getResult().getUser(), callback);
|
userCallback(task.getResult().getUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -261,22 +261,22 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user
|
user
|
||||||
.updateEmail(email)
|
.updateEmail(email)
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "User email address updated");
|
Log.d(TAG, "User email address updated");
|
||||||
userCallback(mAuth.getCurrentUser(), callback);
|
userCallback(mAuth.getCurrentUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -288,21 +288,21 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.updatePassword(newPassword)
|
user.updatePassword(newPassword)
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "User password updated");
|
Log.d(TAG, "User password updated");
|
||||||
userCallback(mAuth.getCurrentUser(), callback);
|
userCallback(mAuth.getCurrentUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -311,22 +311,22 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void sendPasswordResetWithEmail(final String email, final Callback callback) {
|
public void sendPasswordResetWithEmail(final String email, final Callback callback) {
|
||||||
mAuth.sendPasswordResetEmail(email)
|
mAuth.sendPasswordResetEmail(email)
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
WritableMap resp = Arguments.createMap();
|
WritableMap resp = Arguments.createMap();
|
||||||
resp.putString("status", "complete");
|
resp.putString("status", "complete");
|
||||||
callback.invoke(null, resp);
|
callback.invoke(null, resp);
|
||||||
} else {
|
} else {
|
||||||
callback.invoke(task.getException().toString());
|
callback.invoke(task.getException().toString());
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -334,24 +334,24 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
FirebaseUser user = mAuth.getCurrentUser();
|
FirebaseUser user = mAuth.getCurrentUser();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.delete()
|
user.delete()
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "User account deleted");
|
Log.d(TAG, "User account deleted");
|
||||||
WritableMap resp = Arguments.createMap();
|
WritableMap resp = Arguments.createMap();
|
||||||
resp.putString("status", "complete");
|
resp.putString("status", "complete");
|
||||||
resp.putString("msg", "User account deleted");
|
resp.putString("msg", "User account deleted");
|
||||||
callback.invoke(null, resp);
|
callback.invoke(null, resp);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -364,26 +364,26 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.sendEmailVerification()
|
user.sendEmailVerification()
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
WritableMap resp = Arguments.createMap();
|
WritableMap resp = Arguments.createMap();
|
||||||
resp.putString("status", "complete");
|
resp.putString("status", "complete");
|
||||||
resp.putString("msg", "User verification email sent");
|
resp.putString("msg", "User verification email sent");
|
||||||
callback.invoke(null, resp);
|
callback.invoke(null, resp);
|
||||||
} else {
|
} else {
|
||||||
WritableMap err = Arguments.createMap();
|
WritableMap err = Arguments.createMap();
|
||||||
err.putInt("errorCode", ERROR_SENDING_VERIFICATION_EMAIL);
|
err.putInt("errorCode", ERROR_SENDING_VERIFICATION_EMAIL);
|
||||||
err.putString("errorMessage", task.getException().getMessage());
|
err.putString("errorMessage", task.getException().getMessage());
|
||||||
callback.invoke(err);
|
callback.invoke(err);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -396,27 +396,27 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.getToken(true)
|
user.getToken(true)
|
||||||
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<GetTokenResult> task) {
|
public void onComplete(@NonNull Task<GetTokenResult> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
String token = task.getResult().getToken();
|
String token = task.getResult().getToken();
|
||||||
WritableMap resp = Arguments.createMap();
|
WritableMap resp = Arguments.createMap();
|
||||||
resp.putString("status", "complete");
|
resp.putString("status", "complete");
|
||||||
resp.putString("token", token);
|
resp.putString("token", token);
|
||||||
callback.invoke(null, resp);
|
callback.invoke(null, resp);
|
||||||
} else {
|
} else {
|
||||||
WritableMap err = Arguments.createMap();
|
WritableMap err = Arguments.createMap();
|
||||||
err.putInt("errorCode", ERROR_FETCHING_TOKEN);
|
err.putInt("errorCode", ERROR_FETCHING_TOKEN);
|
||||||
err.putString("errorMessage", task.getException().getMessage());
|
err.putString("errorMessage", task.getException().getMessage());
|
||||||
callback.invoke(err);
|
callback.invoke(err);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -445,21 +445,21 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
UserProfileChangeRequest profileUpdates = profileBuilder.build();
|
UserProfileChangeRequest profileUpdates = profileBuilder.build();
|
||||||
|
|
||||||
user.updateProfile(profileUpdates)
|
user.updateProfile(profileUpdates)
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "User profile updated");
|
Log.d(TAG, "User profile updated");
|
||||||
userCallback(mAuth.getCurrentUser(), callback);
|
userCallback(mAuth.getCurrentUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callbackNoUser(callback, true);
|
callbackNoUser(callback, true);
|
||||||
}
|
}
|
||||||
|
@ -483,17 +483,17 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
callbackNoUser(callback, false);
|
callbackNoUser(callback, false);
|
||||||
} else {
|
} else {
|
||||||
user.reload()
|
user.reload()
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "user reloaded");
|
Log.d(TAG, "user reloaded");
|
||||||
userCallback(mAuth.getCurrentUser(), callback);
|
userCallback(mAuth.getCurrentUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,40 +514,40 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
||||||
public void googleLogin(String IdToken, final Callback callback) {
|
public void googleLogin(String IdToken, final Callback callback) {
|
||||||
AuthCredential credential = GoogleAuthProvider.getCredential(IdToken, null);
|
AuthCredential credential = GoogleAuthProvider.getCredential(IdToken, null);
|
||||||
mAuth.signInWithCredential(credential)
|
mAuth.signInWithCredential(credential)
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
userCallback(task.getResult().getUser(), callback);
|
userCallback(task.getResult().getUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void facebookLogin(String Token, final Callback callback) {
|
public void facebookLogin(String Token, final Callback callback) {
|
||||||
AuthCredential credential = FacebookAuthProvider.getCredential(Token);
|
AuthCredential credential = FacebookAuthProvider.getCredential(Token);
|
||||||
mAuth.signInWithCredential(credential)
|
mAuth.signInWithCredential(credential)
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||||
try {
|
try {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
userCallback(task.getResult().getUser(), callback);
|
userCallback(task.getResult().getUser(), callback);
|
||||||
} else {
|
} else {
|
||||||
userErrorCallback(task, callback);
|
userErrorCallback(task, callback);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
userExceptionCallback(ex, callback);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
userExceptionCallback(ex, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal helpers
|
// Internal helpers
|
||||||
|
|
|
@ -341,8 +341,8 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RNFirebaseDatabaseReference getDBHandle(final String path,
|
private RNFirebaseDatabaseReference getDBHandle(final String path,
|
||||||
final ReadableArray modifiersArray,
|
final ReadableArray modifiersArray,
|
||||||
final String modifiersString) {
|
final String modifiersString) {
|
||||||
String key = this.getDBListenerKey(path, modifiersString);
|
String key = this.getDBListenerKey(path, modifiersString);
|
||||||
RNFirebaseDatabaseReference r = mDBListeners.get(key);
|
RNFirebaseDatabaseReference r = mDBListeners.get(key);
|
||||||
|
|
||||||
|
|
|
@ -114,18 +114,18 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
Task<Uri> downloadTask = reference.getDownloadUrl();
|
Task<Uri> downloadTask = reference.getDownloadUrl();
|
||||||
downloadTask
|
downloadTask
|
||||||
.addOnSuccessListener(new OnSuccessListener<Uri>() {
|
.addOnSuccessListener(new OnSuccessListener<Uri>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Uri uri) {
|
public void onSuccess(Uri uri) {
|
||||||
callback.invoke(null, uri.toString());
|
callback.invoke(null, uri.toString());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addOnFailureListener(new OnFailureListener() {
|
.addOnFailureListener(new OnFailureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Exception exception) {
|
public void onFailure(@NonNull Exception exception) {
|
||||||
callback.invoke(makeErrorPayload(1, exception));
|
callback.invoke(makeErrorPayload(1, exception));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -187,8 +187,8 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
|
||||||
@Override
|
@Override
|
||||||
public void doInBackground(StreamDownloadTask.TaskSnapshot taskSnapshot, InputStream inputStream) throws IOException {
|
public void doInBackground(StreamDownloadTask.TaskSnapshot taskSnapshot, InputStream inputStream) throws IOException {
|
||||||
int indexOfLastSlash = localPath.lastIndexOf("/");
|
int indexOfLastSlash = localPath.lastIndexOf("/");
|
||||||
String pathMinusFileName = indexOfLastSlash>0 ? localPath.substring(0, indexOfLastSlash) + "/" : "/";
|
String pathMinusFileName = indexOfLastSlash > 0 ? localPath.substring(0, indexOfLastSlash) + "/" : "/";
|
||||||
String filename = indexOfLastSlash>0 ? localPath.substring(indexOfLastSlash+1) : localPath;
|
String filename = indexOfLastSlash > 0 ? localPath.substring(indexOfLastSlash + 1) : localPath;
|
||||||
File fileWithJustPath = new File(pathMinusFileName);
|
File fileWithJustPath = new File(pathMinusFileName);
|
||||||
fileWithJustPath.mkdirs();
|
fileWithJustPath.mkdirs();
|
||||||
File fileWithFullPath = new File(pathMinusFileName, filename);
|
File fileWithFullPath = new File(pathMinusFileName, filename);
|
||||||
|
@ -255,42 +255,42 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
// register observers to listen for when the download is done or if it fails
|
// register observers to listen for when the download is done or if it fails
|
||||||
uploadTask
|
uploadTask
|
||||||
.addOnFailureListener(new OnFailureListener() {
|
.addOnFailureListener(new OnFailureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Exception exception) {
|
public void onFailure(@NonNull Exception exception) {
|
||||||
// handle unsuccessful uploads
|
// handle unsuccessful uploads
|
||||||
Log.e(TAG, "Failed to upload file " + exception.getMessage());
|
Log.e(TAG, "Failed to upload file " + exception.getMessage());
|
||||||
//TODO: JS Error event
|
//TODO: JS Error event
|
||||||
callback.invoke(makeErrorPayload(1, exception));
|
callback.invoke(makeErrorPayload(1, exception));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
|
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
|
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
|
||||||
Log.d(TAG, "Successfully uploaded file " + taskSnapshot);
|
Log.d(TAG, "Successfully uploaded file " + taskSnapshot);
|
||||||
WritableMap resp = getUploadTaskAsMap(taskSnapshot);
|
WritableMap resp = getUploadTaskAsMap(taskSnapshot);
|
||||||
handleStorageEvent(STORAGE_UPLOAD_SUCCESS, path, resp);
|
handleStorageEvent(STORAGE_UPLOAD_SUCCESS, path, resp);
|
||||||
//TODO: A little hacky, but otherwise throws a not consumed exception
|
//TODO: A little hacky, but otherwise throws a not consumed exception
|
||||||
resp = getUploadTaskAsMap(taskSnapshot);
|
resp = getUploadTaskAsMap(taskSnapshot);
|
||||||
callback.invoke(null, resp);
|
callback.invoke(null, resp);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
|
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
|
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
|
||||||
Log.d(TAG, "Got upload progress " + taskSnapshot);
|
Log.d(TAG, "Got upload progress " + taskSnapshot);
|
||||||
WritableMap event = getUploadTaskAsMap(taskSnapshot);
|
WritableMap event = getUploadTaskAsMap(taskSnapshot);
|
||||||
handleStorageEvent(STORAGE_STATE_CHANGED, path, event);
|
handleStorageEvent(STORAGE_STATE_CHANGED, path, event);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addOnPausedListener(new OnPausedListener<UploadTask.TaskSnapshot>() {
|
.addOnPausedListener(new OnPausedListener<UploadTask.TaskSnapshot>() {
|
||||||
@Override
|
@Override
|
||||||
public void onPaused(UploadTask.TaskSnapshot taskSnapshot) {
|
public void onPaused(UploadTask.TaskSnapshot taskSnapshot) {
|
||||||
Log.d(TAG, "Upload is paused " + taskSnapshot);
|
Log.d(TAG, "Upload is paused " + taskSnapshot);
|
||||||
WritableMap event = getUploadTaskAsMap(taskSnapshot);
|
WritableMap event = getUploadTaskAsMap(taskSnapshot);
|
||||||
handleStorageEvent(STORAGE_STATE_CHANGED, path, event);
|
handleStorageEvent(STORAGE_STATE_CHANGED, path, event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
final int errorCode = 2;
|
final int errorCode = 2;
|
||||||
callback.invoke(makeErrorPayload(errorCode, ex));
|
callback.invoke(makeErrorPayload(errorCode, ex));
|
||||||
|
@ -300,17 +300,17 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
|
||||||
//Firebase.Storage methods
|
//Firebase.Storage methods
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void setMaxDownloadRetryTime(final double milliseconds) {
|
public void setMaxDownloadRetryTime(final double milliseconds) {
|
||||||
FirebaseStorage.getInstance().setMaxDownloadRetryTimeMillis((long)milliseconds);
|
FirebaseStorage.getInstance().setMaxDownloadRetryTimeMillis((long) milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void setMaxOperationRetryTime(final double milliseconds) {
|
public void setMaxOperationRetryTime(final double milliseconds) {
|
||||||
FirebaseStorage.getInstance().setMaxOperationRetryTimeMillis((long)milliseconds);
|
FirebaseStorage.getInstance().setMaxOperationRetryTimeMillis((long) milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void setMaxUploadRetryTime(final double milliseconds) {
|
public void setMaxUploadRetryTime(final double milliseconds) {
|
||||||
FirebaseStorage.getInstance().setMaxUploadRetryTimeMillis((long)milliseconds);
|
FirebaseStorage.getInstance().setMaxUploadRetryTimeMillis((long) milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StorageReference getReference(String path) {
|
private StorageReference getReference(String path) {
|
||||||
|
@ -438,7 +438,7 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
|
||||||
body.putString("path", path);
|
body.putString("path", path);
|
||||||
body.putString("message", error.getMessage());
|
body.putString("message", error.getMessage());
|
||||||
|
|
||||||
WritableMap evt = Arguments.createMap();
|
WritableMap evt = Arguments.createMap();
|
||||||
evt.putString("eventName", STORAGE_ERROR);
|
evt.putString("eventName", STORAGE_ERROR);
|
||||||
evt.putMap("body", body);
|
evt.putMap("body", body);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue