Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions chrome-extension/Readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
WebSDK and Web Push in Chrome Exension
1. Make sure to integrate webSDK to your chrome extension
- Download the latest code from https://cdn.moengage.com/webpush/moe_webSdk.min.latest.js
- Create a new file name webSDK.min.js and save code inside it.
- Inject that script to your extension project.
- Initialize SDK after webSDK.min.js script exection as shared on popup.js
2. To use Web Push notification
- For Web Push notification manifest_version: 3 is required.
- SDK required ["notifications", "storage"] Permission which you have to add in you manifest.json file.
- Make sure to download the moengage chrome extesnion service worker code from https://cdn.moengage.com/webpush/beta/serviceworker_chrome_ext_cdn.js.
- Use that code inside your background.js file.
2 changes: 2 additions & 0 deletions chrome-extension/background.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion chrome-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "Moengage SDK",
"name": "Moengage SDK WebPush",
"description": "Moengage Web SDK Sample for Chrome Extension",
"version": "1.0",
"background": {
"service_worker": "background.js"
},
"permissions": ["notifications"],
"web_accessible_resources": [{
"resources": [ "injectScripts/webSDK.min.js", "injectScripts/webSDK.cards.min.js" ],
"matches": [ "<all_urls>" ]
}],
"manifest_version": 3,
"action": {
"default_popup": "hello.html",
Expand Down
10 changes: 7 additions & 3 deletions chrome-extension/popup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
console.log('This is a popup!');
window.Moengage = moe({
app_id: 'XXXXXXXXXXXXXXXX',
debug_logs: 0
});
app_id: 'XXXXXXXXXXXXXXXXXXXX',
environment: 'sdk-01.moengage.com',
debug_logs: 0,
disable_onsite: true,
disableCookies: true
});

3 changes: 2 additions & 1 deletion chrome-extension/webSDK.min.js

Large diffs are not rendered by default.