This commit is contained in:
Salakar 2018-04-29 15:11:07 +01:00
commit 8ef7c2d983
5 changed files with 21 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.RemoteInput; import android.support.v4.app.RemoteInput;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
@ -634,7 +635,7 @@ public class RNFirebaseNotificationManager {
return null; return null;
} }
private void scheduleNotification(Bundle notification, Promise promise) { private void scheduleNotification(Bundle notification, @Nullable Promise promise) {
if (!notification.containsKey("notificationId")) { if (!notification.containsKey("notificationId")) {
if (promise == null) { if (promise == null) {
Log.e(TAG, "Missing notificationId"); Log.e(TAG, "Missing notificationId");
@ -664,7 +665,11 @@ public class RNFirebaseNotificationManager {
JSONObject json = BundleJSONConverter.convertToJSON(notification); JSONObject json = BundleJSONConverter.convertToJSON(notification);
preferences.edit().putString(notificationId, json.toString()).apply(); preferences.edit().putString(notificationId, json.toString()).apply();
} catch (JSONException e) { } catch (JSONException e) {
if (promise == null) {
Log.e(TAG, "Failed to store notification");
} else {
promise.reject("notification/schedule_notification_error", "Failed to store notification", e); promise.reject("notification/schedule_notification_error", "Failed to store notification", e);
}
return; return;
} }
@ -694,7 +699,11 @@ public class RNFirebaseNotificationManager {
} }
if (interval == null) { if (interval == null) {
if (promise == null) {
Log.e(TAG, "Invalid interval");
} else {
promise.reject("notification/schedule_notification_error", "Invalid interval"); promise.reject("notification/schedule_notification_error", "Invalid interval");
}
return; return;
} }
@ -709,6 +718,8 @@ public class RNFirebaseNotificationManager {
} }
} }
if (promise != null) {
promise.resolve(null); promise.resolve(null);
} }
} }
}

4
lib/index.d.ts vendored
View File

@ -1502,7 +1502,7 @@ declare module "react-native-firebase" {
startAfter(...varargs: any[]): Query; startAfter(...varargs: any[]): Query;
startAt(snapshot: DocumentSnapshot): Query; startAt(snapshot: DocumentSnapshot): Query;
startAt(...varargs: any[]): Query; startAt(...varargs: any[]): Query;
where(fieldPath: string, op: Types.QueryOperator, value: any): Query; where(fieldPath: string | FieldPath, op: Types.QueryOperator, value: any): Query;
} }
interface DocumentChange { interface DocumentChange {
@ -1598,7 +1598,7 @@ declare module "react-native-firebase" {
startAfter(...varargs: any[]): Query; startAfter(...varargs: any[]): Query;
startAt(snapshot: DocumentSnapshot): Query; startAt(snapshot: DocumentSnapshot): Query;
startAt(...varargs: any[]): Query; startAt(...varargs: any[]): Query;
where(fieldPath: string, op: Types.QueryOperator, value: any): Query; where(fieldPath: string | FieldPath, op: Types.QueryOperator, value: any): Query;
} }
namespace Query { namespace Query {
interface NativeFieldPath { interface NativeFieldPath {

View File

@ -103,16 +103,16 @@ export default class Auth extends ModuleBase {
} }
_setUser(user: ?NativeUser): ?User { _setUser(user: ?NativeUser): ?User {
this._authResult = true;
this._user = user ? new User(this, user) : null; this._user = user ? new User(this, user) : null;
this._authResult = true;
SharedEventEmitter.emit(getAppEventName(this, 'onUserChanged'), this._user); SharedEventEmitter.emit(getAppEventName(this, 'onUserChanged'), this._user);
return this._user; return this._user;
} }
_setUserCredential(userCredential: NativeUserCredential): UserCredential { _setUserCredential(userCredential: NativeUserCredential): UserCredential {
const user = new User(this, userCredential.user); const user = new User(this, userCredential.user);
this._authResult = true;
this._user = user; this._user = user;
this._authResult = true;
SharedEventEmitter.emit(getAppEventName(this, 'onUserChanged'), this._user); SharedEventEmitter.emit(getAppEventName(this, 'onUserChanged'), this._user);
return { return {
additionalUserInfo: userCredential.additionalUserInfo, additionalUserInfo: userCredential.additionalUserInfo,

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-firebase", "name": "react-native-firebase",
"version": "4.0.5", "version": "4.0.6",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-firebase", "name": "react-native-firebase",
"version": "4.0.5", "version": "4.0.6",
"author": "Invertase <contact@invertase.io> (http://invertase.io)", "author": "Invertase <contact@invertase.io> (http://invertase.io)",
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Messaging (FCM), Remote Config, Storage and Performance.", "description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Messaging (FCM), Remote Config, Storage and Performance.",
"main": "dist/index.js", "main": "dist/index.js",