Skip to content
Projets

OneSignal/OneSignal-Cordova-SDK

Voir sur GitHub

À propos

OneSignal makes engaging customers simple and is the fastest, most reliable service to send push notifications, in-app messages, SMS, and emails. This plugin makes it easy to integrate your Cordova app with OneSignal. https://onesignal.com

Productivité et automatisation

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Setup

Install clang-format (21.1.3) e.g. brew install clang-format.

OneSignal Cordova Push Notification Plugin

npm version npm downloads


⚠️ Migration Advisory for current OneSignal customers

Our new user-centric APIs and v5.x.x SDKs offer an improved user and data management experience. However, they may not be at 1:1 feature parity with our previous versions yet.

If you are migrating an existing app, we suggest using iOS and Android’s Phased Rollout capabilities to ensure that there are no unexpected issues or edge cases. Here is the documentation for each:

If you run into any challenges or have concerns, please contact our support team at [email protected]


OneSignal is a free email, sms, push notification, and in-app message service for mobile apps. This plugin makes it easy to integrate your Cordova based (e.g. Ionic, PhoneGap, and PhoneGap Build app with OneSignal.

Cordova Notification

Installation and Setup

See the Documentation for installation and setup instructions:

API

See OneSignal's Client SDK Reference page for a list of all available methods.

iOS Native Dependencies

On iOS the plugin is distributed only through Swift Package Manager. CocoaPods is not supported, because CocoaPods trunk became read-only on December 2, 2026 and new OneSignal iOS SDK versions are no longer published there.

  • Cordova apps need cordova-ios 8 or newer, which resolves this plugin through SPM automatically.
  • Capacitor apps need Capacitor 8.4.0 or newer using SPM, so Capacitor can read this plugin's root Package.swift. To migrate an existing CocoaPods app, run npx cap spm-migration-assistant and follow the Capacitor SPM guide.
  • If you added a Notification Service Extension or Live Activity widget, remove its OneSignalXCFramework pod from the Podfile. In Xcode, add the https://github.com/OneSignal/OneSignal-XCFramework package to that target instead: OneSignalExtension for the extension and OneSignalFramework for the widget.

The demo app in examples/demo validates the Capacitor SPM path.

Manual iOS Dependency Tests

Use this check from a clean checkout when changing iOS dependency resolution:

vp install
vp run build

TMP_DIR=$(mktemp -d)
vpx cordova create "$TMP_DIR/spm-app" com.onesignal.spmtest SPMTest
cd "$TMP_DIR/spm-app"
vpx cordova platform add ios@8
vpx cordova plugin add /path/to/OneSignal-Cordova-SDK
vpx cordova prepare ios

# The OneSignal pod should be skipped when SPM is active.
! grep -R "OneSignalCordovaDependencies" platforms/ios/Podfile

APP_NAME=$(basename platforms/ios/*.xcodeproj .xcodeproj)
xcodebuild -resolvePackageDependencies -project "platforms/ios/${APP_NAME}.xcodeproj"
xcodebuild -workspace "platforms/ios/${APP_NAME}.xcworkspace" \
  -scheme "$APP_NAME" \
  -configuration Debug \
  -sdk iphonesimulator \
  -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath build \
  -quiet build \
  CODE_SIGNING_ALLOWED=NO \
  COMPILER_INDEX_STORE_ENABLE=NO

Replace /path/to/OneSignal-Cordova-SDK with the path to this repository. A passing test resolves OneSignal-XCFramework through SPM and builds without adding OneSignalCordovaDependencies to the Podfile.

Disabling OneSignal Location

If your app does not use OneSignal.Location, you can exclude the native OneSignal location module from Android and iOS builds.

Set ONESIGNAL_DISABLE_LOCATION=true in the environment before installing the plugin or syncing native platforms, because this flag is read when native dependencies are resolved. The value is case-insensitive, and 1 is also accepted. For iOS Swift Package Manager, also set the flag for the actual Xcode build process so Package.swift is evaluated with location disabled.

ONESIGNAL_DISABLE_LOCATION=true cordova plugin add onesignal-cordova-plugin
ONESIGNAL_DISABLE_LOCATION=true cordova platform add ios
ONESIGNAL_DISABLE_LOCATION=true cordova platform add android

Capacitor apps do not need to edit CapApp-SPM/Package.swift; run Capacitor sync in an environment where the flag is set:

ONESIGNAL_DISABLE_LOCATION=true npx cap sync ios
ONESIGNAL_DISABLE_LOCATION=true npx cap sync android
ONESIGNAL_DISABLE_LOCATION=true npx cap run ios --no-sync

In CI, set the flag once at the job or step level so Xcode and Gradle inherit it:

env:
  ONESIGNAL_DISABLE_LOCATION: true

With the location module disabled, calls to OneSignal.Location are ignored and OneSignal.Location.isShared() resolves false.

If you change this setting in an existing project, clear the relevant native dependency state and re-resolve in a shell where the variable is exported.

For Capacitor:

rm -rf ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
ONESIGNAL_DISABLE_LOCATION=true xcodebuild \
  -resolvePackageDependencies \
  -project ios/App/App.xcodeproj \
  -derivedDataPath ios/App/build
ONESIGNAL_DISABLE_LOCATION=true xcodebuild \
  -project ios/App/App.xcodeproj \
  -scheme App \
  -derivedDataPath ios/App/build

When using Xcode or Android Studio, launch the IDE from a terminal that has ONESIGNAL_DISABLE_LOCATION exported. An IDE launched from the Dock/Finder does not inherit variables set only in your shell profile.

Change Log

See this repository's release tags for a complete change log of every released version.

Support

Please visit this repository's Github issue tracker for feature requests and bug reports related specificly to the SDK. For account issues and support please contact OneSignal support from the OneSignal.com dashboard.

Demo Projects

To make things easier, we have published an Ionic Capacitor React demo app in the examples/demo folder of this repository.

Legacy (Player Model) demo projects:

Supports:

  • Cordova, Ionic, Ionic Capacitor, and Phonegap
  • Android 4.1 (API Level 16) through 12 (API Level 31), and Amazon FireOS
  • iOS 9 - 15

Explorer des projets similaires

Chargement…