-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MM-58818 fix android push notifications when app is closed #7989
Conversation
+ public void unsafeVacuum() { | ||
+ execute("vacuum"); | ||
+ } | ||
+ | ||
interface TransactionFunction { | ||
+ public interface TransactionFunction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the actual fix
@@ -57,7 +57,7 @@ fun DatabaseHelper.getDatabaseForServer(context: Context?, serverUrl: String): W | |||
if (cursor.count == 1) { | |||
cursor.moveToFirst() | |||
val databasePath = String.format("file://%s", cursor.getString(0)) | |||
return WMDatabase.getInstance(databasePath, context!!) | |||
return WMDatabase.buildDatabase(databasePath, context!!, SQLiteDatabase.CREATE_IF_NECESSARY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to ensure we create a new database connection as when they arrive in quick succession the code complains that we are trying to open an already closed database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migrated to Kotlin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find!
I'd say this should even be cherry-picked for 2.17, thoughts? cc: @larkox |
Cherry pick is scheduled. |
(cherry picked from commit e5ce796)
(cherry picked from commit e5ce796) Co-authored-by: Elias Nahum <[email protected]>
Has this landed to 2.17 in the end? In the git history, it's slated for 2.18. However, the
I'm curious because I'm seeing instability of push notifications when the app is closed after upgrading from 2.16 to 2.17. If the patch is not included, I can test it out whenever the next beta gets available. |
/cherry-pick release-2.17 |
Cherry pick is scheduled. |
(cherry picked from commit e5ce796)
(cherry picked from commit e5ce796) Co-authored-by: Elias Nahum <[email protected]>
It is still not working. I just tried with the latest code. |
Summary
On Android, when a push notification is received while the app is fully closed we were getting a crash with the following message
This is due to the fact that the WatermelonDB
interface TransactionFunction
was not explicitly set to public and for some reason not accessible while the app was not running, although it does not present the same problem when the app is in fact running either in the foreground or background.Along with this fix, we migrated the CustomPushNotification class to kotlin for better interoperatibility ensuring we process only one notification at a time even when they arrive in quick succession.
Release Note