parse-community / Parse-SDK-JS

The JavaScript SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
1.32k stars 596 forks source link

feat: Improve installation object `Parse.Installation.currentInstallation` to support web push notifications #2119

Closed dplewis closed 4 months ago

dplewis commented 4 months ago

Pull Request

Issue

Other Parse SDKs (Swift/Kotlin, etc) supports the Installation object to handle push notifications etc. There seems in the JS SDK there is just a minimal implementation.

Closes: https://github.com/parse-community/Parse-SDK-JS/issues/2112

Approach

const installation = await Parse.Installation.currentInstallation();
installation.set('deviceToken', '123');
installation.set('deviceType', 'web');
installation.set('user', Parse.User.current());
await installation.save();

Tasks

parse-github-assistant[bot] commented 4 months ago

Thanks for opening this pull request!

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (72bc9ac) to head (3803596). Report is 21 commits behind head on alpha.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## alpha #2119 +/- ## =========================================== + Coverage 99.98% 100.00% +0.01% =========================================== Files 61 64 +3 Lines 6185 6275 +90 Branches 1499 1508 +9 =========================================== + Hits 6184 6275 +91 + Misses 1 0 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

parseplatformorg commented 4 months ago

🎉 This change has been released in version 5.1.0-alpha.9

mortenmo commented 4 months ago

@dplewis This might be a general problem and not related to this PR/Web, but I accidentally deleted an installation in the database and it gets into a state where nothing works and it doesn't seem to be a way to get out of it.

The InstallationController never checks for server changes to object, so save() just fails since the local object has an id. And beyond cleaning the cache keys manually out of storage, there is no way to reset the installation locally.

Rest seems to work great though! and this is an edge case for sure. I just cleaned up the wrong things.

dplewis commented 4 months ago

@mortenmo That seems to be a problem. I was looking at the iOS SDK and this SDK should match it closely.

Installations cannot be deleted

We always want [currentInstallation save] to succeed.

parseplatformorg commented 3 months ago

🎉 This change has been released in version 5.1.0-beta.1

parseplatformorg commented 3 months ago

🎉 This change has been released in version 5.1.0