-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New PreyFirebaseCrashlytics
- Loading branch information
Showing
2 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/prey/exceptions/PreyFirebaseCrashlytics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Created by Orlando Aliaga | ||
* Copyright 2023 Prey Inc. All rights reserved. | ||
* License: GPLv3 | ||
* Full license at "/LICENSE" | ||
******************************************************************************/ | ||
package com.prey.exceptions; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.crashlytics.FirebaseCrashlytics; | ||
|
||
import com.prey.PreyConfig; | ||
|
||
public class PreyFirebaseCrashlytics { | ||
|
||
private static PreyFirebaseCrashlytics instance = null; | ||
private FirebaseCrashlytics crashlytics = null; | ||
|
||
private PreyFirebaseCrashlytics(Context ctx) { | ||
//initialize FirebaseCrashlytics | ||
FirebaseApp.initializeApp(ctx); | ||
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); | ||
crashlytics.setCustomKey("devicekey", PreyConfig.getPreyConfig(ctx).getDeviceId()); | ||
crashlytics.setCustomKey("apikey", PreyConfig.getPreyConfig(ctx).getApiKey()); | ||
} | ||
|
||
public static PreyFirebaseCrashlytics getInstance(Context ctx) { | ||
if (instance == null) | ||
instance = new PreyFirebaseCrashlytics(ctx); | ||
return instance; | ||
} | ||
|
||
/** | ||
* Method to report an exception | ||
*/ | ||
public void recordException(@NonNull Throwable throwable) { | ||
crashlytics.recordException(throwable); | ||
} | ||
} |