Coder Social home page Coder Social logo

onesignal / onesignal-expo-plugin Goto Github PK

View Code? Open in Web Editor NEW
145.0 32.0 48.0 1.73 MB

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

License: Other

TypeScript 93.10% JavaScript 1.67% Objective-C 5.23%
react-native expo ios android eas onesignal onesignal-notifications notifications push push-notifications

onesignal-expo-plugin's Introduction

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.
smallIconAccentColor optional The accent color to use for notification icons on Android. Must be a valid hex value, e.g: "#FF0000"
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 initialize function:

import { OneSignal } from 'react-native-onesignal';
import Constants from "expo-constants";
OneSignal.initialize(Constants.expoConfig.extra.oneSignalAppId);

Alternatively, pass the app ID directly to the function:

OneSignal.initialize("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.

onesignal-expo-plugin's People

Contributors

a777med avatar amandeepmittal avatar brismithers avatar dependabot[bot] avatar emawby avatar iamwillshepherd avatar jesse-savary avatar jkasten2 avatar opmat avatar rgomezp avatar wkozyra95 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

onesignal-expo-plugin's Issues

[Bug]: Several Android users added, none correct

What happened?

After build the Expo App, upload it to google play and install on my google device, the onesignal sdk starts up and registered about 6 new users. After that, another 4... I tried to send a push notifications, but 9 is not subcribed and one is Google Play Services Library error.
I follow the ExpoSDK and build the app using Expo EAS
I did not make the ExpoSDK step 2.5 because I don't want to eject from expo.
Any help ?

Steps to reproduce?

1. Follow Expo SDK Setup
2. Configure app.json
3. Add google-service.json into app.json
3.1 - Add OneSignal.setAppId('appid') to App.tsx
4. Connect my firebase to the app com.humbertocruz.brasalapp
5. Build App with eas build - p android
6. Transfer to Google Play on a new app
7. Add a Internal Test version
8. Donload the App on GooglePlay
9. Run the app

What did you expect to happen?

One user from my phone (Sansung A71) created and receive a notification push

OneSignal Expo SDK version

"onesignal-expo-plugin": "^1.0.1"
"react-native-onesignal": "^4.3.7",

Platform

Android

Relevant log output

nothing from my app side

Code of Conduct

  • I agree to follow this project's Code of Conduct

Eas build error

Hi, I just updated the plugin and with eas gives me thi error:
ag for more details.
401
[stderr] error The resource
"/home/expo/workingdir/build/onesignal-expo-plugin: No specifiC actions required for OneSignAl on Android.
402
[stderr] index.js was not found.

I use expo 45, should I upgrade to 46?

We can't set if we want to open in app browser on iOS by Launch URL

We were using the tool Launch URL sending a push, where that URL is a link to do a deep link to our application, but we realized that on iOS devices are opening a kind of modal in app, witch doesn't work with deep link.

So, I found this documentation: https://documentation.onesignal.com/docs/links#launch-url that seems we could change it if we want to open the browser or not, but that is for react native and not for expo applications, we can't modify the Info.plist

Is there some future update on this plugin to give us the possibility of change this?

Thanks a lot

[Bug]: Expo managed Workflow on iOS

What happened?

Hi,

I'm getting an error when I try to run this plugin with a managed workflow.

Steps to reproduce?

I've create a new repository with the code to reproduce.

https://github.com/mathias-casion/poc-expo-one-signal

What did you expect to happen?

I expected to run smoothly without showing any warnings or errors

OneSignal Expo SDK version

"onesignal-expo-plugin": "^1.0.2",
"react-native-onesignal": "^4.4.0",

Platform

iOS

Relevant log output

Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:203:6 in guardedLoadModule
at http://192.168.15.46:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false:121634:3 in global code

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Bug]: EAS Capability Sync removing iOS app groups entitlement from bundle identifier

What happened?

Hello,

Something appears to be up with EAS removing the correct entitlements/capabilities from my bundle identifier. This results in an invalid provisioning profile being generated which causes our build to fail.

I am able to work around the issue by manually updating the OneSignal bundle identifier inside the Apple Developer Portal, then prefixing my build command with EXPO_NO_CAPABILITY_SYNC=1 (see https://docs.expo.dev/build-reference/ios-capabilities/#debugging for details).

Steps to reproduce?

1. Create a bare workflow app
2. Add onesignal-expo-plugin
3. Run `eas build --local --platform ios`

What did you expect to happen?

I expected the OneSignal plugin to generate whatever is needed so that Expo adds entitlements to the identifiers instead of removing them.

OneSignal Expo SDK version

Latest commits from Git

Platform

iOS

Relevant log output

Output of `eas build --profile production --local --platform ios`

...

Setting up credentials for target OneSignalNotificationServiceExtension (com.lckroom.apps.lckroom-client.OneSignalNotificationServiceExtension)

✔ Bundle identifier registered com.lckroom.apps.lckroom-client.OneSignalNotificationServiceExtension
✔ Synced capabilities: Disabled: App Groups <----- this line
✔ Synced capability identifiers: No updates
✔ Fetched Apple distribution certificates
✔ Fetched Apple provisioning profiles


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

EAS build failing with: CocoaPods could not find compatible versions for pod "OneSignalXCFramework

What happened?

EAS build is suddenly failing with full error:

Installing pods
Using Expo modules
...
[!] CocoaPods could not find compatible versions for pod "OneSignalXCFramework":
  In snapshot (Podfile.lock):
    OneSignalXCFramework (< 4.0, = 3.10.3, >= 3.0)
  In Podfile:
    OneSignalXCFramework (< 4.0, >= 3.0)
    react-native-onesignal (from `../node_modules/react-native-onesignal`) was resolved to 4.3.11, which depends on
      OneSignalXCFramework (= 3.11.2)

I have not made any change to my OneSignal since the time I set it up (a couple of months ago). But this morning, it started failing.

Steps to reproduce?

I have not any change to the Onesignal plugin setup since I installed it for the first time a coupe of months ago by following official guide (https://github.com/OneSignal/onesignal-expo-plugin).

What did you expect to happen?

I expect EAS to build successfully

OneSignal Expo SDK version

"onesignal-expo-plugin": "^1.0.2",

Platform

iOS

Relevant log output

Installing pods
Using Expo modules
Auto-linking React Native modules for target `develop`: RNFlashList, RNGestureHandler, RNReanimated, RNSVG, RNScreens, RNSentry, react-native-get-random-values, react-native-onesignal, react-native-safe-area-context, and react-native-webview
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`
[!] CocoaPods could not find compatible versions for pod "OneSignalXCFramework":
  In snapshot (Podfile.lock):
    OneSignalXCFramework (< 4.0, = 3.10.3, >= 3.0)
  In Podfile:
    OneSignalXCFramework (< 4.0, >= 3.0)
    react-native-onesignal (from `../node_modules/react-native-onesignal`) was resolved to 4.3.11, which depends on
      OneSignalXCFramework (= 3.11.2)
You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `OneSignalXCFramework` inside your development pod `react-native-onesignal`.
   You should run `pod update OneSignalXCFramework` to apply changes you've made.
Error: Compatible versions of some pods could not be resolved.
You are seeing this error because either:
  - Versions in the Podfile.lock cached by EAS do not match required values for some of the libraries, it can be triggered when upgrading Expo SDK or any other library with native code. To fix that add the "cache.key" field (it can be set to any value) in the build profile in eas.json to invalidate the cache.
  - Some of your npm packages have native code that depend on different versions of the same pod. Please see logs for more info.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Two notifications on Android Devices - expo

Hey! We was trying this tool in a development environment and the SDK works fine. But when we went to production and sent our first notification push, we saw that notifications appears twice on android devices, the first one is just an icon of our app with the name, and the second one is the original push sent from OneSignal dashboard. I'd like to know if you tried it out, and if you know some solution for this. Right now we're using expo-notification and OneSignal SDK in the same time... Maybe isn't compatible?

This was tested on Android devices, using expo with the expo-notification module and OneSignal SDK/Plugin.

iOS entitlement/Android build script being added on every prebuild

expo prebuild

Outcome
group.xyz.xxx.xxx.onesignal is added to the iOS entitlements array even if it already exists.
buildscript is added to build.gradle even if it already exists.

Harmless, I believe, but just something I need to clean up when I bump my app versions.

CFBundleShortVersionString and CFBundleVersion issue

WARNING ITMS-90473: "CFBundleShortVersionString Mismatch. The CFBundleShortVersionString value '1.0' of extension '.app/PlugIns/OneSignalNotificationServiceExtension.appex' does not match the CFBundleShortVersionString value '' of its containing iOS application '*.app'."

WARNING ITMS-90473: "CFBundleVersion Mismatch. The CFBundleVersion value '1' of extension '.app/PlugIns/OneSignalNotificationServiceExtension.appex' does not match the CFBundleVersion value '' of its containing iOS application '*.app'."

I got the warning above from the app store submission.

I control the version / the build number of my app with app.json, but when I run expo prebuild, I can see the version and the build number of OneSignalNotificationServiceExtension are not match to my app but just 1.0.0.

I found a similar issue like here, but the solution doesn't work for our case because we use Expo managed workflow.

Can we update the plugin to match the version and the build number of OneSignalNotificationServiceExtension to the main app's ones?

Refer: https://github.com/OneSignal/onesignal-expo-plugin/blob/main/support/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist#L19-L22

Thanks!

No users/subscribers appearing in OneSignal

Hi there, love that you've created this plugin!
I can't seem to get my device subscribed to OneSignal.
I'm using expo managed workflow with the beta6 release of this plugin, I have react-native-onesignal installed, and I have followed the README and example app code for setup, but no subscribers are appearing.

The initialisation code is definitely being reached (logcat + a peppering of console.log calls show this).
I can't see OneSignal throwing any errors in logcat. It's simply failing silently. I am trying to build an APK with expo build to eliminate the possibility of Expo Go being the issue, and I've also tried eas build, but neither work.

I am using expo ^42.0.0

Let me know if I should provide more details.

Keychain on iOS

iOS keychain doesn't work after adding one signal. By any chance, does anyone know how to fix it?

Before After
IMG_0622 IMG_0621

Native module cannot be null

Hi, after adding

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

...running the app with expo start keeps giving me "OneSignal is not defined"

Is there something else to import?

Thanks

[Bug]: expo prebuild fails in a monorepo.

What happened?

My codebase is in a monorepo with the following structure:

root
-> mobile
    -> package.json
    -> app.config.js

Running expo prebuild fails with the error:

onesignal-expo-plugin: Couldn't read file:node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h

it is fixed if I dont hoist onesignal-expo-plugin, i.e. by adding the following to the root's package.json:

 "nohoist": [
    "**/onesignal-expo-plugin"
]

Steps to reproduce?

As described above.

What did you expect to happen?

Running expo prebuild in a monorepo should work.

OneSignal Expo SDK version

1.0.1

Platform

iOS

Relevant log output

Created native projects | gitignore already synced
⚠️  Skipped Metro config updates:
› Existing Metro config found; not overwriting.
› You will need to extend the default @expo/metro-config in your Metro config.
  Learn more: https://docs.expo.dev/guides/customizing-metro

✔ Updated package.json and added index.js entry point for iOS and Android
🧶 Using Yarn to install packages. Pass --npm to use npm instead.
✔ Installed JavaScript dependencies 3253ms
» android: userInterfaceStyle: Install expo-system-ui in your project to enable this feature.
Using node to generate images. This is much slower than using native packages.
› Optionally you can stop the process and try again after successfully running `npm install -g sharp-cli`.

Using node to generate images. This is much slower than using native packages.
› Optionally you can stop the process and try again after successfully running `npm install -g sharp-cli`.

        onesignal-expo-plugin: Couldn't read file:node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h
(node:38807) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:38807) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:38807) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✔ Config synced
⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: Unable to find a target named `OneSignalNotificationServiceExtension` in project `TradeziDev.xcodeproj`, did find `TradeziDev`.

Code of Conduct

  • I agree to follow this project's Code of Conduct

FS Could not be found

I tried to run:

npm install react-native-onesignal

before following the setup as suggested to resolve the issue described here

But now I'm getting:

iOS Bundling failed 3417ms
Unable to resolve module fs from /Users/giulioserra/Documents/App/CTS/node_modules/onesignal-expo-plugin/build/onesignal/withOneSignalIos.js: fs could not be found within the project or in these directories:
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
  29 | exports.xcodeProjectAddNse = exports.withOneSignalIos = void 0;
  30 | const config_plugins_1 = require("@expo/config-plugins");
> 31 | const fs = __importStar(require("fs"));

My package.json:

{

...
  "dependencies": {
    "@fortawesome/free-solid-svg-icons": "^5.15.4",
    "@fortawesome/react-native-fontawesome": "^0.2.7",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/native-stack": "^6.2.5",
    "accordion-collapse-react-native": "^1.1.0",
    "axios": "^0.25.0",
    "expo": "~44.0.0",
    "expo-av": "^10.2.0",
    "expo-barcode-scanner": "~11.2.0",
    "expo-location": "^14.0.1",
    "expo-status-bar": "~1.2.0",
    "expo-web-browser": "^10.1.0",
    "firebase": "^9.6.4",
    "geolib": "^3.3.3",
    "jsbarcode": "^3.11.5",
    "onesignal-expo-plugin": "^1.0.0-beta10",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-gesture-handler": "^2.2.0",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-onesignal": "^4.3.6",
    "react-native-svg": "12.1.1",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-web": "0.17.1",
    "react-native-webview": "^11.17.1"
  },
}

Onesignal Version and Build Number Being not Set Properly

Hi,

First of all, thanks for addressing #48 so fast!

Just one thing is when I run expo prebuild --platform ios, only one of {{BUNDLE_VERSION}} and {{BUNDLE_SHORT_VERSION}} seems to be set properly.

I could be wrong, but I think it is because updateNSEBundleShortVersion and updateNSEBundleVer write the same file at the same time. Could you look into this?

Thank you!

  NseUpdaterManager.updateNSEBundleVersion(bundleVersion ?? DEFAULT_BUNDLE_VERSION);
   NseUpdaterManager.updateNSEBundleShortVersion(bundleShortVersion ?? DEFAULT_BUNDLE_SHORT_VERSION);

Invariant Violation: Native module cannot be null.

Hello everybody, I'm trying to add one-signal to my expo managed project, In the App.js file I have:

export default function App() {
  useEffect(() => {
   ///Other things
    OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);
  }, []);

When trying to run the application on iOS I get:

Invariant Violation: Native module cannot be null.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:204:6 in guardedLoadModule
at http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:263808:3 in global code

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

Here is my package.json:

{
  "name": "ctsapp",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@fortawesome/free-solid-svg-icons": "^5.15.4",
    "@fortawesome/react-native-fontawesome": "^0.2.7",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/native-stack": "^6.2.5",
    "accordion-collapse-react-native": "^1.1.0",
    "axios": "^0.25.0",
    "expo": "~44.0.0",
    "expo-av": "~10.2.0",
    "expo-barcode-scanner": "~11.2.0",
    "expo-constants": "~13.0.1",
    "expo-location": "~14.0.1",
    "expo-status-bar": "~1.2.0",
    "expo-web-browser": "~10.1.0",
    "firebase": "^9.6.4",
    "geolib": "^3.3.3",
    "jsbarcode": "^3.11.5",
    "onesignal-expo-plugin": "^1.0.0-beta10",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-svg": "12.1.1",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-web": "0.17.1",
    "react-native-webview": "11.15.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

Any suggestions? Thanks

eas build (IOS): Error: No profile for 'com.myapp. OneSignalNotificationServiceExtension' were found

Following the installation and configuration process, I was able to setup OneSignal successfully for android (remote eas build and deployment to physical device, custom dev-client). But the remote build fails in the case of IOS with the error:

error: No profiles for 'com.myapp.OneSignalNotificationServiceExtension' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.myapp.OneSignalNotificationServiceExtension.

Here is a dump of my local envinronment (npx expo-env-info):

  expo-env-info 1.0.2 environment info:
    System:
      OS: macOS 12.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
      Yarn: 1.22.15 - ~/.yarn/bin/yarn
      npm: 8.3.0 - ~/.nvm/versions/node/v14.18.1/bin/npm
      Watchman: 2021.11.15.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.11.2 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    IDEs:
      Android Studio: 2020.3 AI-203.7717.56.2031.7935034
      Xcode: 13.2/13C5081f - /usr/bin/xcodebuild
    npmPackages:
      expo: ~44.0.0 => 44.0.5 
      react: 17.0.1 => 17.0.1 
      react-dom: 17.0.1 => 17.0.1 
      react-native: 0.64.3 => 0.64.3 
      react-native-web: 0.17.1 => 0.17.1 
    npmGlobalPackages:
      eas-cli: 0.41.1
      expo-cli: 5.3.0
    Expo Workflow: managed

EAS Build - Execution failed for task ':app:checkDebugAarMetadata'.

Description:

After adding onesignal-expo-plugin in app.config.json when I run eas build command. The build failed with the following error:

It is related to this issue, OneSignal/react-native-onesignal#1318
I have tried to create a custom plugin with the solution found there. But It doesn't work

Expo-SDK: 44.0.6
onesignal-expo-plugin: 1.0.0-beta10
react-native-onesignal: 4.3.6

Build Error:

// Build failed with an exception.

[stderr] *    What went wrong:
[stderr]      Execution failed for task ':app:checkDebugAarMetadata'.
[stderr] >   A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
[stderr] >  The minCompileSdk (31) specified in a
[stderr]      dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
[stderr]      is greater than this module's compileSdkVersion (android-30).
[stderr]      Dependency: androidx.work:work-runtime:2.7.1.
[stderr]      AAR metadata file: /home/expo/.gradle/caches/transforms-3/c9b633a7cdef94f5ad87c49ed563a3db/transformed/work-runtime-2.7.1/META-INF/com/android/build/gradle/aar-metadata.properties.

Custom Plugin Code:

// plugins/one-signal-csdk-downgrade-plugin.js

const expoConfigPlugins = require('@expo/config-plugins');

const newResolutionStrategyGradle = `
configurations.all {
    resolutionStrategy {
        force 'androidx.work:work-runtime:2.6.0'
    }
}`;


/**
 * Update **app/build.gradle** by adding work-runtime
 */
module.exports = function withWorkingWorkRuntimeVersion (config, _props) {
    return expoConfigPlugins.withAppBuildGradle(config, (newConfig) => {
      newConfig.modResults.contents = `${newResolutionStrategyGradle.trimStart()}\n\n${
        newConfig.modResults.contents
      }`;
  
      return newConfig;
    });
};

app.config.json:

"plugins": [
    "plugins/one-signal-csdk-downgrade-plugin",
    [
      "onesignal-expo-plugin",
      {
        "mode": "development"
      }
    ],
  ]

[Bug]: 'expo run:ios' fails after installing onesignal-expo-plugin

What happened?

I have the latest version of expo-cli.

Using:

"onesignal-expo-plugin": "^1.0.0",
"react-native-onesignal": "^4.3.7",

Steps to reproduce?

Follow the documentation found here: https://github.com/OneSignal/onesignal-expo-plugin

What did you expect to happen?

Everything runs without any issues until I get to expo run:ios

Then I get the below error:

The following build commands failed:
        CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'ExpoModulesCore' from project 'Pods')

OneSignal Expo SDK version

1.0.0

Platform

No response

Relevant log output

2022-04-08 15:38:39.692 xcodebuild[73298:4604834] warning:  The file reference for "OneSignalNotificationServiceExtension" is a member of multiple groups ("Pods" and ""); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
** BUILD FAILED **


The following build commands failed:
        CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'ExpoModulesCore' from project 'Pods')
        PhaseScriptExecution [CP-User]\ Generate\ Specs Library/Developer/Xcode/DerivedData/App-fspnqmnktjandhhdnfysxlewamvd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-BD7ACB0873CA1DBF901FF4818FC9757C.sh (in target 'FBReactNativeSpec' from project 'Pods')
(2 failures)
Build logs written to app/.expo/xcodebuild.log

Code of Conduct

  • I agree to follow this project's Code of Conduct

Beta: iOS not yet fully functional

This issue is to highlight that in the beta, the iOS platform is not yet fully functional.

This includes a lack of support for the Notification Service Extension and App Groups, among other issues.

We are working to add support for these very soon. Thanks for your patience.

Error to compile the plugin - File not found

Steps to reproduce the first issue:

1.expo install onesignal-expo-plugin
2. Add configuration at app.json ( plugin )
3. expo start

This problem came from the package.json of the plugin:
"main": "build/withOneSignal.js"

Seems like this is trying to access to file where it isn't there, it's inside of /build/onesignal/withOneSignal.js
Even though, that main should aim to ./app.plugin.json

I fixed this by hand, but after this solution, another error come:

Cannot destructure property 'mode' of 'undefined' as it is undefined.
TypeError: Cannot destructure property 'mode' of 'undefined' as it is undefined.
    at withAppEnvironment (/Users/cristianhourcade/Desktop/Proyects/buenbit-app/mobile/node_modules/onesignal-expo-plugin/build/onesignal/withOneSignalIos.js:14:39)
    at withOneSignalIos (/Users/cristianhourcade/Desktop/Proyects/buenbit-app/mobile/node_modules/onesignal-expo-plugin/build/onesignal/withOneSignalIos.js:55:5)
    at withOneSignal (/Users/cristianhourcade/Desktop/Proyects/buenbit-app/mobile/node_modules/onesignal-expo-plugin/build/onesignal/withOneSignal.js:10:54)
    at withStaticPlugin (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/config-plugins/src/plugins/withStaticPlugin.ts:117:12)
    at /usr/local/lib/node_modules/expo-cli/node_modules/@expo/config-plugins/src/plugins/withPlugins.ts:20:43
    at Array.reduce (<anonymous>)
    at withPlugins (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/config-plugins/src/plugins/withPlugins.ts:20:18)
    at withConfigPlugins (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/config/src/plugins/withConfigPlugins.ts:19:14)
    at fillAndReturnConfig (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/config/src/Config.ts:126:35)
    at getConfig (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/config/src/Config.ts:190:10)

To fix this, I'had to add in the plugin prop inside app.json, the prop "mode". This isn't in the documentation, with add this should be fine.
Example of my plugins that works fine:

"plugins": [
      ... 
      [
        "react-native-onesignal-plugin",
        {
          "mode": "development"
        }
      ]
     ...
    ],

This was a test in React Native Expo application.

[Bug]: Intermittent "ITMS-90078: Missing Push Notification Entitlement" on Testflight

What happened?

Hi,

The majority of my builds receive the "ITMS-90078: Missing Push Notification Entitlement" error when I submit them to Testflight. Occasionally, I can get a successful build, but I can't isolate exactly what causes that to happen.

Happy to provide logs and help debug, as this has significantly slowed down our deploy process.

Thanks in advance for your help everyone!

Steps to reproduce?

1. Install expo 45.0.0
2. Run eas build
3. Run eas submit -p ios once done building

What did you expect to happen?

Expected to have a working build with all capabilities enabled, but both Apple Sign In and Push Notifications don't work. I get the "Missing Push Capability" error when sending user data to OneSignal.

OneSignal Expo SDK version

1.0.2

Platform

iOS

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Missing Push Capability on iOS - EAS Built App

Problem Statement - Our iOS integration with OneSignal is not functional due to a Missing Push Capability error in OneSignal.

image

Environment Details

  • Expo SDK 44
  • EAS managed workflow build

Steps Taken to Resolve / Root Cause Analysis

  1. iOS setup has been completed as per the discussion in https://github.com/OneSignal/onesignal-expo-plugin/discussions -
  2. Ensured the provisioning profiles created as part of the above were regenerated / up-to-date (even tried recreating them, inc. distribution cert).
  3. Experimented with all plugin props (mode, devTeam, iPhoneDeploymentTarget).
  4. Experimented with EXPO_NO_CAPABILITY_SYNC as per https://docs.expo.dev/build-reference/ios-capabilities/
  5. Experimented with adding the aps-environment entitlement as per https://docs.expo.dev/versions/v44.0.0/config/app/#entitlements

None of these yielded a positive result.

In combination with the above, I also experimented with stripping the app right back to a boilerplate Expo app and gradually building the functionality of our app back up from scratch. Certain configurations of the source code would work through this process, but results were inconsistent:

  • The totally stripped back app succeeded reliably.
  • Our full app failed reliably.
  • Intermediate states were inconsistent - successive builds (of the exact same source configuration) would yield different results; some would fail, some would succeed.

Looking at the Xcode logs for source configurations that had inconsistent results, the logs are quite different. A key difference I observed in the logs is that a working run would include in the aps-environment in the entitlements (see below). This feels significant to the presence or absence of the "Missing Push Capability" error, but I'm unable to determine what causes it to be present or not, and why different eas build runs (with identical input and parameters) would have different results.

{
    "application-identifier" = "XYZ";
    "aps-environment" = production;
    "com.apple.developer.team-identifier" = ABC;
    "com.apple.security.application-groups" = (
        "DEF"
    );

Plugin is an unexpected type: object

Trying to follow the directions and receive the following error when modifying the plugin array:

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

Error:

Plugin is an unexpected type: object

If I remove the object, then I receive the following error:

Missing required "mode" key in your app.json or app.config.js file for "onesignal-expo-plugin".

Package dependencies:

"dependencies": {
    "expo": "~44.0.0",
    "expo-status-bar": "~1.2.0",
    "onesignal-expo-plugin": "^1.0.0-beta10",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-web": "0.17.1",
    "expo-splash-screen": "~0.14.1"
  },

Can i skip the creation of iOS App Group ID PACKAGENAME.onesignal?

Hi,
is there a way to skip the creation of the .onesignal AppGroup ID PACKAGENAME.onesignal?
The group is already present but is linked to the previus developer account who published the app and then transferred the app to my client’s Apple Developer Account.
Problem 1: the group ids are not transferred so the creation of the AppGroupId fails and the build cannot be created.
Problem 2: the developer account the app group id is linked to is not active anymore

Any idea?

P.s. I already wrote a message to Apple asking if they could remove the app group id, waiting for a response

Update Plugin to Catch Up with react-native-onesignal bug fixes

Hi,
I have successfully installed and tested the plugin on android but came across the issue described on react-native-onesignal repo in 1288.

The proposed solutions there were:

1 - Revert back to [email protected]
This is not possible using the plugin because react-native-onesignal dependency is locked at ^4.3.1 hence EAS build always tries to pick at least that version.

2 - Upgrade to [email protected]
Currently Expo uses compileSdkVersion = 30 and trying to use react-native-onesignal with a version greater than 4.3.1 throws error:

> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction [stderr] > The minCompileSdk (31) specified in a [stderr] dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) [stderr] is greater than this module's compileSdkVersion (android-30). [stderr] Dependency: androidx.work:work-runtime:2.7.1. [stderr] AAR metadata file: /root/.gradle/caches/transforms-3/f2e8a192284df9764ec691ee3f57b75f/transformed/work-runtime-2.7.1/META-INF/com/android/build/gradle/aar-metadata.properties.

Please advise whats the best way to overcome this issue.

Thanks

[Bug]: Bundle identifier of extension doesn't update when prebuild again

What happened?

Hello!

First, thanks for the package. It makes development so much easier!

My app.config.js have a variable iOS bundle identifier: according to the current environment, it will generate either a production or a staging app.

On the first generation of the ios folder, everything works as expected:

  • My app bundle identifier: com.myapp.app1
  • OneSignal bundle identifier: com.myapp.app1.OneSignalNotificationServiceExtension

Then, I update my native files by running again expo prebuild using a different environment (without --clean).

  • My app new bundle identifier: com.myapp.app2
  • OneSignal bundle identifier: com.myapp.app1.OneSignalNotificationServiceExtension

While doing the second generation, onesignal-expo-plugin output the following:

onesignal-expo-plugin: OneSignal dependencies already added to build.gradle. Skipping...
onesignal-expo-plugin: OneSignalNotificationServiceExtension target already added to Podfile. Skipping..
onesignal-expo-plugin: OneSignalNotificationServiceExtension already exists in project. Skipping...

As you can see, the OneSignal extension isn't updated to the new bundle identifier.

I may be using expo prebuild wrong? I do the following:

  • expo prebuild -> fallback to DEV environment
  • env APP_ENV=STAGING expo prebuild -> staging configuration (with staging bundle identifier)
  • env APP_ENV=PRODUCTION expo prebuild -> production configuration

The solution to this is simply to remove ios and android folders before each expo prebuild. Or using expo prebuild --clean.

Steps to reproduce?

1. Create an empty expo project
2. add OneSignal Expo with a basic configuration and the expo plugin.
3. Set a first bundle identifier in app.json
4. run `expo prebuild`
5. Set a new bundle indentifier
6. run `expo prebuild` again
7. Note that the app bundle identifier is correct but the OneSignalExtension bundle identifier is wrong

What did you expect to happen?

The bundle identifier should update on expo prebuild

OneSignal Expo SDK version

"react-native-onesignal": "4.3.7"
"onesignal-expo-plugin": "1.0.1"

Platform

iOS

Relevant log output

env APP_ENV=STAGING yarn expo prebuild
yarn run v1.22.18
$ expo prebuild
✔ Created native projects | /android, /ios **already created** | gitignore already synced
✔ Updated package.json and added index.js entry point for iOS and Android
🧶 Using Yarn to install packages. Pass --npm to use npm instead.
✔ Installed JavaScript dependencies 1606ms
        onesignal-expo-plugin: OneSignal dependencies already added to build.gradle. Skipping...
        onesignal-expo-plugin: OneSignalNotificationServiceExtension target already added to Podfile. Skipping..
        onesignal-expo-plugin: **OneSignalNotificationServiceExtension already exists in project. Skipping...**
✔ Config synced
✨  Done in 5.24s.

(added ** around interesting parts)



### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

iOS not showing notifications (iPhone 12 - iOS 15.11)

Hi, I've just tested the integration with an Android (emulator with expo start --dev-client and physical device) and everything's fine; I log in in the OneSignal dashboard and under Audiences I see the user with the external_id I set iin my react native app; I set it as a test user and I send a push notification targeting that user. All perfect and the notification is shown in the emulator right away.

Now to iOS (iPhone 12 - iOS 15.11)
I build the app with EAS, send it to testFlight and install in my iPhone 12; the app launches fine, asks me for the consent for the notifications, I agree and as before I log in in the OneSignal dashboard and under Audiences I see the user with the external_id.
I send the test push notification but nothing happens.
I checked:

  • provision profile created during the build process and it includes correctly "push notifications"
  • phone is high in battery power
  • no "no disturb mode"
  • wifi or 5G ok

Is there somenthing I'm not aware of to make it work?

Versions of the packages:
expo 43.0.0
"onesignal-expo-plugin": "^1.0.0-beta7",

SOLVED:

  1. I re-created the push certificate using this awesome wizard: https://onesignal.com/provisionator
  2. I then uploaded this certificate in OneSignal settings > configure > apple-ios

Great! Hope this helps someone with the same issue

ld: library not found for -lPods-OneSignalNotificationServiceExtension

Not super familiar with Xcode, so struggling a bit with the setup of the plugin. I'm almost there, but the app fails on the build stage in Fastlane. Any suggestions on how to tackle this?

› Linking Nuptuality/OneSignalNotificationServiceExtension » OneSignalNotificationServiceExtension

❌ ld: library not found for -lPods-OneSignalNotificationServiceExtension

❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)

▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸ Ld /Users/expo/Library/Developer/Xcode/DerivedData/Nuptuality-czypadaqxhhqkcaohroovtjuwjiy/Build/Intermediates.noindex/ArchiveIntermediates/Nuptuality/IntermediateBuildFilesPath/Nuptuality.build/Release-iphoneos/OneSignalNotificationServiceExtension.build/Objects-normal/armv7/Binary/OneSignalNotificationServiceExtension normal armv7 (in target 'OneSignalNotificationServiceExtension' from project 'Nuptuality')
▸ (1 failure)
** ARCHIVE FAILED **
The following build commands failed:
Ld /Users/expo/Library/Developer/Xcode/DerivedData/Nuptuality-czypadaqxhhqkcaohroovtjuwjiy/Build/Intermediates.noindex/ArchiveIntermediates/Nuptuality/IntermediateBuildFilesPath/Nuptuality.build/Release-iphoneos/OneSignalNotificationServiceExtension.build/Objects-normal/armv7/Binary/OneSignalNotificationServiceExtension normal armv7 (in target 'OneSignalNotificationServiceExtension' from project 'Nuptuality')
(1 failure)
Exit status: 65

[Bug]: The target `OneSignalNotificationServiceExtension` is declared multiple times

What happened?

I have the latest version of expo-cli.

Using:

"onesignal-expo-plugin": "^1.0.0",
"react-native-onesignal": "^4.3.11",
"expo": "^44.0.0",

Steps to reproduce?

1. Install the app with `expo install onesignal-expo-plugin && yarn add react-native-onesignal`
2. Added the onesignal plugin in the array of plugins in `app.json`.

{
  "plugins": [
    [
      "onesignal-expo-plugin",
      {
        "mode": "development",
        "devTeam": "XXXXXX",
      }
    ]
  ],
....
  "extra": {
    "oneSignalAppId": "<YOUR APP ID HERE>"
  }
}

3. Run expo prebuild --clean

What did you expect to happen?

Everything runs without any issues until I get to expo run:ios

Then I get this error:

⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: The target `OneSignalNotificationServiceExtension` is declared multiple times.

When I opened the Podfile located at ios/Podfile I found this at the end of the file:

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end
target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end

OneSignal Expo SDK version

1.0.2

Platform

iOS

Relevant log output

✔ Updated package.json and added index.js entry point for iOS and Android
🧶 Using Yarn to install packages. Pass --npm to use npm instead.
✔ Installed JavaScript dependencies 1430ms
adding android:forceDarkAllowed = false
[config-plugins/detox] Setting Kotlin version to: 1.4.21. This could lead to Android build issues.
✔ Config synced
⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: The target `OneSignalNotificationServiceExtension` is declared multiple times.

Code of Conduct

  • I agree to follow this project's Code of Conduct

ERROR Could not load RNOneSignal native module. Make sure native dependencies are properly linked.

I am attempting to set up OneSignal on my React-Native application. I have followed the steps here precisely.

My question is: If I am using an Android Emulator (and I understand that the push notifications will not work), is this the cause of the error? Or is this error unrelated to using the emulator with push notifications?

And if it is unrelated, what can I do to fix this issue?

OneSignal Expo SDK version

1.1.0

Platform

Android

Relevant log output

Could not load RNOneSignal native module. Make sure native dependencies are properly linked.
at node_modules/react-native-onesignal/dist/helpers.js:15:8 in isNativeModuleLoaded
at node_modules/react-native-onesignal/dist/index.js:61:13 in OneSignal.setAppId
at App.js:7:2 in App
at node_modules/react-native/Libraries/ReactNative/renderApplication.js:80:4 in renderApplication
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:119:25 in runnables.appKey.run
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:213:4 in runApplication

Code of Conduct

  • I agree to follow this project's Code of Conduct

No push notification on iOS

The app push notification doesn't work on iOS whereas it works on Android.

I'm not even sure what to share here to help you debug this. Please let me know what information you'd like to have.

The notification stops working when one signal is added, and it works just fine when one signal is removed.

Android notifications icons in Expo setup

For the life of me I'm unable to figure out how to configure notification icons in an Expo setup. We previously used expo-notifications and notification icons showed up ok.

By default, Expo seems to generate notification_icon.png in all of the required formats when using expo prebuild. However, OneSignal seems to expect ic_stat_onesignal_default.png in all of the required formats.

Has anyone been able to get this to work?

[question]: Is there a way to disable OneSignal when using Expo Go

How can we help?

I am looking at a way that will enable me to continue to use Expo Go to develop the majority of my app but use the custom dev client for when I need to make changes to the push notification side of things.

Is there a way to disable the One Signal plugin to avoid the Native module cannot be null When using Expo Go?

Many Thanks
James

OneSignal Expo SDK version

1.0.1

Platform

iOS

Relevant log output

Native module cannot be null.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Could not load RNOneSignal native module. Make sure native dependencies are properly linked.

I am receiving this error.

image

The dependencies installed on my project:
image

OneSignal Expo SDK version

1.0.2

Platform

Android

Relevant log output

Could not load RNOneSignal native module. Make sure native dependencies are properly linked.
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native-onesignal\dist\helpers.js:15:8 in isNativeModuleLoaded
at node_modules\react-native-onesignal\dist\index.js:61:13 in OneSignal.setAppId
at App.tsx:15:0 in <global>
at node_modules\metro-runtime\src\polyfills\require.js:339:11 in loadModuleImplementation
at index.js:3:0 in <global>
at node_modules\metro-runtime\src\polyfills\require.js:339:11 in loadModuleImplementation
at node_modules\metro-runtime\src\polyfills\require.js:200:44 in guardedLoadModule
at http://192.168.2.130:19000/index.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:230494:3 in global code

Code of Conduct

  • I agree to follow this project's Code of Conduct

EAS Build Failing during prebuild: no such file NotificationService.h

I am attempting to build a custom dev client for Expo with EAS Build and my iOS build is failing during the "Prebuild" stage with the following error:

[stderr] onesignal-expo-plugin: Couldn't read file:node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h
- Config syncing
[stderr] Error: ENOENT: no such file or directory, open 'node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h'

onesignal-expo-plugin: 1.0.0-beta11
react-native-onesignal: 4.3.7

[stderr] [11:09:40] [ios.entitlements]: withIosEntitlementsBaseMod: Entitlements plist is empty

Hi.
On EAS from Expo when I run eas build --profile staging --platform ios
On the Prebuild step I have this error :

Prebuilding managed project
- Clearing ios
✔ Cleared ios code
- Creating native project directories (./ios and ./android) and updating .gitignore
✔ Created native project | gitignore already synced
- Adding Metro bundler config
✔ Added Metro config
- Updating your package.json scripts, dependencies, and main file
✔ Updated package.json and added index.js entry point for iOS and Android
- Config syncing
✖ Config sync failed
[stderr] [11:09:40] [ios.entitlements]: withIosEntitlementsBaseMod: Entitlements plist is empty
bash exited with non-zero code: 1

My plugins array from app.config.js is

"plugins": [
    "sentry-expo",
    "@react-native-mapbox-gl/maps",
    "@config-plugins/android-jsc-intl",
    [
      "@config-plugins/react-native-branch",
      {
        "apiKey": "BRANCH_API_KEY",
        "iosAppDomain": "test.app.link"
      }
    ],
    [
      "onesignal-expo-plugin",
      {
        "mode": "production"
      }
    ]
  ],

If i remove the onesignal-expo-plugin part the build is successful

Their is a provisioning profile configured by eas on my apple account like this :
image

And the app id configuration is associated to a production certificate.

I don't what I'm doing wrong on the config side.

Thanks.

warning: The file reference for “OneSignalNotificationServiceExtension” is a member of multiple groups (“Pods” and “”);

Environment Details

Expo SDK 44
EAS managed workflow build

Issue Detail

The following warning is emitted from Xcode (as part of the EAS build):

warning: The file reference for “OneSignalNotificationServiceExtension” is a member of multiple groups (“Pods” and “”); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.

Note that this issue was observed as part of the diagnosis of #67, so it might be that the two issues are interdependent.

[Bug]: Android 13 runtime notification permission not requested

What happened?

  • A user upgraded his Android OS to Android 13
  • They installed my app from the play store
  • The device is seen in the users section of the expo portal, but with "permission not granted" status
  • The user had to manually go into android settings for the app, and manually add permission for notifications in order to receive notifications

Steps to reproduce?

* Setup a basic expo app with onesignal plugin
Make sure OneSignal.setAppId and OneSignal.promptForPushNotificationsWithUserResponse are called
* Launch it on a phone with Android 13 installed
* The app will never ask for notification permission even when promptForPushNotificationsWithUserResponse is called

What did you expect to happen?

I expected the app to request the user's permission for notifications with a popup - as per the onesignal documentation here https://documentation.onesignal.com/docs/android-13-push-notification-developer-update-guide since I am using the latest expo sdk

OneSignal Expo SDK version

"onesignal-expo-plugin": "^1.0.2",
"react-native-onesignal": "^4.4.0",
"expo": "^46.0.0",

Platform

Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

error in plugin mode

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

Output Error => Cannot destructure property 'mode' of 'undefined' as it is undefined.

error: No profiles for 'x.x.OneSignalNotificationServiceExtension' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'x.x.OneSignalNotificationServiceExtension'

Hi,

I'm having an issue with the building process using react-native expo and EAS for the IOS build

I'm using this Expo project template:
image

I follow this documentation to Generate an iOS Push Certificate:
https://documentation.onesignal.com/docs/generate-an-ios-push-certificate

Run fastlane build process error:
image
image

I tried using the EAS automatic creation of the provisioning profile and manually creating the provisioning profile with the name com.gobooc.app.OneSignalNotificationServiceExtension but it doesn't work.

iOS Entitlements replaced during build

iOS entitlements that were added manually through the Apple Developer portal appear to be erased during expo's eas build and replaced with one that's not useful.

I have Beta11 installed.

Here are the enabled capabilities for my app, taken from the Provisioning Profile that I manually generated in the Apple Dev portal:

image

Here are the entitlements in my XCode logs when running a build with and without OneSignal configured...

Without OneSignal:

{
    "application-identifier" = "TEAM_ID.com.PROJECT.www";
    "aps-environment" = production;
    "beta-reports-active" = 1;
    "com.apple.developer.applesignin" =     (
        Default
    );
    "com.apple.developer.team-identifier" = TEAM_ID;
    "get-task-allow" = 0;
}

With OneSignal:

{
    "application-identifier" = "TEAM_ID.com.PROJECT.www";
    "beta-reports-active" = 1;
    "com.apple.developer.team-identifier" = TEAM_ID;
    "get-task-allow" = 0;
    "keychain-access-groups" =     (
        "TEAM_ID.com.PROJECT.www"
    );
}

As you can see, aps-environment and applesignin are both overwritten with keychain-access-groups when the OneSignal plugin is included in the build.

Here is my OneSignal plugin configuration in app.config.ts

     plugins: [
      'sentry-expo',
      [
        'onesignal-expo-plugin',
        {
          mode: process.env.NODE_ENV || 'production',
          devTeam: 'TEAM_ID',
        },
      ]
    ],

I've tried adding the entitlements manually to my app.config.ts like so:

ios: {
     ...,
      entitlements: {
        'aps-environment': 'production',
        'com.apple.developer.applesignin': ['Default'],
        'com.apple.security.application-groups': [
          'group.com.yc14ec100daa.www.onesignal',
        ],
        'keychain-access-groups': ['9T3ZC4D4BU.com.yc14ec100daa.www'],
      },
}

And I was able to verify that the configuration was updated by running expo config --type introspect, but the entitlements were cleared again once I built using eas build

And here is the Apple email that brought the issue to my attention:

Dear Developer,
We identified one or more issues with a recent delivery for your app, "PROJECT". Your delivery was successful, but you may wish to correct the following issues in your next delivery:

ITMS-90078: Missing Push Notification Entitlement - Your app appears to register with the Apple Push Notification service, but the app signature's entitlements do not include the 'aps-environment' entitlement. If your app uses the Apple Push Notification service, make sure your App ID is enabled for Push Notification in the Provisioning Portal, and resubmit after signing your app with a Distribution provisioning profile that includes the 'aps-environment' entitlement. Xcode does not automatically copy the aps-environment entitlement from provisioning profiles at build time. This behavior is intentional. To use this entitlement, either enable Push Notifications in the project editor's Capabilities pane, or manually add the entitlement to your entitlements file. For more information, see https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/HandlingRemoteNotifications.html#//apple_ref/doc/uid/TP40008194-CH6-SW1.

After you’ve corrected the issues, you can upload a new binary to App Store Connect.
Best regards,The App Store Team

I just finished getting my builds to complete without error by following the steps here: #40

I'm hoping I just messed up a step somewhere along the way.

Stuck on splash screen with TestFlight

I am in the process of testing One Signal with Expo so I have a fresh Expo install that runs fine when deployed to an iPhone using TestFlight. I used the expo init command to create this and complied the app using Expos servers.

However, as soon as I add this plugin and compile the app in the same way, TestFlight just hangs on the splash screen, I have even installed Sentry to see if I can get any errors from it but it's not even getting to that point.

Here are all the files from my app that I have changed when adding this plugin, any help would be much appreciated here.

app.json

  "expo": {
    "name": "notificationtest",
    "slug": "notificationtest",
    "version": "1.0.8",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.dynamiccarrots.testapp",
      "buildNumber": "1.0.8"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "url": "{REMOVED FOR HERE}",
            "organization": "appdev",
            "project": "notificationtest",
            "authToken": "{REMOVED FOR HERE}"
          }
        }
      ]
    },
    "extra": {
      "oneSignalAppId": "c21f7175-4c13-4a79-8f48-67cf2736e174" // not the real ID for here
    },
    "plugins": [
      [
        "onesignal-expo-plugin",
        {
          "mode": "development",
          "devTeam": "{REMOVED FOR HERE}"
        }
      ]
    ]
  }
}

App.js

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import OneSignal from 'react-native-onesignal';
import Constants from "expo-constants";

Sentry.init({
  dsn: 'https://[email protected]/36',
  enableInExpoDevelopment: true,
  debug: true, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
});

OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);



export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

package.json

{
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@sentry/react-native": "^3.2.13",
    "expo": "~44.0.0",
    "expo-application": "^4.0.1",
    "expo-constants": "^13.0.1",
    "expo-device": "^4.1.0",
    "expo-splash-screen": "~0.14.1",
    "expo-status-bar": "~1.2.0",
    "expo-updates": "^0.11.5",
    "onesignal-expo-plugin": "^1.0.0-beta9",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-onesignal": "^4.3.5",
    "react-native-web": "0.17.1",
    "sentry-expo": "^4.0.3"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true,
  "name": "app",
  "version": "1.0.0"
}

OneSignal Development Mode

Hey, this isn't a issue, but it's important.

We need to configure our plugin prop inside our app.json to work this plugin, and it works fine, but there is a question, why should we use the 'mode':'development'? Is there some reason of this? We could change this to 'mode':'production'?

Anyway, the latest changes worked fine, so, thanks for that.

OneSignalNotificationServiceExtension provisioning profile?

Hi, I am getting the following Fastlane error when I try to build for iOS (eas build --profile development --platform ios):

❌ error: No profiles for 'bundle id.OneSignalNotificationServiceExtension' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'bundle id.OneSignalNotificationServiceExtension'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'OneSignalNotificationServiceExtension' from project '***')

Do I have to manually create an additional identifier (.OneSignalNotificationServiceExtension) and then a provisioning profile for this?

The plugin works perfectly when I comment all the OneSignal related code out before the build, and then uncomment it all after running expo start --dev-client.

Thanks so much!

[question]: cannot run locally with `run:ios`

How can we help?

Hi,

I'm trying to follow the guide from here to add OneSignal in.
So I'm just running expo run:ios to have it running locally first (not build with eas cloud), however, it couldn't build.
Are there any other steps needed besides those listed in the document?

Thanks

OneSignal Expo SDK version

1.0.0

Platform

iOS

Relevant log output

expo run:ios
✔ Created native project | gitignore already synced
⚠️  Skipped Metro config updates:
› Existing Metro config found; not overwriting.
› You will need to extend the default @expo/metro-config in your Metro config.
  Learn more.

✔ Updated package.json and added index.js entry point for iOS and Android
🧶 Using Yarn to install packages. Pass --npm to use npm instead.
✔ Installed JavaScript dependencies 2111ms
	onesignal-expo-plugin: Couldn't read file:node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h
(node:92532) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/NotificationService.h'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:92532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:92532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✔ Config synced
⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: Unable to find a target named `OneSignalNotificationServiceExtension` in project `Buzzbike.xcodeproj`, did find `Buzzbike`.

› Planning build

› 0 error(s), and 0 warning(s)

Failed to build iOS project. "xcodebuild" exited with error code 65.
To view more error logs, try building the app with Xcode directly, by opening /Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/ios/Buzzbike.xcodeproj.

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project /Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/ios/Buzzbike.xcodeproj -configuration Debug -scheme Buzzbike -destination id=FF042B5A-7013-4044-B380-8A25312579C6

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

note: Using new build system
note: Planning
Analyze workspace

Create build description
Build description signature: 59a67742d7c91632124a84ee6622b65c
Build description path: /Users/luan/Library/Developer/Xcode/DerivedData/Buzzbike-atvmsyprpckdeedqwjobpqcpyxjy/Build/Intermediates.noindex/XCBuildData/59a67742d7c91632124a84ee6622b65c-desc.xcbuild

note: Build preparation complete
note: Building targets in dependency order
/Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/ios/Pods/Target Support Files/Pods-Buzzbike/Pods-Buzzbike.debug.xcconfig:1:1: error: unable to open file (in target "Buzzbike" in project "Buzzbike")
/Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/ios/Pods/Target Support Files/Pods-Buzzbike/Pods-Buzzbike.debug.xcconfig:1:1: error: unable to open file (in target "Buzzbike" in project "Buzzbike")
/Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/ios/Pods/Target Support Files/Pods-Buzzbike/Pods-Buzzbike.debug.xcconfig:1:1: error: unable to open file (in target "Buzzbike" in project "Buzzbike")
/Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/ios/Pods/Target Support Files/Pods-Buzzbike/Pods-Buzzbike.debug.xcconfig:1:1: error: unable to open file (in target "Buzzbike" in project "Buzzbike")


** BUILD FAILED **

Build logs written to /Users/luan/Development/Buzzbike/buzzbike-mobile/packages/mobile/.expo/xcodebuild.log

Code of Conduct

  • I agree to follow this project's Code of Conduct

[question]: How does this work with VOIP Push Notifications?

How can we help?

I am actually a bit overwhelmed on how to setup voip notifications for RN Native with EAS? I previously worked with expo notifications, but switched to one signal.

Can I use the Expo Plugin also for voip or are there addtional steps required?

Thank you in advance!

OneSignal Expo SDK version

1.0.2

Platform

iOS

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

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.