• Stars
    star
    101
  • Rank 331,721 (Top 7 %)
  • Language
    TypeScript
  • License
    Other
  • Created almost 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.

Welcome to the onesignal-expo-plugin πŸ‘‹

Version Documentation Maintenance Twitter: onesignal

The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.

Overview

This plugin is an Expo Config Plugin. It extends the Expo config to allow customizing the prebuild phase of managed workflow builds (no need to eject to a bare workflow). For the purposes of OneSignal integration, the plugin facilitates automatically generating/configuring the necessary native code files needed to get the OneSignal React-Native SDK to work. You can think of adding a plugin as adding custom native code.

Supported environments:


Install

You need both the onesignal-expo-plugin and the react-native-onesignal npm package.

npx expo install onesignal-expo-plugin

# npm
npm install react-native-onesignal

# yarn
yarn add react-native-onesignal

Configuration in app.json / app.config.js

Plugin

Add the plugin to the front of the plugin array. It should be added automatically if you ran npx expo install. Just make sure it is the first plugin in the array and to configure any desired plugin props:

app.json

{
  "plugins": [
    [
      "onesignal-expo-plugin",
      {
        "mode": "development",
      }
    ]
  ]
}

or

app.config.js

export default {
  ...
  plugins: [
    [
      "onesignal-expo-plugin",
      {
        mode: "development",
      }
    ]
  ]
};

Plugin Prop

You can pass props to the plugin config object to configure:

Plugin Prop
mode required Used to configure APNs environment entitlement. "development" or "production"
devTeam optional Used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager e.g: "91SW8A37CR"
iPhoneDeploymentTarget optional Target IPHONEOS_DEPLOYMENT_TARGET value to be used when adding the iOS NSE. A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: "12.0".
smallIcons optional An array of local paths to small notification icons for Android. Image should be white, transparent, and 96x96 in size. Input images will be automatically scaled down and placed in the appropriate resource folders. e.g: ["./assets/ic_stat_onesignal_default.png"]. See https://documentation.onesignal.com/docs/customize-notification-icons#small-notification-icons.
largeIcons optional An array of local paths to large notification icons for Android. Image should be white, transparent, and 256x256 in size. e.g: ["./assets/ic_onesignal_large_icon_default.png"]. See https://documentation.onesignal.com/docs/customize-notification-icons#large-notification-icons.
iosNSEFilePath optional The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy of the default NSE, then altered to support any custom logic required. e.g: "./assets/NotificationService.m".

OneSignal App ID

Add your OneSignal App ID to your Expo constants via the extra param:

Example:

{
  "extra": {
    "oneSignalAppId": "<YOUR APP ID HERE>"
  }
}

You can then access the value to pass to the setAppId function:

import OneSignal from 'react-native-onesignal';
import Constants from "expo-constants";
OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);

Alternatively, pass the app ID directly to the function:

OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");

Versioning

In your configuration file, make sure you set:

Property Details
version Your app version. Corresponds to CFBundleShortVersionString on iOS. It is a human-readable version number of an iOS app, and is typically in the format of "X.X.X" (e.g. "1.0" or "2.3.1"). It is the version number that is typically displayed to users in the App Store and in the app itself. This value will be used in your NSE* target's plist file.
ios.buildNumber Build number for your iOS standalone app. Corresponds to CFBundleVersion and must match Apple's specified format (e.g: "42" or "100"). The build number is used by the App Store and iOS to identify and track different versions of an app, and is typically incremented for each new release. It is a number typically used for the developer's and system reference. This value will be used in your NSE* target's plist file.
ios.bundleIdentifier Bundle identifier for your iOS standalone app. Corresponds to CFBundleIdentifier. It's a unique identifier string that is used to identify an iOS app or bundle. It is typically in the format of "com.companyname.appname" (e.g. "com.example.myapp"). This value will be used in your NSE* target's plist and entitlements file.

* NSE = Notification Service Extension. Learn more about the NSE here.

EAS (Expo Application Services)

See our EAS documentation for help with EAS.

iOS Credentials: OneSignal + EAS

To distribute your iOS application via EAS, you will need to ensure your credentials are set up correctly. See our credentials setup guide for instructions.

Prebuild (optional)

Prebuilding in Expo will result in the generation of the native runtime code for the project (and ios and android directories being built). By prebuilding, we automatically link and configure the native modules that have implemented CocoaPods, autolinking, and other config plugins. You can think of prebuild like a native code bundler.

When you run expo prebuild we enter into a custom managed workflow which provides most of the benefits of bare workflows and managed workflows at the same time.

Why should I prebuild?

It may make sense to prebuild locally to inspect config plugin changes and help in debugging issues.

Run

npx expo prebuild
# nukes changes and rebuilds
npx expo prebuild --clean

EAS Note: if you choose to stay in a fully managed workflow by not prebuilding, EAS will still run npx expo prebuild at build time. You can also prebuild locally but remain in a fully managed workflow by adding the android and ios directories to your .gitignore.

Run

The following commands will prebuild and run your application. Note that for iOS, push notifications will not work in the Simulator.

# Build and run your native iOS project
npx expo run:ios

# Build and run your native Android project
npx expo run:android

🀝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

OneSignal

πŸ“ License

Copyright Β© 2023 OneSignal.
This project is MIT licensed.

More Repositories

1

react-native-onesignal

React Native Library for OneSignal Push Notifications Service
TypeScript
1,516
star
2

OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
Dart
582
star
3

OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Java
573
star
4

OneSignal-iOS-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native iOS app with OneSignal. https://onesignal.com
Objective-C
464
star
5

OneSignal-Website-SDK

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
TypeScript
377
star
6

OneSignal-Cordova-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Ionic, PhoneGap CLI, PhoneGap Build, Cordova, or Sencha Touch app with OneSignal. Supports Android, iOS, and Amazon's Fire OS platforms. https://onesignal.com
Java
238
star
7

OneSignal-Unity-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Unity app with OneSignal. https://onesignal.com
C#
208
star
8

OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Objective-C
101
star
9

OneSignal-WordPress-Plugin

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

serde-redis

Serde support for redis-rs
Rust
74
star
11

OneSignal-Gradle-Plugin

Use with OneSignal-Android-SDK to help integrate it into your Android Studio or Gradle project. https://onesignal.com
Groovy
64
star
12

react-onesignal

React OneSignal Module: Make it easy to integrate OneSignal with your React App!
TypeScript
63
star
13

L3-37

Yet another Tokio connection pooler. May cause robot uprising.
Rust
53
star
14

OneSignal-XCFramework

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native iOS app with OneSignal. https://onesignal.com. This Repository hosts OneSignal's XCFramework to be used with Swift Package Manager
Swift
18
star
15

onesignal-node-api

OneSignal Node Client
TypeScript
17
star
16

linebased

Drop-in TCP command server
Rust
16
star
17

onesignal-ruby-api

Ruby
13
star
18

cli

Command line tool for OneSignal power users. 1-step iOS SDK Integration. Now in Beta.
Ruby
13
star
19

onesignal-php-api

The official OneSignal API client for PHP
PHP
11
star
20

onesignal-vue

Vue OneSignal Plugin: Make it easy to integrate OneSignal with your Vue App!
TypeScript
10
star
21

OneSignal-DotNet-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your .NET app with OneSignal. https://onesignal.com
Objective-C
10
star
22

onesignal-vue3

Vue 3 OneSignal Plugin: Make it easy to integrate OneSignal with your Vue App!
TypeScript
9
star
23

onesignal-python-api

Python
8
star
24

onesignal-dotnet-api

C#
8
star
25

onesignal-go-api

The official OneSignal API client for Go
7
star
26

sdks

OneSignal simplifies customer messaging. Integrate with ease today.
6
star
27

OneSignal-ChromeApp-SDK

OneSignal is a free push notification service for Chrome and mobile apps. This plugin makes it easy to integrate your Chrome App or Extension with OneSignal. https://onesignal.com
JavaScript
6
star
28

onesignal-java-api

Java
5
star
29

onesignal-ngx

OneSignal Angular
4
star
30

hyper-client-pool

For when one hyper::Client isn't enough
Rust
4
star
31

rust-service

A framework for writing system services
Rust
4
star
32

onesignal-rust-api

OneSignal Rust API Client SDK library
Rust
4
star
33

envgrep

Search through all process environment variables on linux
Rust
4
star
34

api

API Reference. OpenAPI Specification files for OneSignal's REST API.
Shell
3
star
35

OneSignal-Marmalade-SDK

OneSignal is a free push notification service for mobile apps. This extension makes it easy to integrate your Marmalade app with OneSignal. https://onesignal.com
C++
3
star
36

HttpWebPushDemo

OneSignal HTTP web push demo.
CSS
3
star
37

geocoder_rs

Rust
2
star
38

web-test-ext

Chrome extension to aid in web SDK tests by providing browser automation and settings controls.
JavaScript
2
star
39

OneSignal-Cordova-Dependencies-Compat

Use for Intel XDK with the onesignal-cordova-plugin-pgb-compat pluign. https://onesignal.com
2
star
40

NotificationActivityBackstackExample

Example showing Activity back stack started from notifications do NOT work correctly on some devices, such as Xiaomi
Java
2
star
41

openssl

C
2
star
42

thesis

Rust library for controling experimental refactors
Rust
2
star
43

help

Get help using and integrating OneSignal's powerful messaging service. Community and commercial support available.
1
star
44

docs

OneSignal Documentation. Community-driven documentation for users and developers.
1
star
45

OneSignal-Alexa-Nodejs-SDK

This plugin makes it easy to integrate your Amazon Alexa Skill with OneSignal. https://onesignal.com
JavaScript
1
star
46

zk-4lw

ZooKeeper Four Letter Word Client Library for Rust
Rust
1
star
47

OneSignal-Solar2D-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Solar2D app with OneSignal https://www.onesignal.com
Java
1
star
48

CustomPushOriginSubdomainDemo

Setup OneSignal web push notifications with notifications coming from https://my-push-subdomain.yoursite.com. This repo demos the behind-the-scenes code used for the actual "my-push-subdomain".yoursite.com.
HTML
1
star
49

examples

Customer Messaging made obvious. Tutorials and Recipes for using OneSignal. Sample applications that show the way.
1
star