Skip to content

Commit 41c6bca

Browse files
committed
feat(firebase-crashlytics): add plugin
related: #2889
1 parent d55d1d6 commit 41c6bca

File tree

1 file changed

+182
-0
lines changed
  • src/@ionic-native/plugins/firebase-crashlytics

1 file changed

+182
-0
lines changed
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
import { Injectable } from '@angular/core';
2+
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
3+
4+
/**
5+
* @name Firebase Crashlytics
6+
* @description
7+
* A Google Firebase Crashlytics plugin to enable capture of crash reports.
8+
*
9+
* @usage
10+
* ```typescript
11+
* import { FirebaseCrashlytics } from '@ionic-native/firebase-crashlytics/ngx';
12+
*
13+
*
14+
* constructor(private firebaseCrashlytics: FirebaseCrashlytics) { }
15+
*
16+
* ...
17+
*
18+
*
19+
* const crashlytics = this.firebaseCrashlytics.initialize();
20+
* crashlytics.logException('my caught exception');
21+
*
22+
* ```
23+
*/
24+
@Plugin({
25+
pluginName: 'FirebaseCrashlytics',
26+
plugin: 'cordova-plugin-firebase-crashlytics',
27+
pluginRef: 'FirebaseCrashlytics',
28+
repo: 'https://github.com/ReallySmallSoftware/cordova-plugin-firebase-crashlytics',
29+
install: 'ionic cordova plugin add cordova-plugin-firebase-crashlytics --variable ANDROID_FIREBASE_CORE_VERSION=16.0.0',
30+
installVariables: ['ANDROID_FIREBASE_CORE_VERSION'],
31+
platforms: ['Android', 'iOS']
32+
})
33+
@Injectable()
34+
export class FirebaseCrashlytics extends IonicNativePlugin {
35+
/**
36+
* Simply add the plugin to get the default Crashlytics functionality. Note that crashes and logged exceptions will only be reported when the application restarts. In order to log caught exceptions the following can be used:
37+
*
38+
* @returns {void}
39+
*/
40+
@Cordova({
41+
sync: true
42+
})
43+
initialize(): void {
44+
return; // We add return; here to avoid any IDE / Compiler errors
45+
}
46+
47+
/**
48+
* Generate a forced crash. Visible in console after restart of application.
49+
*
50+
* @returns {void}
51+
*/
52+
@Cordova({
53+
sync: true
54+
})
55+
crash(): void {
56+
return; // We add return; here to avoid any IDE / Compiler errors
57+
}
58+
59+
/**
60+
* Log a priority message. Will only be logged in the event of a crash.
61+
*
62+
* @param {number} priority
63+
* @param {string} tag
64+
* @param {string} message
65+
* @returns {void}
66+
*/
67+
@Cordova({
68+
sync: true
69+
})
70+
logPriority(priority: number, tag: string, message: string): void {
71+
return;
72+
}
73+
74+
/**
75+
* Log a message. Will only be logged in the event of a crash.
76+
*
77+
* @param {string} message
78+
* @returns {void}
79+
*/
80+
@Cordova({
81+
sync: true
82+
})
83+
log(message: string): void {
84+
return;
85+
}
86+
87+
/**
88+
* Log when a handled exception has happened. Visible in console after restart of application.
89+
*
90+
* @param {string} message
91+
* @returns {void}
92+
*/
93+
@Cordova({
94+
sync: true
95+
})
96+
logException(message: string): void {
97+
return;
98+
}
99+
100+
/**
101+
* Set extra key/value string value. Will only be logged in the event of a crash.
102+
*
103+
* @param {string} key
104+
* @param {string} value
105+
* @returns {void}
106+
*/
107+
@Cordova({
108+
sync: true
109+
})
110+
setString(key: string, value: string): void {
111+
return;
112+
}
113+
114+
/**
115+
* Set extra key/value bool value. Will only be logged in the event of a crash.
116+
*
117+
* @param {string} key
118+
* @param {boolean} value
119+
* @returns {void}
120+
*/
121+
@Cordova({
122+
sync: true
123+
})
124+
setBool(key: string, value: boolean): void {
125+
return;
126+
}
127+
128+
/**
129+
* Set extra key/value double value. Will only be logged in the event of a crash.
130+
*
131+
* @param {string} key
132+
* @param {number} value
133+
* @returns {void}
134+
*/
135+
@Cordova({
136+
sync: true
137+
})
138+
setDouble(key: string, value: number): void {
139+
return;
140+
}
141+
142+
/**
143+
* Set extra key/value float value. Will only be logged in the event of a crash.
144+
*
145+
* @param {string} key
146+
* @param {number} value
147+
* @returns {void}
148+
*/
149+
@Cordova({
150+
sync: true
151+
})
152+
setFloat(key: string, value: number): void {
153+
return;
154+
}
155+
156+
/**
157+
* Set extra key/value integer value. Will only be logged in the event of a crash.
158+
*
159+
* @param {string} key
160+
* @param {number} value
161+
* @returns {void}
162+
*/
163+
@Cordova({
164+
sync: true
165+
})
166+
setInt(key: string, value: number): void {
167+
return;
168+
}
169+
170+
/**
171+
* Set the identifier for the user. Take care when using this method and ensure you privacy policy is updated accordingly.
172+
*
173+
* @param {string} identifier
174+
* @returns {void}
175+
*/
176+
@Cordova({
177+
sync: true
178+
})
179+
setUserIdentifier(identifier: string): void {
180+
return;
181+
}
182+
}

0 commit comments

Comments
 (0)