Skip to content
프로젝트

OneSignal/react-native-onesignal

GitHub에서 보기

소개

OneSignal은 고객 참여를 간편하게 지원하며, 푸시 알림, 인앱 메시지, SMS, 이메일을 가장 빠르고 안정적으로 전송할 수 있는 서비스입니다. 이 플러그인을 사용하면 React Native 앱을 OneSignal과 쉽게 연동할 수 있습니다. https://onesignal.com

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
-1
in 7 days
-2
in 15 days
-4
in 1 month
-5

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

React Native OneSignal SDK

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 SDK makes it easy to integrate your native React-Native iOS and/or Android apps with OneSignal.

Requirements

  • React Native >=0.79.0 for 5.4.x and later. The TurboModule registers itself through the codegenConfig.ios.modulesProvider field added in React Native 0.79, so earlier versions will throw TurboModuleRegistry.getEnforcing(...): 'OneSignal' could not be found at runtime when the New Architecture is enabled. Apps on React Native 0.76–0.78 (including Expo SDK 52) should stay on 5.3.x, which uses the legacy bridge module and works on the New Architecture via the interop layer.

Installation

See the Setup Guide for setup instructions.

Swift Package Manager (iOS)

This package ships a Package.swift for React Native's Swift Package Manager mode (React Native 0.87 and later). In that mode it is the Swift package ReactNativeOneSignal, which brings in OneSignal-XCFramework. Run npx react-native spm add (or npx react-native spm update if SPM is already set up) after installing. CocoaPods apps stay on OneSignalXCFramework 5.8.1, because CocoaPods trunk is read-only and newer iOS SDK versions ship only through Swift Package Manager.

A Notification Service Extension target is not managed by React Native's autolinker. Add the OneSignalExtension product from https://github.com/OneSignal/OneSignal-XCFramework to it in Xcode, at the version Package.swift pins.

With pnpm, React Native's SwiftPM Release builds can fail with hermesc: No such file or directory, because React Native looks for hermes-compiler at the top level of node_modules. Hoist it in pnpm-workspace.yaml (or with public-hoist-pattern[]=hermes-compiler in .npmrc on pnpm 9 and earlier), then reinstall:

publicHoistPattern:
  - hermes-compiler

Disable Location Module

By default, react-native-onesignal includes OneSignal's native location module so OneSignal.Location works without extra setup. If your app does not use location features, you can exclude the native location module from iOS and Android builds.

Set ONESIGNAL_DISABLE_LOCATION=true in the environment before resolving or building, for both CocoaPods (iOS) and Gradle (Android). The value is case-insensitive, and 1 is also accepted:

ONESIGNAL_DISABLE_LOCATION=true pod install        # iOS, from the ios directory
ONESIGNAL_DISABLE_LOCATION=true ./gradlew assembleDebug   # Android, from the android directory

For Android, you can also persist the Gradle property in android/gradle.properties:

onesignal.disableLocation=true

In GitHub Actions, you can also set it once at the job or step level so pod install, pod update, and Gradle builds inherit it:

env:
  ONESIGNAL_DISABLE_LOCATION: true

When disabled, OneSignal.Location.requestPermission() and OneSignal.Location.setShared() no-op on native builds without the location module, and OneSignal.Location.isShared() resolves false.

Applying the change (clearing cached pods)

The environment variable is only read when dependencies are resolved. CocoaPods pins the resolved pods in Podfile.lock, so after changing the variable on an existing project you must reinstall pods in a shell where the variable is exported:

cd ios
pod deintegrate
rm -rf Pods Podfile.lock
ONESIGNAL_DISABLE_LOCATION=true pod install

Gradle re-reads the environment variable or onesignal.disableLocation property on each configuration, so a clean build after changing the flag is enough on Android.

With Swift Package Manager, Package.swift reads the variable when packages are resolved. Export it in the shell that runs npx react-native spm update and xcodebuild (or launches Xcode), then run File > Packages > Reset Package Caches in Xcode after changing it.

[!IMPORTANT] 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. On CI, key any CocoaPods, SwiftPM, Xcode DerivedData, and Gradle caches on the value of ONESIGNAL_DISABLE_LOCATION so a restored cache does not resurrect the location module.

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 specifically to the SDK. For account issues and support please contact OneSignal support from the OneSignal.com dashboard.

Demo Project

To make things easier, we have published some demo projects in the /examples folder of this repository.

관련 프로젝트 살펴보기

불러오는 중…