-
Notifications
You must be signed in to change notification settings - Fork 938
FCM Pre Modularization #3234
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
Merged
FCM Pre Modularization #3234
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
22a0ce5
FCM Pre Modualization
zwu52 78b0e73
Refactor FCM typing
zwu52 3e4f2d6
Polish javascript doc
zwu52 3aa4d88
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 d504772
Update index.d.ts
zwu52 0dfecf6
Add Changeset
zwu52 31fa196
Fix changeset from major to minor
zwu52 d058ba4
Add to changeset
zwu52 5b719a8
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 8aedf92
Polished index.d.ts based on Arthur's feedback
zwu52 d1670fe
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 0403b84
Polish PR based on feedbacks
zwu52 436fa54
Update Changeset
zwu52 5624886
Merge branch 'master' into api
zwu52 ed31954
Merge branch 'master' into api
zwu52 6921af8
Fix wording
zwu52 8911188
Merge branch 'api' of https://github.com/firebase/firebase-js-sdk int…
zwu52 374dc78
Polishing
zwu52 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'firebase': minor | ||
'@firebase/messaging': minor, | ||
--- | ||
|
||
Add `getToken(options:{serviceWorkerRegistration, vapidKey})`,`onBackgroundMessage`. | ||
Deprecate `setBackgroundHandler`, `onTokenRefresh`, `useVapidKey`, `useServiceWorker`, `getToken`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
async function addPayloadToDb(payload) { | ||
const dbOpenReq = indexedDB.open(TEST_DB); | ||
|
||
dbOpenReq.onupgradeneeded = () => { | ||
const db = dbOpenReq.result; | ||
|
||
// store creation is a synchronized call | ||
console.log('creating object store...'); | ||
db.createObjectStore(BACKGROUND_MESSAGES_OBJECT_STORE, { | ||
keyPath: BACKGROUND_MESSAGES_OBJECT_STORE_PRIMARY_KEY | ||
}); | ||
}; | ||
|
||
dbOpenReq.onsuccess = () => { | ||
const db = dbOpenReq.result; | ||
|
||
addPayloadToDbInternal(db, { | ||
...payload, | ||
// ndx is required as the primary key of the store. It doesn't have any other testing purpose | ||
ndx: BACKGROUND_MESSAGES_OBJECT_STORE_DEFAULT_NDX | ||
}); | ||
}; | ||
} | ||
|
||
async function addPayloadToDbInternal(db, payload) { | ||
// onsuccess might race with onupgradeneeded. Consequently causing "object stores was not found" error. Therefore, wait briefly for db.createObjectStore to complete | ||
zwu52 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const delay = ms => new Promise(res => setTimeout(res, ms)); | ||
await delay(/* milliseconds= */ 30000); | ||
|
||
tx = db.transaction(BACKGROUND_MESSAGES_OBJECT_STORE, 'readwrite'); | ||
|
||
console.log('adding message payload to db: ' + JSON.stringify(payload)); | ||
addReq = tx.objectStore(BACKGROUND_MESSAGES_OBJECT_STORE).add(payload); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
integration/messaging/test/static/valid-vapid-key-modern-sw/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<html> | ||
<head> | ||
<title>FCM Demo</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
</head> | ||
<body> | ||
<h1>Valid <strong>WITH</strong> VAPID Key - Modern SW</h1> | ||
|
||
<script src="/firebase-app.js"></script> | ||
<script src="/firebase-messaging.js"></script> | ||
<script src="../app.js"></script> | ||
<script src="../constants.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sinon.js/4.1.3/sinon.min.js"></script> | ||
<script> | ||
navigator.serviceWorker | ||
.register('./sw.js') | ||
.then(reg => { | ||
window.__test = new window.DemoApp(FIREBASE_CONFIG, { | ||
swReg: reg, | ||
vapidKey: PUBLIC_VAPID_KEY | ||
}); | ||
}) | ||
.catch(error => { | ||
console.log('Error registering FCM SW: ' + error); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.