Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit b302884

Browse files
wildtigonmithun-mondal
authored andcommitted
[firebase_messaging] fix crash when func deleteInstanceID return result in incorrect thread (flutter-team-archive#1756)
* [firebase_messaging] fix crash when calling func deleteInstanceID (flutter-team-archive#1756)
1 parent ff8d355 commit b302884

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

packages/firebase_messaging/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.0.5
2+
3+
* On Android, fix crash when calling `deleteInstanceID` with latest Flutter engine.
4+
15
## 5.0.4
26

37
* Automatically use version from pubspec.yaml when reporting usage to Firebase.

packages/firebase_messaging/android/src/main/java/io/flutter/plugins/firebasemessaging/FirebaseMessagingPlugin.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,30 @@ public void onComplete(@NonNull Task<InstanceIdResult> task) {
148148
public void run() {
149149
try {
150150
FirebaseInstanceId.getInstance().deleteInstanceId();
151-
result.success(true);
151+
if (registrar.activity() != null) {
152+
registrar
153+
.activity()
154+
.runOnUiThread(
155+
new Runnable() {
156+
@Override
157+
public void run() {
158+
result.success(true);
159+
}
160+
});
161+
}
152162
} catch (IOException ex) {
153163
Log.e(TAG, "deleteInstanceID, error:", ex);
154-
result.success(false);
164+
if (registrar.activity() != null) {
165+
registrar
166+
.activity()
167+
.runOnUiThread(
168+
new Runnable() {
169+
@Override
170+
public void run() {
171+
result.success(false);
172+
}
173+
});
174+
}
155175
}
156176
}
157177
})

packages/firebase_messaging/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Cloud Messaging, a cross-platform
33
messaging solution that lets you reliably deliver messages on Android and iOS.
44
author: Flutter Team <flutter-dev@googlegroups.com>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_messaging
6-
version: 5.0.4
6+
version: 5.0.5
77

88
flutter:
99
plugin:

0 commit comments

Comments
 (0)