Skip to content

Commit 70eeb66

Browse files
committed
fix: fix crash when google services not available
1 parent eddd52f commit 70eeb66

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

android/src/main/java/com/cryptoticket/reactnativepushnotification/PushNotificationModule.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ class PushNotificationModule(reactContext: ReactApplicationContext) : ReactConte
148148
try {
149149
FirebaseMessaging.getInstance().token
150150
.addOnCompleteListener(OnCompleteListener { task ->
151-
if (!task.isSuccessful) {
151+
if (task.isSuccessful) {
152+
val token = task.result
153+
promise.resolve(token)
154+
} else {
152155
promise.reject("E_FIREBASE_DEVICE_TOKEN", "Unable to retrieve device FCM token")
153156
}
154-
val token = task.result
155-
promise.resolve(token)
156157
})
157158
} catch (err: IOException) {
158159
promise.reject("E_FIREBASE_DEVICE_TOKEN", "Firebase instance is not available");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cryptoticket/react-native-push-notification",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "React native package that manages push notifications",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)