OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 374 forks source link

Expo config plugin #1252

Closed slorber closed 2 years ago

slorber commented 3 years ago

Description:

It would be great to have an Expo plugin in this repo.

This would allow Expo user to use this library with much less friction (ie no need to eject anymore to the Bare workflow):

https://blog.expo.io/expo-sdk-42-579aee2348b6 https://blog.expo.io/introducing-custom-development-clients-5a2c79a9ddf8

leggomuhgreggo commented 3 years ago

I came here to ask about this very same feature! Thanks @slorber for opening the issue!

I had some details prepared, which I'll add here, in case they're useful. The context is fairly broad, and so hopefully the notes below help make it easier to map out.

Would be so great to see this come to fruition -- been a dream for a while.

Thanks!

Feature Context

Over the past several months Expo has introduced features which enable apps to use external native modules, without ejecting Expo's managed workflow.

The customizations to the iOS and Android code that are required by a given native module are automated, using an AST-based API that Expo provides through "Config Plugins" feature.

These automations (called "mods") are executed during a new "Prebuild" phase, in which boilerplate ios and android directories are created — and then their respective files are altered, based on the instructions in a given modules config plugin. The end result is essentially the same as if you ejected and manually changed the ios/android files.

Here's the Expo blog post announcing Config Plugins and the associated feature-set.

Overview of Proposed Implementation

The process for creating a Config Plugin is detailed here: https://docs.expo.io/guides/config-plugins/#creating-a-plugin

There are a few different "recipes" for how to implement — but the gist of it is:

nicely commented 3 years ago

Can't we create a simple reusable plugin config that makes OneSignal modifications automatically and shares it with a public repo for the humanity? :D

rgomezp commented 3 years ago

Howdy, We are working on next steps regarding this request. Thank you for your patience.

Svarto commented 3 years ago

@rgomezp I am looking into this at the moment, did you make any progress?

rgomezp commented 3 years ago

@Svarto , Yes. We have a working version currently in testing.

Svarto commented 3 years ago

@Svarto , Yes. We have a working version currently in testing.

Cool! Can I help with the testing or could you share some of the code so I can spin up my own? I struggle specifically with adding the Notification Service Extension through the config-plugin, I struggle to get it registered correctly as an additional target...

rgomezp commented 3 years ago

I'll discuss internally whether we can share it publicly at this time.

You bring up a good point. We have run into the same issue. The NSE is tricky if not impossible to add through the plugin due to the apparent limitations of the XCode API. The good news is it isn't absolutely critical to have basic notifications working. However, you do miss out on some extra functionality.

LinFeiLong commented 3 years ago

Hi @rgomezp , any news on this one ?

rgomezp commented 3 years ago

Thanks, everyone for your patience.

Here is the repository.

Please note, the project is very much bare bones at the moment. Our hope is that the community (aka YOU!) can contribute to it directly and help shape it in its early stages. You have the opportunity to become an early contributor to what we hope will become a popular plugin for the React Native / Expo community.

Any feedback, suggestions, or direct contributions via PRs to improve it would be very much appreciated.

Enjoy!


cc: @LinFeiLong @Svarto @nicely @leggomuhgreggo @slorber @yourlocal @thalesog @m1st1ck @mrrenaud @jamesbechet @javascripter @wethechiang @karengrigoryan @devpato

Svarto commented 3 years ago

@rgomezp thanks for this and the work! I have OneSignal fully functioning with a custom config plugin I wrote. What's missing in the repository you shared?

My solution required diving into the Cordova xcode package to add a Target, as the Expo helpers don't allow for that yet.