Coder Social home page Coder Social logo

onesignal / onesignal-website-sdk Goto Github PK

View Code? Open in Web Editor NEW
383.0 58.0 115.0 21.96 MB

OneSignal is a push notification service for web and mobile apps. This SDK makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com

License: Other

JavaScript 2.20% TypeScript 91.28% Shell 0.62% Dockerfile 0.01% HTML 1.32% SCSS 4.58%
webpush web-push notifications notification-service javascript serviceworker push-notifications pushnotifications onesignal email

onesignal-website-sdk's Introduction



Showing web push notifications from Chrome, Safari, and Firefox

OneSignal Web Push SDK

OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.

This SDK allows your site's visitors to receive push notifications from you. Send visitors custom notification content, target specific users, and send automatically based on triggers.

Getting Started

View our documentation to get started.

Please reference the OneSignal SDK on your webpage via our CDN URL (listed in our setup documentation) instead of copying the source into another file. This is because our SDK updates frequently for new features and bug fixes.

onesignal-website-sdk's People

Contributors

burningtree avatar dependabot[bot] avatar devpato avatar emawby avatar fedterzi avatar gdeglin avatar gonzalonarbaiz avatar itrush avatar jasonpang avatar jkasten2 avatar jmadler avatar jordikroon avatar kootoopas avatar leemunroe avatar marclucraft avatar niels-s avatar rafaelncarvalho avatar rgomezp avatar ryanamos avatar shepherd-l avatar soroushchehresa avatar terrynsun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onesignal-website-sdk's Issues

If user deleted from OneSignal dashboard, wipe client-side data

It's not intuitive that deleting a user from the OneSignal dashboard still leaves behind client-side data on the browser. IndexedDB should be wiped and the service worker should be unregistered (if possible, on HTTPS) if we get a no user with this ID found error indicating the user is deleted.

Allow setDefaultTitle to have a blank title of ''

For a web push notification with a non-empty title specified when sending the message, that title will always be used.

For a web push notification sent without a title:

  • We check for whether a default title has been explicitly set. You would set a default title by calling OneSignal.setDefaultTitle() and this value is persisted in the site's web storage. If a default title has been explicitly set, it is used.
  • On any page with OneSignal active on it, our SDK stores the current page's title. In case the notification was sent without a title, and in case no default title has been explicitly set, we use the last visited page's title as the notification's title.
  • If, for any reason, neither the default title or the last visited page's title is stored, no title is displayed and the notification's title is left blank.

setDefaultTitle('') currently chokes because of this check: https://github.com/OneSignal/OneSignal-Website-SDK/blob/master/src/serviceWorker.js#L592. It should really be if (defaultTitle !== null) to allow the empty string as a valid title.

Currently users must call setDefaultTitle(' ') with a space in order to get around this.

Slim down SDK size

The current minified SDK size is 342 KB, and is 70.2 KB after browser compression.

Show the welcome notification again if the user subscribed

Currently the welcome notification is only shown to "new" users who have just had their IndexedDB database created for the first time. Change this so that the welcome notification is always shown on re-subscription to confirm that the user re-subscribed successfully.

Firefox IndexedDb InvalidStateError - Print typed descriptive error

with Firefox 45 we on some workstations with windows (7, 8.1, 10) we are not able to use website push notifications. while using chrome browser this works on the same workstation.

we debugged the error in firebug:
Unable to open IndexedDB. error
OneSignalSDK.js (Zeile 5)
UnknownError
OneSignalSDK.js (Zeile 5, Spalte 15054)

You have new updates shown if user is missing IndexedDB with service worker still active

Somehow, users' IndexedDB data is being cleared while the service worker is still active (as if only 'Offline Website Data' is cleared). When a push event is triggered on the service worker by Chrome, our service worker is unable to contact OneSignal to retrieve the notification contents, because the API to do so requires a valid user ID, which was stored in IndexedDB but is now missing.

Automate documentation and type information from source

I'm building an angular2 app with OneScript to do push, and it would be nice to have a definition file to use with typescript that helps implement the API correctly. Are you likely to provide one in the future? If not and I end up writing one, would you guys be interested in bundling it with your SDK?

It would also be a good thing to write/provide for the cordova SDK, since then we could integrate it more easily into our ionic2 app.

Please remove "onfetch" that catching everything (or an option to disable this)

Hello!
First of all thank you for OneSignal. It's very convenient to use.

My problem is that OneSignal ServiceWorker catching all requests. It seems useless cause it doesn't do anything except fetch. Even more, it's harmful!

In my case it broke all videos on my site. There are two reasons:

  1. Seems like "fetch" doesn't allow request to http video from https (while browser allow this).
  2. Even if I use https to request video, "fetch" seems like trying to download whole video and video player waiting until it would be done.

So, please remove it or add an option to disable it.

SDK initialization event is incompatible with CloudFlare's rocket loader

console.warn('Current Document ReadyState:', document.readyState);
document.onreadystatechange = () => console.warn('onreadystatechange ReadyState:', document.readyState);
window.addEventListener('DOMContentLoaded', () => console.warn('DOMContentLoaded ReadyState:', document.readyState));
window.addEventListener('load', () => console.warn('load ReadyState:', document.readyState));

Results:

Current Document ReadyState: loading
onreadystatechange ReadyState: loading
DOMContentLoaded ReadyState: loading
onreadystatechange ReadyState: loading
load ReadyState: loading

CloudFlare's rocket loader somehow modifies the loading events. However this event is still fired:

onreadystatechange: complete

So we should listen for that.

dashboard giving wrong Delivery Status

I am sending push Notifications to n devices,after sending message in delivery Status it is showing that the notification sent successfully to all the n devices but none of the device received any notification.
How can i solve this issue

Add in NPM

You can add your project in NPM?

npm install onesignal-web-sdk --save

listen to push notification

Is there a way to listen to the push notification ? I may need to perform a certain action when the user receives a certain type of notification while reading a certain article on my website. It would be nice to give users the option of displaying the Chrome notification message OR running a custom script or both.
The cordova implementation of of notificationOpenedCallback seem to do exactly what I need. However, I am unable to find a similar callback with the Web Push SDK. https://documentation.onesignal.com/docs/phonegap--cordova-sdk-api#notificationOpenedCallback

The only relevant callback for Web Push is addListenerForNotificationOpened but it requires the user to click the displayed message for the callback function to run. Also, it does not give me the option of disabling the default notification message when my website tab is active.

In other words, I may want to tap into the following

self.addEventListener('push', function(event) {  

});

as described in the following link:
https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web?hl=en

Firefox 45 not working (Ubuntu)

Website SDK isn't working on Firefox 45 (Ubuntu) :

TypeError: window.localStorage is null
 init()
  OneSignalSDK.js:4
 push()
  OneSignalSDK.js:5
 _processPushes()
  OneSignalSDK.js:5
 <anonyme>
  OneSignalSDK.js:1
 __webpack_require__()
  OneSignalSDK.js:1
 <anonyme>
  OneSignalSDK.js:1
 <anonyme>
  OneSignalSDK.js:1

Notify button circular drop shadow occasionally truncates and becomes rectangular

Causes:

  • On mobile, clicking the notify button to subscribing, dismissing the permission prompt, and clicking again on the page can cause the button to exhibit the rectangular truncated drop shadow
  • Pulse animation on desktop. Setting a display: none; to the .pulse-ring class seems to make it go away. Seems to occur on onesignal.com/webpush but not a local testing site.

Support Firefox 48+ mobile push notifications

Push is now enabled by default in Firefox 48, and users can subscribe, but:

  • Our isPushNotificationsSupported() method says Firefox 47 on Android supports push notifications, which isn't correct

Multiple subscriptions are made if multiple registerForPushNotifications() calls are made

If a user clicks the notify button, which brings up the permission prompt the first time, but instead of interacting with the prompt clicks the notify button one or more times again, the user is subscribed multiple times when he finally clicks Allow. The event handlers should not stack.

However, the registration IDs have been unique in the single test case I've observed.

Safari error

Hi there,

I'm seeing this error on Safari browser

TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.controller') ... sdk.js:1869

But notification are working.

In our website we are including this js file https://cdn.onesignal.com/sdks/OneSignalSDK.js

Let me know if you need more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.