diff --git a/plugin.xml b/plugin.xml
index 9add74bc8..99cbada59 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -27,9 +27,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
-
-
-
@@ -79,15 +76,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
production
-
- no
-
-
-
-
-
-
-
diff --git a/src/android/FirebasePlugin.java b/src/android/FirebasePlugin.java
index a872594a2..274aaf666 100755
--- a/src/android/FirebasePlugin.java
+++ b/src/android/FirebasePlugin.java
@@ -60,15 +60,8 @@ public class FirebasePlugin extends CordovaPlugin {
private FirebaseAnalytics mFirebaseAnalytics;
private static CordovaWebView appView;
private final String TAG = "FirebasePlugin";
- private final String ERRORINITFIREBASE = "Firebase isn't initialised";
- private final String ERRORINITCRASHLYTICS = "Crashlytics isn't initialised";
- private final String ERRORINITANALYTICS = "Analytics isn't initialised";
- private final String ERRORINITPERFORMANCE = "Performance isn't initialised";
protected static final String KEY = "badge";
- private static boolean crashlyticsInit = false;
- private static boolean analyticsInit = false;
- private static boolean performanceInit = false;
private static boolean inBackground = true;
private static ArrayList notificationStack = null;
private static CallbackContext notificationCallbackContext;
@@ -82,6 +75,8 @@ protected void pluginInitialize() {
public void run() {
Log.d(TAG, "Starting Firebase plugin");
FirebaseApp.initializeApp(context);
+ mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
+ mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
if (extras != null && extras.size() > 1) {
if (FirebasePlugin.notificationStack == null) {
FirebasePlugin.notificationStack = new ArrayList();
@@ -97,16 +92,7 @@ public void run() {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- if (action.equals("initCrashlytics")) {
- this.initCrashlytics(callbackContext);
- return true;
- } else if (action.equals("initAnalytics")) {
- this.initAnalytics(callbackContext);
- return true;
- } else if (action.equals("initPerformance")) {
- this.initPerformance(callbackContext);
- return true;
- } else if (action.equals("getInstanceId")) {
+ if (action.equals("getInstanceId")) {
this.getInstanceId(callbackContext);
return true;
} else if (action.equals("getId")) {
@@ -207,8 +193,8 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
this.setAnalyticsCollectionEnabled(callbackContext, args.getBoolean(0));
return true;
} else if (action.equals("setPerformanceCollectionEnabled")) {
- this.setPerformanceCollectionEnabled(callbackContext, args.getBoolean(0));
- return true;
+ this.setPerformanceCollectionEnabled(callbackContext, args.getBoolean(0));
+ return true;
} else if (action.equals("clearAllNotifications")) {
this.clearAllNotifications(callbackContext);
return true;
@@ -242,52 +228,6 @@ public void onDestroy() {
}
}
- private void initCrashlytics(final CallbackContext callbackContext) {
- final Context context = this.cordova.getActivity().getApplicationContext();
-
- Log.d(TAG, "Initialising Crashlytics");
- try {
- Fabric.with(context, new Crashlytics());
- FirebasePlugin.crashlyticsInit = true;
- callbackContext.success();
- } catch(Exception e) {
- callbackContext.error(ERRORINITCRASHLYTICS);
- }
- }
-
- private void initAnalytics(final CallbackContext callbackContext) {
- final Context context = this.cordova.getActivity().getApplicationContext();
-
- Log.d(TAG, "Initialising Analytics");
- try {
- mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
- mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
- FirebasePlugin.analyticsInit = true;
- callbackContext.success();
- } catch(Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
- callbackContext.error(ERRORINITANALYTICS);
- }
- }
-
- private void initPerformance(final CallbackContext callbackContext) {
- final Context context = this.cordova.getActivity().getApplicationContext();
-
- Log.d(TAG, "Initialising Performance");
- try {
- FirebasePerformance.getInstance().setPerformanceCollectionEnabled(true);
- FirebasePlugin.performanceInit = true;
- callbackContext.success();
- } catch(Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
- callbackContext.error(ERRORINITPERFORMANCE);
- }
- }
-
private void onNotificationOpen(final CallbackContext callbackContext) {
FirebasePlugin.notificationCallbackContext = callbackContext;
if (FirebasePlugin.notificationStack != null) {
@@ -309,9 +249,7 @@ public void run() {
FirebasePlugin.sendToken(currentToken);
}
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -336,9 +274,7 @@ public static void sendNotification(Bundle bundle, Context context) {
try {
json.put(key, bundle.get(key));
} catch (JSONException e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
return;
}
@@ -367,18 +303,6 @@ public static boolean inBackground() {
return FirebasePlugin.inBackground;
}
- public static boolean crashlyticsInit() {
- return FirebasePlugin.crashlyticsInit;
- }
-
- public static boolean analyticsInit() {
- return FirebasePlugin.analyticsInit;
- }
-
- public static boolean performanceInit() {
- return FirebasePlugin.performanceInit;
- }
-
public static boolean hasNotificationsCallback() {
return FirebasePlugin.notificationCallbackContext != null;
}
@@ -414,9 +338,7 @@ public void run() {
String id = FirebaseInstanceId.getInstance().getId();
callbackContext.success(id);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -430,9 +352,7 @@ public void run() {
String token = FirebaseInstanceId.getInstance().getToken();
callbackContext.success(token);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -450,9 +370,7 @@ public void run() {
object.put("isEnabled", areNotificationsEnabled);
callbackContext.success(object);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -470,9 +388,7 @@ public void run() {
ShortcutBadger.applyCount(context, number);
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -488,9 +404,7 @@ public void run() {
int number = settings.getInt(KEY, 0);
callbackContext.success(number);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -504,9 +418,7 @@ public void run() {
FirebaseMessaging.getInstance().subscribeToTopic(topic);
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -520,9 +432,7 @@ public void run() {
FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -536,9 +446,7 @@ public void run() {
FirebaseInstanceId.getInstance().deleteInstanceId();
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -563,16 +471,10 @@ private void logEvent(final CallbackContext callbackContext, final String name,
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
- if(FirebasePlugin.analyticsInit()){
- mFirebaseAnalytics.logEvent(name, bundle);
- callbackContext.success();
- } else {
- callbackContext.error(ERRORINITANALYTICS);
- }
+ mFirebaseAnalytics.logEvent(name, bundle);
+ callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -583,16 +485,10 @@ private void logError(final CallbackContext callbackContext, final String messag
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(new Exception(message));
- callbackContext.success(1);
- } else {
- callbackContext.error(ERRORINITCRASHLYTICS);
- }
+ Crashlytics.logException(new Exception(message));
+ callbackContext.success(1);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.log(e.getMessage());
- }
+ Crashlytics.log(e.getMessage());
e.printStackTrace();
callbackContext.error(e.getMessage());
}
@@ -605,16 +501,10 @@ private void setScreenName(final CallbackContext callbackContext, final String n
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
try {
- if(FirebasePlugin.analyticsInit()){
mFirebaseAnalytics.setCurrentScreen(cordova.getActivity(), name, null);
callbackContext.success();
- } else {
- callbackContext.error(ERRORINITANALYTICS);
- }
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -625,16 +515,10 @@ private void setUserId(final CallbackContext callbackContext, final String id) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
- if(FirebasePlugin.analyticsInit()){
mFirebaseAnalytics.setUserId(id);
callbackContext.success();
- } else {
- callbackContext.error(ERRORINITANALYTICS);
- }
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -642,23 +526,17 @@ public void run() {
}
private void setUserProperty(final CallbackContext callbackContext, final String name, final String value) {
- if(FirebasePlugin.analyticsInit()){
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
mFirebaseAnalytics.setUserProperty(name, value);
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
});
- } else {
- callbackContext.error(ERRORINITANALYTICS);
- }
}
private void activateFetched(final CallbackContext callbackContext) {
@@ -668,9 +546,7 @@ public void run() {
final boolean activated = FirebaseRemoteConfig.getInstance().activateFetched();
callbackContext.success(String.valueOf(activated));
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -697,16 +573,12 @@ public void onSuccess(Void data) {
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
});
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -724,9 +596,7 @@ public void run() {
object.put("array", new JSONArray(bytes));
callbackContext.success(object);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -742,9 +612,7 @@ public void run() {
: FirebaseRemoteConfig.getInstance().getValue(key, namespace);
callbackContext.success(value.asString());
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -767,9 +635,7 @@ public void run() {
callbackContext.success(info);
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -786,9 +652,7 @@ public void run() {
FirebaseRemoteConfig.getInstance().setConfigSettings(settings.build());
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -805,9 +669,7 @@ public void run() {
FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults), namespace);
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -869,9 +731,7 @@ public void onVerificationCompleted(PhoneAuthCredential credential) {
returnResults.put("verificationId", false);
returnResults.put("instantVerification", true);
} catch (JSONException e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
return;
}
@@ -897,9 +757,7 @@ public void onVerificationFailed(FirebaseException e) {
errorMsg = "The SMS quota for the project has been exceeded";
}
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(errorMsg);
}
@@ -915,9 +773,7 @@ public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingTo
returnResults.put("verificationId", verificationId);
returnResults.put("instantVerification", false);
} catch (JSONException e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
return;
}
@@ -933,9 +789,7 @@ public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingTo
cordova.getActivity(), // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
+ Crashlytics.logException(e);
callbackContext.error(e.getMessage());
}
}
@@ -950,144 +804,114 @@ public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingTo
private void startTrace(final CallbackContext callbackContext, final String name) {
final FirebasePlugin self = this;
- if(FirebasePlugin.performanceInit()){
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
-
- Trace myTrace = null;
- if (self.traces.containsKey(name)) {
- myTrace = self.traces.get(name);
- }
-
- if (myTrace == null) {
- myTrace = FirebasePerformance.getInstance().newTrace(name);
- myTrace.start();
- self.traces.put(name, myTrace);
- }
-
- callbackContext.success();
- } catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
- e.printStackTrace();
- callbackContext.error(e.getMessage());
- }
- }
- });
- } else {
- callbackContext.error(ERRORINITPERFORMANCE);
- }
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ try {
+
+ Trace myTrace = null;
+ if (self.traces.containsKey(name)) {
+ myTrace = self.traces.get(name);
+ }
+
+ if (myTrace == null) {
+ myTrace = FirebasePerformance.getInstance().newTrace(name);
+ myTrace.start();
+ self.traces.put(name, myTrace);
+ }
+
+ callbackContext.success();
+ } catch (Exception e) {
+ Crashlytics.logException(e);
+ e.printStackTrace();
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
}
private void incrementCounter(final CallbackContext callbackContext, final String name, final String counterNamed) {
final FirebasePlugin self = this;
- if(FirebasePlugin.performanceInit()){
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
-
- Trace myTrace = null;
- if (self.traces.containsKey(name)) {
- myTrace = self.traces.get(name);
- }
-
- if (myTrace != null && myTrace instanceof Trace) {
- myTrace.incrementCounter(counterNamed);
- callbackContext.success();
- } else {
- callbackContext.error("Trace not found");
- }
- } catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
- e.printStackTrace();
- callbackContext.error(e.getMessage());
- }
- }
- });
- } else {
- callbackContext.error(ERRORINITPERFORMANCE);
- }
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ try {
+
+ Trace myTrace = null;
+ if (self.traces.containsKey(name)) {
+ myTrace = self.traces.get(name);
+ }
+
+ if (myTrace != null && myTrace instanceof Trace) {
+ myTrace.incrementCounter(counterNamed);
+ callbackContext.success();
+ } else {
+ callbackContext.error("Trace not found");
+ }
+ } catch (Exception e) {
+ Crashlytics.logException(e);
+ e.printStackTrace();
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
}
private void stopTrace(final CallbackContext callbackContext, final String name) {
final FirebasePlugin self = this;
- if(FirebasePlugin.performanceInit()){
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
-
- Trace myTrace = null;
- if (self.traces.containsKey(name)) {
- myTrace = self.traces.get(name);
- }
-
- if (myTrace != null && myTrace instanceof Trace) { //
- myTrace.stop();
- self.traces.remove(name);
- callbackContext.success();
- } else {
- callbackContext.error("Trace not found");
- }
- } catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.logException(e);
- }
- e.printStackTrace();
- callbackContext.error(e.getMessage());
- }
- }
- });
- } else {
- callbackContext.error(ERRORINITPERFORMANCE);
- }
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ try {
+
+ Trace myTrace = null;
+ if (self.traces.containsKey(name)) {
+ myTrace = self.traces.get(name);
+ }
+
+ if (myTrace != null && myTrace instanceof Trace) { //
+ myTrace.stop();
+ self.traces.remove(name);
+ callbackContext.success();
+ } else {
+ callbackContext.error("Trace not found");
+ }
+ } catch (Exception e) {
+ Crashlytics.logException(e);
+ e.printStackTrace();
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
}
private void setAnalyticsCollectionEnabled(final CallbackContext callbackContext, final boolean enabled) {
final FirebasePlugin self = this;
- if(FirebasePlugin.analyticsInit()){
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- mFirebaseAnalytics.setAnalyticsCollectionEnabled(enabled);
- callbackContext.success();
- } catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.log(e.getMessage());
- }
- e.printStackTrace();
- callbackContext.error(e.getMessage());
- }
- }
- });
- } else {
- callbackContext.error(ERRORINITANALYTICS);
- }
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ try {
+ mFirebaseAnalytics.setAnalyticsCollectionEnabled(enabled);
+ callbackContext.success();
+ } catch (Exception e) {
+ Crashlytics.log(e.getMessage());
+ e.printStackTrace();
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
}
private void setPerformanceCollectionEnabled(final CallbackContext callbackContext, final boolean enabled) {
final FirebasePlugin self = this;
- if(FirebasePlugin.performanceInit()){
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebasePerformance.getInstance().setPerformanceCollectionEnabled(enabled);
- callbackContext.success();
- } catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
- Crashlytics.log(e.getMessage());
- }
- e.printStackTrace();
- callbackContext.error(e.getMessage());
- }
- }
- });
- } else {
- callbackContext.error(ERRORINITPERFORMANCE);
- }
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ try {
+ FirebasePerformance.getInstance().setPerformanceCollectionEnabled(enabled);
+ callbackContext.success();
+ } catch (Exception e) {
+ Crashlytics.log(e.getMessage());
+ e.printStackTrace();
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
}
public void clearAllNotifications(final CallbackContext callbackContext) {
@@ -1099,9 +923,7 @@ public void run() {
nm.cancelAll();
callbackContext.success();
} catch (Exception e) {
- if(FirebasePlugin.crashlyticsInit()){
Crashlytics.log(e.getMessage());
- }
}
}
});
diff --git a/src/ios/FirebasePlugin.h b/src/ios/FirebasePlugin.h
index fb5123413..216866c75 100755
--- a/src/ios/FirebasePlugin.h
+++ b/src/ios/FirebasePlugin.h
@@ -3,10 +3,6 @@
@interface FirebasePlugin : CDVPlugin
+ (FirebasePlugin *) firebasePlugin;
-- (void)initFirebase:(CDVInvokedUrlCommand*)command;
-- (void)initCrashlytics:(CDVInvokedUrlCommand*)command;
-- (void)initAnalytics:(CDVInvokedUrlCommand*)command;
-- (void)initPerformance:(CDVInvokedUrlCommand*)command;
- (void)getVerificationID:(CDVInvokedUrlCommand*)command;
- (void)verifyPhoneNumber:(CDVInvokedUrlCommand*)command;
- (void)getInstanceId:(CDVInvokedUrlCommand*)command;
@@ -41,9 +37,5 @@
@property (nonatomic, copy) NSString *tokenRefreshCallbackId;
@property (nonatomic, retain) NSMutableArray *notificationStack;
@property (nonatomic, readwrite) NSMutableDictionary* traces;
-@property (atomic, assign) BOOL crashlyticsInit;
-@property (atomic, assign) BOOL analyticsInit;
-@property (atomic, assign) BOOL remoteconfigInit;
-@property (atomic, assign) BOOL performanceInit;
@end
diff --git a/src/ios/FirebasePlugin.m b/src/ios/FirebasePlugin.m
index 66aa584ee..bd2c250f1 100644
--- a/src/ios/FirebasePlugin.m
+++ b/src/ios/FirebasePlugin.m
@@ -26,15 +26,7 @@ @implementation FirebasePlugin
@synthesize notificationStack;
@synthesize traces;
-@synthesize crashlyticsInit;
-@synthesize analyticsInit;
-@synthesize performanceInit;
-
static NSInteger const kNotificationStackSize = 10;
-static NSString * const ERRORINITFIREBASE = @"Firebase isn't initialised";
-static NSString * const ERRORINITCRASHLYTICS = @"Crashlytics isn't initialised";
-static NSString * const ERRORINITANALYTICS = @"Analytics isn't initialised";
-static NSString * const ERRORINITPERFORMANCE = @"Performance isn't initialised";
static FirebasePlugin *firebasePlugin;
+ (FirebasePlugin *) firebasePlugin {
@@ -44,57 +36,6 @@ + (FirebasePlugin *) firebasePlugin {
- (void)pluginInitialize {
NSLog(@"Starting Firebase plugin");
firebasePlugin = self;
- self.crashlyticsInit = NO;
- self.analyticsInit = NO;
- self.performanceInit = NO;
-}
-
-- (void)initCrashlytics:(CDVInvokedUrlCommand *)command {
- __block CDVPluginResult *pluginResult;
- [Fabric with:@[[Crashlytics class]]];
-
- if ([Crashlytics sharedInstance] == nil) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
- } else {
- self.crashlyticsInit = YES;
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- }
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)initAnalytics:(CDVInvokedUrlCommand *)command {
- __block CDVPluginResult *pluginResult;
- if ([FIRApp defaultApp] == nil) {
- [FIRApp configure];
- }
-
- if ([FIRAnalyticsConfiguration sharedInstance] == nil) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
- } else {
- [[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:YES];
- self.analyticsInit = YES;
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- }
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)initPerformance:(CDVInvokedUrlCommand *)command {
- __block CDVPluginResult *pluginResult;
- if ([FIRApp defaultApp] == nil) {
- [FIRApp configure];
- }
-
- if ([FIRPerformance sharedInstance] == nil) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
- } else {
- [[FIRPerformance sharedInstance] setDataCollectionEnabled:YES];
- self.performanceInit = YES;
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- }
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)getId:(CDVInvokedUrlCommand *)command {
@@ -326,82 +267,59 @@ - (void)sendToken:(NSString *)token {
- (void)logEvent:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
NSString* name = [command.arguments objectAtIndex:0];
NSDictionary *parameters;
@try {
- NSString *description = NSLocalizedString([command argumentAtIndex:1 withDefault:@"No Message Provided"], nil);
- parameters = @{ NSLocalizedDescriptionKey: description };
+ NSString *description = NSLocalizedString([command argumentAtIndex:1 withDefault:@"No Message Provided"], nil);
+ parameters = @{ NSLocalizedDescriptionKey: description };
}
@catch (NSException *execption) {
- parameters = [command argumentAtIndex:1];
+ parameters = [command argumentAtIndex:1];
}
- if(self.analyticsInit){
- [FIRAnalytics logEventWithName:name parameters:parameters];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITANALYTICS];
- }
+ [FIRAnalytics logEventWithName:name parameters:parameters];
+
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void)logError:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
NSString* errorMessage = [command.arguments objectAtIndex:0];
- if(self.crashlyticsInit){
- CLSNSLog(@"%@", errorMessage);
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITCRASHLYTICS];
- }
+ CLSNSLog(@"%@", errorMessage);
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void)setScreenName:(CDVInvokedUrlCommand *)command {
- CDVPluginResult *pluginResult;
NSString* name = [command.arguments objectAtIndex:0];
- if(self.analyticsInit){
- [FIRAnalytics setScreenName:name screenClass:NULL];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITANALYTICS];
- }
+ [FIRAnalytics setScreenName:name screenClass:NULL];
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)setUserId:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
NSString* id = [command.arguments objectAtIndex:0];
- if(self.analyticsInit){
- [FIRAnalytics setUserID:id];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITANALYTICS];
- }
+ [FIRAnalytics setUserID:id];
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void)setUserProperty:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
NSString* name = [command.arguments objectAtIndex:0];
NSString* value = [command.arguments objectAtIndex:1];
- if(self.analyticsInit){
- [FIRAnalytics setUserPropertyString:value forName:name];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITANALYTICS];
- }
+ [FIRAnalytics setUserPropertyString:value forName:name];
+
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
@@ -448,13 +366,10 @@ - (void)activateFetched:(CDVInvokedUrlCommand *)command {
- (void)getValue:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
NSString* key = [command.arguments objectAtIndex:0];
-
FIRRemoteConfig* remoteConfig = [FIRRemoteConfig remoteConfig];
NSString* value = remoteConfig[key].stringValue;
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:value];
-
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:value];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
@@ -465,25 +380,20 @@ - (void)getValue:(CDVInvokedUrlCommand *)command {
- (void)startTrace:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
- if(self.performanceInit){
- NSString* traceName = [command.arguments objectAtIndex:0];
- FIRTrace *trace = [self.traces objectForKey:traceName];
+ NSString* traceName = [command.arguments objectAtIndex:0];
+ FIRTrace *trace = [self.traces objectForKey:traceName];
- if ( self.traces == nil) {
- self.traces = [NSMutableDictionary new];
- }
-
- if (trace == nil) {
- trace = [FIRPerformance startTraceWithName:traceName];
- [self.traces setObject:trace forKey:traceName ];
+ if ( self.traces == nil) {
+ self.traces = [NSMutableDictionary new];
+ }
- }
+ if (trace == nil) {
+ trace = [FIRPerformance startTraceWithName:traceName];
+ [self.traces setObject:trace forKey:traceName ];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITPERFORMANCE];
}
+
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
@@ -491,21 +401,16 @@ - (void)startTrace:(CDVInvokedUrlCommand *)command {
- (void)incrementCounter:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
- if(self.performanceInit){
- NSString* traceName = [command.arguments objectAtIndex:0];
- NSString* counterNamed = [command.arguments objectAtIndex:1];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- FIRTrace *trace = (FIRTrace*)[self.traces objectForKey:traceName];
-
- if (trace != nil) {
- [trace incrementCounterNamed:counterNamed];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
- }
+ NSString* traceName = [command.arguments objectAtIndex:0];
+ NSString* counterNamed = [command.arguments objectAtIndex:1];
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ FIRTrace *trace = (FIRTrace*)[self.traces objectForKey:traceName];
+
+ if (trace != nil) {
+ [trace incrementCounterNamed:counterNamed];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITPERFORMANCE];
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
@@ -515,21 +420,16 @@ - (void)incrementCounter:(CDVInvokedUrlCommand *)command {
- (void)stopTrace:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
- if(self.performanceInit){
- NSString* traceName = [command.arguments objectAtIndex:0];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- FIRTrace *trace = [self.traces objectForKey:traceName];
-
- if (trace != nil) {
- [trace stop];
- [self.traces removeObjectForKey:traceName];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
- }
+ NSString* traceName = [command.arguments objectAtIndex:0];
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ FIRTrace *trace = [self.traces objectForKey:traceName];
+
+ if (trace != nil) {
+ [trace stop];
+ [self.traces removeObjectForKey:traceName];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITPERFORMANCE];
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
@@ -538,15 +438,10 @@ - (void)stopTrace:(CDVInvokedUrlCommand *)command {
- (void)setAnalyticsCollectionEnabled:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
- CDVPluginResult *pluginResult;
BOOL enabled = [[command argumentAtIndex:0] boolValue];
- if(self.analyticsInit){
- [[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:enabled];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:ERRORINITANALYTICS];
- }
+ [[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:enabled];
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
diff --git a/www/firebase-browser.js b/www/firebase-browser.js
index 6a57d8cae..01e39cb9f 100755
--- a/www/firebase-browser.js
+++ b/www/firebase-browser.js
@@ -1,27 +1,3 @@
-exports.initFirebase = function (success, error) {
- if (typeof success === 'function') {
- success();
- }
-};
-
-exports.initCrashlytics = function (success, error) {
- if (typeof success === 'function') {
- success();
- }
-};
-
-exports.initAnalytics = function (success, error) {
- if (typeof success === 'function') {
- success();
- }
-};
-
-exports.initPerformance = function (success, error) {
- if (typeof success === 'function') {
- success();
- }
-};
-
exports.getVerificationID = function (number, success, error) {
if (typeof success === 'function') {
success();
diff --git a/www/firebase.js b/www/firebase.js
index 9cb19248a..8bd50ce3e 100644
--- a/www/firebase.js
+++ b/www/firebase.js
@@ -1,17 +1,5 @@
var exec = require('cordova/exec');
-exports.initCrashlytics = function (success, error) {
- exec(success, error, "FirebasePlugin", "initCrashlytics", []);
-};
-
-exports.initAnalytics = function (success, error) {
- exec(success, error, "FirebasePlugin", "initAnalytics", []);
-};
-
-exports.initPerformance = function (success, error) {
- exec(success, error, "FirebasePlugin", "initPerformance", []);
-};
-
exports.getVerificationID = function (number, success, error) {
exec(success, error, "FirebasePlugin", "getVerificationID", [number]);
};