{"library":"onesignal-vue","title":"OneSignal Vue 2 Plugin","description":"The `onesignal-vue` package provides a specialized JavaScript module to seamlessly integrate OneSignal's push notification, in-app messaging, and analytics services into Vue 2 applications. It acts as a wrapper around the core OneSignal Web SDK, simplifying setup and API access within the Vue ecosystem. Currently at version 2.7.0, the library receives frequent minor and patch updates, indicating active maintenance and continuous improvement. Its primary differentiator is its targeted compatibility with Vue 2, offering a `Vue.use()` plugin interface and injecting the OneSignal API directly onto Vue instances as `$OneSignal`. For Vue 3 projects, a separate package, `onesignal-vue3`, is required due to breaking changes in Vue's plugin architecture.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install onesignal-vue"],"cli":null},"imports":["import OneSignalVue from 'onesignal-vue';","this.$OneSignal.init({ appId: '...' });","import { IDisplayableOSNotification } from 'onesignal-vue';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Vue from 'vue';\nimport App from './App.vue';\nimport OneSignalVue from 'onesignal-vue';\n\n// Install the plugin globally\nVue.use(OneSignalVue);\n\nnew Vue({\n  render: (h) => h(App),\n  beforeMount() {\n    // Initialize OneSignal with your App ID\n    // Replace 'YOUR_ONESIGNAL_APP_ID' with your actual OneSignal Application ID\n    this.$OneSignal.init({ appId: 'YOUR_ONESIGNAL_APP_ID' })\n      .then(() => {\n        console.log('OneSignal initialized successfully.');\n        // Example: Prompt the user for push notification permission\n        this.$OneSignal.User.PushSubscription.optIn();\n      })\n      .catch(error => {\n        console.error('OneSignal initialization failed:', error);\n      });\n  },\n}).$mount('#app');","lang":"javascript","description":"Demonstrates how to install the `onesignal-vue` plugin and initialize the OneSignal SDK with an application ID in a Vue 2 application, then prompts the user for push notification permission.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}