Our Chrome App Extension is no longer being updated, however it is open source if you would like to contribute:
https://github.com/OneSignal/OneSignal-ChromeApp-SDK
Required for setup
- OneSignal Account
- OneSignal App ID, available in Settings > Keys & IDs
- A Google Server API Key. See Generating a Google Server API Key for details
1. Import OneSignal
1.1 Download the latest OneSignal Chrome App SDK. 1.2 CopyOneSignal.js
to your App/Extension project folder.
1.3 Continue to 2A if you have a Chrome App.
Or continue to 2B if you have a Chrome Extension.
2A. Add OneSignal to a Chrome App
2A.1 Open yourmanifest.json
and add OneSignal.js
before you own background.js.
manifest.json
contains a background page
instead of scripts
, then add OneSignal.js
to your background HTML page before your own background.js
.
2A.2 In your manifest.json
add the following 5 permissions to your permissions array.
2B. Add OneSignal to a Chrome Extension
2B.1 Open yourmanifest.json
and add OneSignal.js
before you own background.js
.
Create new blank background.js
file if you don’t have a background script already.
manifest.json
, add the following permissions to your permissions array:
3. Add Required Code
3.1 Open yourbackground.js
file and add the following line outside of any function so it runs when your app/extension is loaded.
Replace appId
with your OneSignal App Id, and googleProjectNumber
with your own as well.
You should be all set to go with your Chrome App or Extension app.